Port forwarding
Jump to navigation
Jump to 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:
- http://www.frozentux.net/iptables-tutorial/iptables-tutorial.html#IPHEADERS
- http://www.ridinglinux.org/2008/05/21/simple-port-forwarding-with-iptables-in-linux/
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