how to change ip source address of incoming packets

Gáspár Lajos swifty at
Wed Nov 15 09:13:07 CET 2006

Matevz Langus írta:
> Does anyone know how to change ip source address when entering Linux 
> interface to something else and when leaving out the same interface 
> (backwards) changing it back.
> The problem is this:
> I have 10 devices with the same IP address, They are 
> connected to ethernet switch, which adds VLAN TAG to packets from each 
> device. Linux box is connected to the switch. It is possible to create 
> 10 VLAN interfaces on the Linux box and only one address 
> will be seen per interface. In order to establish TCP connections to 
> all devices at the same time, source address must be altered.
> on eth0.10, INPUT SRC ->
> on eth0.10, OUTPUT DST ->
> on eth0.11, INPUT SRC ->
> on eth0.11, OUTPUT DST ->
> ...
Try this :

iptables -t nat -A POSTROUTING -j SNAT -i eth0.10 -s 
iptables -t nat -A PREROUTING -j DNAT -o eth0.10 -d 
> thanks,
>   Matevz Langus

More information about the netfilter mailing list