NAT problem with iptables...
Hi Guys;
I'm fighthing almost second day with NAT problem. I need to translate local IP to 'normal' Inet IPs. I set up one box which have two NIC cards. One side is connected to local LAN with IP 192.168.0.x and other side is connected to 'copy' of firewall which is used in production. I would like to simulate situation as on Inet. I don't want to change IP of firewall which I would like to debug. I need to setup iptables on linux translating box as follows:
192.168.0.230 <-> 64.124.175.104
192.168.0.231 <-> 64.124.175.105
192.168.0.232 <-> 208.184.248.9
--
*IN ROOT WE TRUST*
Marian Stepka <mailto:[email protected]>
Quoted 10 lines · Marian Stepka
Hi Guys;
I'm fighthing almost second day with NAT problem. I need to translate local IP to 'normal' Inet IPs. I set up one box which have two NIC cards. One side is connected to local LAN with IP 192.168.0.x and other side is connected to 'copy' of firewall which is used in production. I would like to simulate situation as on Inet. I don't want to change IP of firewall which I would like to debug. I need to setup iptables on linux translating box as follows:
Quoted 3 lines
192.168.0.230 <-> 64.124.175.104
192.168.0.231 <-> 64.124.175.105
192.168.0.232 <-> 208.184.248.9
iptables -A PREROUTING -t nat -d 192.168.0.230 -j DNAT --to 64.124.175.104 iptables -A PREROUTING -t nat -d 192.168.0.231 -j DNAT --to 64.124.175.105 iptables -A PREROUTING -t nat -d 192.168.0.232 -j DNAT --to 208.184.248.9 iptables -A POSTROUTING -t nat -s 64.124.175.104 -j SNAT --to 192.168.0.230 iptables -A POSTROUTING -t nat -s 64.124.175.105 -j SNAT --to 192.168.0.231 iptables -A POSTROUTING -t nat -s 208.184.248.9 -j SNAT --to 192.168.0.232
plus the appropriate FORWARDing rules for whatever protocols you want to allow to/from these addresses.
Antony.
Signature · 5 lines
You can spend the whole of your life trying to be popular, but at the end of the day the size of the crowd at your funeral will be largely dictated by the weather. - Frank Skinner
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Marian Stepka
Hi Antony;
Quoted 8 lines
iptables -A PREROUTING -t nat -d 192.168.0.230 -j DNAT --to 64.124.175.104 iptables -A PREROUTING -t nat -d 192.168.0.231 -j DNAT --to 64.124.175.105 iptables -A PREROUTING -t nat -d 192.168.0.232 -j DNAT --to 208.184.248.9 iptables -A POSTROUTING -t nat -s 64.124.175.104 -j SNAT --to 192.168.0.230
iptables -A POSTROUTING -t nat -s 64.124.175.105 -j SNAT --to 192.168.0.231
iptables -A POSTROUTING -t nat -s 208.184.248.9 -j SNAT --to 192.168.0.232
Quoted 5 lines
I'd try this solution but it working only partly. When I log what happening, only destination address is translated. When I try to ping f.g. 192.168.0.230 it is tranlated to 64.124.175.104 but id does not goes back. So ping is not successful. But I can ping card directly from translating box. So network seems to be set up properly.
Does the destination machine know how to route back to the source machine
correctly ? (See my sig below, which quite by chance came out with this one
for this email !)
Antony.
Signature · 3 lines
90% of network problems are routing problems. 9 of the remaining 10% are routing problems in the other direction. The remaining 1% might be something else, but check the routing anyway.