[NCLUG] Multiple nics same subnet

Michael Milligan milli at acmeps.com
Thu Mar 2 11:59:52 MST 2006


Bryan Stillwell wrote:
> On Wed, Mar 01, 2006 at 04:26:22PM -0700, Chris Funk wrote:
> 
>>Anyway,  I thought I would give each server it's own path to one of the
>>nics. So I setup  addresses  192.168.2.100 192.168.2.101, 192.168.2.102, and
>>192.168.2.103.  I'm sure you know what is happening.  All the traffic get's
>>sent back out the 192.168.2.100 nic.  I thought maybe shorewall and the
>>routeback option would work but it didn't. 
>>
>>Anything I can do to make the traffic go back out the same interface it was
>>received on?
> 
> 
> You need to set up static routes to each of those IP addresses.
> 
> Try something like this:
> 
>    route add 192.168.2.100 netmask 255.255.255.255 dev eth0
>    route add 192.168.2.101 netmask 255.255.255.255 dev eth1
>    route add 192.168.2.102 netmask 255.255.255.255 dev eth2
>    route add 192.168.2.103 netmask 255.255.255.255 dev eth3

That won't work at all.  You have to define each interface as having a 
/32 netmask and then add specific static routes for the remote addresses 
to force routing back out a specific interface.  So it can be done if 
you know the addresses of the other servers, which you do.  Here I 
assume they are 10.0.0.1 thru .4 :

ifconfig eth0 192.168.2.100 netmask 255.255.255.255 up
ifconfig eth1 192.168.2.101 netmask 255.255.255.255 up
ifconfig eth2 192.168.2.102 netmask 255.255.255.255 up
ifconfig eth3 192.168.2.103 netmask 255.255.255.255 up

route add -host 10.0.0.1 gw 192.168.2.100
route add -host 10.0.0.2 gw 192.168.2.101
route add -host 10.0.0.3 gw 192.168.2.102
route add -host 10.0.0.4 gw 192.168.2.103

This of course leads to asymmetric routing if the 10.0.0.1 server talks 
to 192.168.2.103...

Only way (I know of) to make this work for the general case is to use 
the policy routing feature of the iproute2 package.  You can configure a 
default route per interface.

"apt-get install iproute" on Debian-based distros.  Then "man ip".

Regards,
Mike

-- 
Michael Milligan                                   -> milli at acmeps.com



More information about the NCLUG mailing list