Port forwarding: Difference between revisions

From finninday
Jump to navigation Jump to search
(Created page with "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 co...")
 
No edit summary
Line 6: Line 6:
* http://www.frozentux.net/iptables-tutorial/iptables-tutorial.html#IPHEADERS
* http://www.frozentux.net/iptables-tutorial/iptables-tutorial.html#IPHEADERS
* http://www.ridinglinux.org/2008/05/21/simple-port-forwarding-with-iptables-in-linux/
* http://www.ridinglinux.org/2008/05/21/simple-port-forwarding-with-iptables-in-linux/
Create the FORWARD rule
<pre>
[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
</pre>
Create the NAT rule
<pre>
[0:0] -A PREROUTING -p tcp -i lo --dport 7777 -j DNAT --to-destination 10.0.0.45:7777
</pre>
Create the MASQUERADE rule.
<pre>
[0:0] -A POSTROUTING -o eth0 -j MASQUERADE
</pre>

Revision as of 05:53, 10 October 2013

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