hello,
I set a 4 computer LAN with configuration as
HostA
eth0=> 192.168.1.100
Router1
eth0=>10.1.1.1
eth1=>192.168.1.1
Router2
eth0=>10.1.1.100
eth1=>172.16.1.1
HostB
eth0=>172.16.1.100
I have already “echo 1 > /proc/sys/net/ipv4/ip_forward” performed on both machines.
From HostA(192.168.1.100) I am pinging HostB (172.16.1.100).
What i want Among Set 3 Networks whenever packet generated for HostB(172.16.1.100) At HostA(192.168.1.100) Router1 has to SNAT for Outgoing Packet from 192.168.1.100 to 10.1.1.1
Similarly, whenever packet generated for HostA(192.168.1.100) At HostB(172.16.1.100), Router2 has to SNAT for Outgoing Packet from 172.16.1.100 to 10.1.1.100
What should i do to achieve this? Because in my current configuartion only Ping originating Host’s Router able to SNAT but nor for reply packet from otherside by other sides’s Router. why?
My current configuartion is
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth0 -o eth1 -m state –state
ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT