On Thursday 25 May 2006 08:35, Joshua Gimer wrote:
There isn't going to be a difference to your routing. Whatever gateway comes first in your routing table is going to be used first. You can add the one that you want to use as the primary gateway in ifcfg-ethx of your first interface. Then you should see two entries in your routing table (along with the usual entries and information):
Destination Gateway Genmask Interface 0.0.0.0 (The address of your first gateway) 0.0.0.0 eth0 0.0.0.0 (The address of your second gateway) 0.0.0.0 eth1
On 5/25/06, Tom Brown tom@ng23.net wrote:
Hi
On a multihomed box how can i set different gateways for each NIC? Setting them in the ifcfg-ethx does not seem to make any difference to the routing?
thanks _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Hi,
I've done some work on this a few month ago at my other job, and basically the solution lies in iproute2 commands.
First you need to create a rule and assign that traffic to a different table than the main table. Then you can easily add a default route to that new table.
so it would look like this
ip rule add from 192.168.1.0/24 table X
check /etc/iproute2/rt_tables if you want to make aliases like eth1 eth2 eth3 it will get easier if you automate this thing :)
After that you set a default route to this new table.
ip route add default via 1.2.3.4 table X
Once you have this done and working it's a matter of getting your dhclient of pppoe to do this for you as soon as ip changes.
for pppoe create a /etc/ppp/ip-up.local script. for dhclient stuff you need to look in /sbin/dhclient-script script to find out how it will execute what's in /etc/dhclient-enter-hooks or /etc/dhclient-exit-hooks
It's quite useful and for me it did turn out to work nicely. I just had to create some sort of master script that would take decisions on what's going on with my gateways :) It was pretty fun to work on that. I hope this helps you out.
Later, Charles