Linux – multiple IP addresses bound – which one is used for outgoing packets

iptableslinuxnetworkingshorewall

Using IP aliasing a linux box has bound multiple ip addresses from the same subnet on the same NIC. So ifconfig shows up device eth0 with , eth0:1 with and eth0:2 with .

How does Linux determine the IP source address used for outgoing ip traffic? Is there a way to define what source IP address certain outgoing traffic should use?

Best Answer

I'm not sure why he posted his answer as a comment, but David Schwartz is correct, you should set a netmask of 255.255.255.255 on the 'secondary' addresses, and you should not set gateway addresses on them. You put the correct netmask on the main address, and give it the correct gateway address.