Saturday, 21 August 2010

iptables destination nat and masquerade with-in an internal network

switched network environment, ubuntu ,accept all prerouting postrouting input forward output (don't do so in a production environment), each box has only eth0
A - 192.168.10.1
B - 192.168.10.2
C - 192.168.10.3 wheres apache2 is running on port 80

what I want to do is by typing B's address in box A's browser, and actually browsing C
now, configure B as an intermediate, and forward all incoming web request to C and the traffic back from C to its own origin (masquerade)


# enable ip forward first
echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 80 -d 192.168.10.3 -j MASQUERADE
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-dest 192.168.10.3



http://ubuntuforums.org/showthread.php?t=183994
http://forums.whirlpool.net.au/archive/505897
http://en.wikipedia.org/wiki/IP_masquerading

No comments:

Labels

Search This Blog