Port forwarding

From Finninday
Revision as of 05:53, 10 October 2013 by Rday (Talk | contribs)

Jump to: navigation, search

This should be so easy, but I've made several attempts and each have failed, so I need to start keeping track of what I have tried so I don't repeat myself.

The goal is to configure my iptables firewall to pass traffic from the internet through my server to a NATted box on my internal network where I'm running a service of some kind.

References:

Create the FORWARD rule

[0:0] -A FORWARD -p tcp -d 10.0.0.45 --dport 7777 -j ACCEPT
[0:0] -A FORWARD -p udp -d 10.0.0.45 --dport 7777 -j ACCEPT

Create the NAT rule

[0:0] -A PREROUTING -p tcp -i lo --dport 7777 -j DNAT --to-destination 10.0.0.45:7777

Create the MASQUERADE rule.

[0:0] -A POSTROUTING -o eth0 -j MASQUERADE