Skip to contentSkip to conversation

NAT and IPSEC

DISCUSSION Stephen Clark 2 participants 2 messages Apr 16, 2009 netfilter

lore
Share & tools
lore
#0 lore raw

Hello,

I have to separate ipsec tunnels going to two different private networks. How do I keep iptables from natting the traffic destined for these 2 networks. I tried:

iptables -t nat -A POSTROUTING -o eth1 -d ! 192.168.1.0/24 -d ! 172.16.0.0/16 -j MASQUERADE

but it says only one -d is allowed. So I tried
iptables -t nat -A POSTROUTING -o eth1 -d ! ( 192.168.1.0/24 || 172.16.0.0/16 ) -j MASQUERADE

and it says "(" error. So how do I specify multiple destination networks/addresses to be excluded from being natted.

Thanks,
Steve

Signature · 5 lines
"They that give up essential liberty to obtain temporary safety,
deserve neither liberty nor safety."  (Ben Franklin)

"The course of history shows that as a government grows, liberty
decreases."  (Thomas Jefferson)
#1 lore raw
Quoted 10 lines · Stephen Clark

Hello,

I have to separate ipsec tunnels going to two different private networks. How do I keep iptables from natting the traffic destined for these 2 networks. I tried:

iptables -t nat -A POSTROUTING -o eth1 -d ! 192.168.1.0/24 -d ! 172.16.0.0/16 -j MASQUERADE

but it says only one -d is allowed. So I tried

Create a new chain from which you prematurely exit if the daddr is 192.168.1.0/24 or 172.16.0.0/16, and the third rule would masq.

Quoted 5 lines

iptables -t nat -A POSTROUTING -o eth1 -d ! ( 192.168.1.0/24 || 172.16.0.0/16 ) -j MASQUERADE

and it says "(" error. So how do I specify multiple destination networks/addresses to be excluded from being natted.