My setup is as follows:
I have a Linux server with two interfaces,
eth1 has an Internet connection through my normal LAN.
eth0 is serving DHCP and the interface itself has an IP address of
I want to accomplish the following:
I want to have packets on port 80 originating from machines connected to
eth0 to be redirected to port 80 on the routing machine itself, and response packets to of course be redirected back. That in itself is simple enough, but I have one more requirement. I would like clients on
eth0 with certain IP addresses to be able to be exempt from this, and have port 80 packets routed as they normally would be. How can I do this? So far, I've done the following to redirect all port 80 packets from
eth0 to the local machine. It is working, but I do not know how to do my second requirement.
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 10.0.0.1:80 -i eth0
iptables -t nat -A POSTROUTING -p tcp -d 127.0.0.1 --dport 80 -j SNAT --to-source 10.0.0.1