hi every one..
i have a linux box on a network. the network has two IPv4 networks operating on the same wire. each of them has it's own gateway.
net1: 10.0.0.0/24 , gateway: 10.0.0.138 , box ip: 10.0.0.101
net2: 192.168.1.0/24 , gateway: 192.168.1.1 , box ip: 192.168.1.101
i want to access both networks and have access to the internet through both gateways. i did the following:
ip addr add 10.0.0.101/24 brd + dev eth0
ip addr add 192.168.1.101/24 brd + dev eth0
doing this, the machine can ping all other machines on the two networks, including the gateways.
to add the default gateways , i did the following:
ip route add default scope global nexthop via 10.0.0.138 nexthop via 192.168.1.1
now, i could do a ping google.com -I 192.168.1.101 successfully. but, ping google.com -I 10.0.0.138 failed. a quick sniffer check and i found that in both cases, the MAC address of 192.168.1.1 is used. i.e. only one gateway is used, not taking the source address in account.
when i switched the gateways in the command, 10.0.0.138 worked, but not 192.168.1.1:
ip route add default scope global nexthop via 192.168.1.1 nexthop via 10.0.0.138
last one in the command is the one that works! i can't explain this.
if any one can point out what's wrong with this setup, it would be great! any help or hints would be nice, too...
thanks in advance...