[CentOS] routing multiple network cards on a single subnet

Wed Jan 20 19:28:44 UTC 2010
Frank Cox <theatre at sasktel.net>

On Wed, 2010-01-20 at 10:27 -0600, Frank Cox wrote:

> My problem is that I can only access one IP address at a time.  I
> started out using dhcp and found that if I went through the dhcp
> song-and-dance then that address became active and the other one was
> disabled, and vice versa.

The solution has been found, thanks to one of the guys on our local tech
mailing list (who is a truly wonderful and extremely knowedgable and
helpful person).

For the benefit of anyone else who might have occasion to do this, here
is the complete solution.

My IP addresses are eth1=24.89.92.178, eth2=24.89.92.180
Gateway for both is 24.89.92.1

First, add two lines to /etc/iproute2/rt_tables, so it looks like this:

#
# reserved values
#
255     local
254     main
253     default
0       unspec
#
# local
#
#1      inr.ruhep
50      access1
60      access2

Then add the following routes:

ip route add 24.89.92.0/24 dev eth1 table access1
ip route add default via 24.89.92.1 dev eth1 table access1
ip rule add from 24.89.92.178/32 lookup access1

ip route add 24.89.92.0/24 dev eth2 table access2
ip route add default via 24.89.92.1 dev eth2 table access2
ip rule add from 24.89.92.180/32 lookup access2


> 
-- 
MELVILLE THEATRE ~ Melville Sask ~ http://www.melvilletheatre.com