NAT with two external IP numbers

former03 | Baltasar Cevc baltasar.cevc at
Thu Nov 16 17:32:06 CET 2006

Hi Mogens,

> Give the linux box two IP numbers externally,
> e.g. and, register
> with the journal, change the
> internal IP numbers so that:
 > [...]
> /sbin/iptables -t nat -A POSTROUTING -s -o eth0 -j 
> /sbin/iptables -t nat -A POSTROUTING -s -o eth0:1 -j 

eth0:1 is not a real interface so no packets can go out there. It would 
good if iptables would throw an error, but probably it's hard for the 
to tell what are 'real' interfaces.

You must use the SNAT target to achieve what you want:
/sbin/iptables -t nat -A POSTROUTING -s -o eth0 -j SNAT 
/sbin/iptables -t nat -A POSTROUTING -s -o eth0 -j SNAT 

(Please note that both rules use eth0 as that's the interface where the 
go out).

Hope that helps,

More information about the netfilter mailing list