Nat – how to correctly change the source ip of a ping packet

nat;

So I have a private network and there is a host with ip = 10.20.111.2
and there is a firewall for this host which has ip = 10.20.111.1
And of course i has external network , host ip =10.10.111.107

So i would like my external host to ping the private host and private host reply. After that, the external host will examine the ping packet and should find the private host has a IP address = 10.10.111.1

And i used the command on the firewall:
-iptables -F
-iptables -t nat -A POSTROUTING -o eth0 -j SNAT –to 10.10.111.1

but when i examine the echo from the external machine, the packet from the private network still has source address = 10.20.111.2 ..which means my command doesn't work.

Please help :(…

Best Answer

Try something like:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE --to 10.10.111.1
Related Topic