Iptables massive 1:1 NAT

Posted by TiFFolk on Server Fault See other posts from Server Fault or by TiFFolk
Published on 2010-02-04T13:40:12Z Indexed on 2010/04/09 7:03 UTC
Read the original article Hit count: 357

Filed under:
|

I have to connect two LANs: LAN1: 10.10.0.0/16 and LAN2: 192.168.0.0/16. I can't do simple routing, because 192.168.0.0/16 net is prohibited in LAN1, so I am thinking of using Full cone nat (1:1) to translate 192.168.x.y/16 to 10.11.x.y/16. Each translation is done by this rules:

iptables -t nat -A PREROUTING -d 10.11.0.0/16 -j DNAT --to-destination 192.168.0.0/16
iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -j SNAT --to-source 10.11.0.0/16

But I will have to enter 254*254*2 rules, what will, I think, result in enormous performance degradation. So, is there a way to write such one-to-one translation with minimum number of rules?

© Server Fault or respective owner

Related posts about iptables

Related posts about nat