I have a home network with Linux pc\'s, which all had iptables running. I think it is easier to put my LAN behind a Linux gateway/firewall, so I\'ve put a pc (with fedora,no gui
RedHat has a great doc about iptables (a little bit long), but the subject to cover is complex and there are so many different use cases that I don't see how to avoid it.
Here is the chapter about FORWARD and NAT Rules. As it states:
For example, if you want to forward incoming HTTP requests to your dedicated Apache HTTP Server at 172.31.0.23, use the following command as the root user:
~]# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 172.31.0.23:80
Here is what happens:
x.x.x.x:y
(sender IP from the internet & source port used for packet transmission)192.168.1.1:80
(assuming your linux gateway IP on external NIC, ie p1p1
)-j
) to the DNAT function (Destination Network Address Translation) which changes the destination of the packet header from the initial 192.168.1.1:80
to 172.31.0.23:80
.172.31.0.23:80
.
192.168.1.1:80
) ? No, so I won't send it to the INPUT chain.filter
chain FORWARD
), the packet should be forwarded correctly to your local Apache HTTP Server (for example).Hope it'll help to understand a little bit more how internal routing works with iptables.