Skip to contentSkip to conversation

SNAT problem

DISCUSSION Yevgeny Kosarzhevsky 2 participants 3 messages Aug 22, 2010 – Sep 13, 2010 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi,

I have the issue with incorrect SNAT.

I have two interfaces, let's say ppp0 - x.x.x.x, ppp1 - y.y.y.y ppp0 is a default gateway. I use some command to change routing to IP z.z.z.z via ppp1:
ip ro ad to z.z.z.z dev ppp1

I have SNAT rules for both interfaces, however, I notice with tcpdump that outgoing packets are still using x.x.x.x instead of y.y.y.y IP, though packets are being sent with the correct interface (ppp1)

I have shut down ppp0 and removed SNAT rule for it, but outgoing packets are still showing x.x.x.x IP. Even, ip ro fl cache didn't help.

Is there anything I am doing wrongly? I suppose this is some unwanted behaviour.

warp:~# uname -a
Linux warp 2.6.32-5-686 #1 SMP Thu Aug 12 13:38:27 UTC 2010 i686 GNU/Linux
#1 lore raw
Quoted 6 lines · Yevgeny Kosarzhevsky

I have two interfaces, let's say ppp0 - x.x.x.x, ppp1 - y.y.y.y ppp0 is a default gateway.
I use some command to change routing to IP z.z.z.z via ppp1:
ip ro ad to z.z.z.z dev ppp1

Quoted 6 lines

I have SNAT rules for both interfaces, however, I notice with tcpdump that outgoing packets are still using x.x.x.x instead of y.y.y.y IP, though packets are being sent with the correct interface (ppp1)

I have shut down ppp0 and removed SNAT rule for it, but outgoing packets are still showing x.x.x.x IP. Even, ip ro fl cache didn't help.

If the packets belong to an existing connection (conntrack-wise) which was established before the route change, this behaviour is expected. Changing the source address may break the connection.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 15 lines · Yevgeny Kosarzhevsky
Quoted 14 lines · Pascal Hambourg
Quoted 12 lines · Yevgeny Kosarzhevsky

I have two interfaces, let's say ppp0 - x.x.x.x, ppp1 - y.y.y.y ppp0 is a default gateway.
I use some command to change routing to IP z.z.z.z via ppp1:
ip ro ad to z.z.z.z dev ppp1

I have SNAT rules for both interfaces, however, I notice with tcpdump that outgoing packets are still using x.x.x.x instead of y.y.y.y IP, though packets are being sent with the correct interface (ppp1)

I have shut down ppp0 and removed SNAT rule for it, but outgoing packets are still showing x.x.x.x IP. Even, ip ro fl cache didn't help.

Quoted 8 lines
Quoted 3 lines

If the packets belong to an existing connection (conntrack-wise) which was established before the route change, this behaviour is expected. Changing the source address may break the connection.

I have this trouble for new ipsec connections. I change route on my gateway and then trying to establish ipsec connection. I see on the gateway with tcpdump that the address of outgoing packets are still belong to old interface.

Is the new IPSec connection to the same destination address ? If so, then the connection tracking and NAT system may consider it is the same connection and uses the same NAT mapping as before.

Did you wait until the old IPSec conntrack entry expires (check in /proc/net/nf_conntrack) or try to delete it with the conntrack tool ?