Most people just put one GATEWAY line in either /etc/sysconfig/network or /etc/sysconfig/network-scripts/ifcfg-eth0.
Many years ago - very early linux kernels - you could have as many default routes as you had interfaces, and it worked perfectly. I ran over 30 multihomed hosts, each with four default routes, and loved it. The linux network stack of that time, which I think came from SUCS, was one of the reasons I started using it.
But now if you try that and run tcpdump on the output you will be pretty horrified. The packets go all over the damn place. DO NOT LIKE.
So you can't easily have multiple defaults any more unless you use policy routing, or run some kind of routing daemon like gated. Unfortunately some opportunistic clods bought the gated sources from Merit and closed the formerly free open source program so I would never use that, and zebra/quagga et al seem to be pretty raw and unfinished. Policy routing to the rescue.
Policy routing discussion here->
http://kindlund.wordpress.com/2007/1...utes-in-linux/
You can implement policy routing on Red Hat/Centos that will survive a reboot by modifying the ifcfg-eth?, rule-eth?, and route-eth? files found in /etc/sysconfig/network-scripts. The explanation that follows was written by the late Lou Goddard; he was configuring RHES5 at the time.
THIS IS FOR PROS ONLY
/etc/sysconfig/network-scripts/ifcfg-eth? and /etc/sysconfig/network must not contain any GATEWAY entries.
You must have a rule-eth? file for each ifcfg-eth? file.
Each /etc/sysconfig/network-scripts/rule-eth? file should contain the following line:
from xxx.xxx.xxx.0/24 tab B priority C
* xxx.xxx.xxx = the first three octets of the IP address of this ethernet interface
* B = ethN + 1
* C = arbitrary priority, I simply started at 500 for eth0 and incremented by 100 per interface
So, in my own rule-eth0 you will find:
from 192.168.10.0/24 tab 1 priority 500
And in rule-eth1 you will find:
from 192.168.20.0/24 tab 2 priority 600
And so on......
Next, let's look at the route-eth? files. They contain the following:
default via yyy.yyy.yyy.yyy dev ethN tab B
* yyy.yyy.yyy.yyy = the default route associated with this network interface
* B = ethN + 1
* N = the ethernet interface you're working on.
So, in route-eth0 you will find:
default via 192.168.10.12 dev eth0 tab 1
And so on....
To check your work you may run the following commands and examine the output.
[root@mrwizard ~]# ip route show
192.168.10.0/24 dev eth0 proto kernel scope link src 192.168.10.3
192.168.20.0/24 dev eth1 proto kernel scope link src 192.168.20.3
192.168.30.0/24 dev eth2 proto kernel scope link src 192.168.30.3
192.168.40.0/24 dev eth3 proto kernel scope link src 192.168.40.3
169.254.0.0/16 dev eth3 scope link
default via 192.168.10.12 dev eth0
[root@mrwizard ~]# ip route list ta 1
default via 192.168.10.12 dev eth0
[root@mrwizard ~]# ip route list ta 2
default via 192.168.20.12 dev eth1
[root@mrwizard ~]# ip route list ta 3
default via 192.168.30.12 dev eth2
[root@mrwizard ~]# ip route list ta 4
default via 192.168.40.12 dev eth3
[root@mrwizard ~]# ip rule list
0: from all lookup 255
500: from 192.168.10.0/24 lookup 1
600: from 192.168.20.0/24 lookup 2
700: from 192.168.30.0/24 lookup 3
800: from 192.168.40.0/24 lookup 4
32766: from all lookup main
32767: from all lookup default