Skip to contentSkip to conversation

ipsec nat issue

DISCUSSION Stephen Clark 2 participants 4 messages Oct 12, 2012 – Oct 13, 2012 netfilter

lore
Share & tools
lore
#0 lore raw

Hello,

I have the following setup:

ipsec tunnel 10.255.3.128/25 - pub add1 <-> pub add2 - 10.255.5.128/25

trying to SNAT remote private address 10.255.5.128/25 to make it appear like it was local 10.255.3.254 but it doesn't work - see below.

iptables -t nat -I POSTROUTING -o eth0 -s 10.255.5.128/25 -d 10.255.3.128/25 -j SNAT --to-source 10.255.3.254

Chain POSTROUTING (policy ACCEPT 6 packets, 456 bytes)
pkts bytes target prot opt in out source
destination

    0     0 SNAT       all  --  *      eth0    10.255.5.128/25      

10.255.3.128/25 to:10.255.3.254

$ sudo tcpdump -nli eth0 icmp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
15:20:17.772396 IP 10.255.5.254 > 10.255.3.129: ICMP echo request, id 52588, seq 62, length 64
15:20:18.777272 IP 10.255.5.254 > 10.255.3.129: ICMP echo request, id 52588, seq 63, length 64
15:20:19.772572 IP 10.255.5.254 > 10.255.3.129: ICMP echo request, id 52588, seq 64, length 64
15:20:20.770681 IP 10.255.5.254 > 10.255.3.129: ICMP echo request, id 52588, seq 65, length 64

I would expect 10.255.5.254 to be replaced with 10.255.3.254 what am I missing? Is this possible I could do it when we were using FreeBSD.

I didn't find anything googling.

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 8 lines · Stephen Clark

Hello,

I have the following setup:

ipsec tunnel 10.255.3.128/25 - pub add1 <-> pub add2 - 10.255.5.128/25

trying to SNAT remote private address 10.255.5.128/25 to make it appear like it was local 10.255.3.254

The left endpoint has 10.255.3.128/25 declared as local, so if the left side is to respond to packets which have 10.255.3.254 as source address, that reply will be delivered on its own side (the left side), and never the tunnel.

This is like trying to SNAT all your home traffic that is supposed to go to the internet to 192.168.1.1 -- unroutable for the Internet.

#2 lore raw
Quoted 12 lines · Jan Engelhardt
Quoted 9 lines · Stephen Clark

Hello,

I have the following setup:

ipsec tunnel 10.255.3.128/25 - pub add1<-> pub add2 - 10.255.5.128/25

trying to SNAT remote private address 10.255.5.128/25 to make it appear like it was local 10.255.3.254

Quoted 9 lines

The left endpoint has 10.255.3.128/25 declared as local, so if the left side is to respond to packets which have 10.255.3.254 as source address, that reply will be delivered on its own side (the left side), and never the tunnel.

This is like trying to SNAT all your home traffic that is supposed to go to the internet to 192.168.1.1 -- unroutable for the Internet.

Hi Jan,

The ping is initiated from the right side of the tunnel trying to ping a device on the left subnet. The device on the left subnet at 10.255.3.129 doesn't know about the right subnet at 10.255.5.128/25 so I want to make the packets coming from the right subnet of 10.255.5.128/25 appear as if they came from the left address of 10.255.3.254. I would expect that when the echo response came back from 10.255.3.129 it would be unSNATed so the destination address would now be 10.255.5.254 and it would go back thru the vpn tunnel to the right side.

I don't see this as any different than when I use SNAT from my private network to my public network except I using two private addresses.

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)
#3 lore raw

Sorry for the noise.

I had started the ping before I added the NAT rule so either conntrack or the route cache was keeping the packet from going thru the SNAT. I stopped the ping for a while then started it back up and everything worked as I expected.

Quoted 31 lines · Stephen Clark
Quoted 10 lines · Jan Engelhardt
Quoted 8 lines · Stephen Clark

Hello,

I have the following setup:

ipsec tunnel 10.255.3.128/25 - pub add1<-> pub add2 - 10.255.5.128/25

trying to SNAT remote private address 10.255.5.128/25 to make it appear like it was local 10.255.3.254

Quoted 8 lines

The left endpoint has 10.255.3.128/25 declared as local, so if the left side is to respond to packets which have 10.255.3.254 as source address, that reply will be delivered on its own side (the left side), and never the tunnel.

This is like trying to SNAT all your home traffic that is supposed to go to the internet to 192.168.1.1 -- unroutable for the Internet.

Hi Jan,

The ping is initiated from the right side of the tunnel trying to ping a device on the left subnet. The device on the left subnet at 10.255.3.129 doesn't know about the right subnet at 10.255.5.128/25 so I want to make the packets coming from the right subnet of 10.255.5.128/25 appear as if they came from the left address of 10.255.3.254. I would expect that when the echo response came back from 10.255.3.129 it would be unSNATed so the destination address would now be 10.255.5.254 and it would go back thru the vpn tunnel to the right side.

I don't see this as any different than when I use SNAT from my private network to my public network except I using two private addresses.

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)