Skip to contentSkip to conversation

Problem with SNAT and same port number

DISCUSSION [email protected] 1 participant 1 message Feb 23, 2004

lore
Share & tools
lore
#0 lore raw

Hi,

I am wanting to change the source address of outgoing packets that have a src port of 53.

I have tried
/sbin/iptables -A POSTROUTING -p tcp -t nat -o bond0 --sport 53 -j SNAT --to-source 192.168.0.1:53

This doesnt work, it seems to be that you cant SNAT to a port the same as the original src port because

/sbin/iptables -A POSTROUTING -p tcp -t nat -o bond0 --sport 53 -j SNAT --to-source 192.168.0.1

/sbin/iptables -A POSTROUTING -p tcp -t nat -o bond0 --sport 53 -j SNAT --to-source 192.168.0.1:52

both works, but obviously not the same results as I wanted because the src port is also changed.

Is there any other way to do what I am wanting??

TIA