Here’s the docs from redhat on how to setup static routes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
/etc/sysconfig/network-scripts/route-<interface-namegt; Contains lines that specify additional routes that should be added when the associated interface is brought up. The files are processed by the ifup-routes script and uses the /sbin/ipcalc utility for all network masks and numbers. Routes are specified using the syntax: ADDRESSn=<network> NETMASKn=<network/prefix mask> GATEWAYn=<next-hop router/gateway IP address> The "n" can be any integer number, but is expected to be monotonically increasing and counting starts from 0. For example: ADDRESS0=192.168.2.0 NETMASK0=255.255.255.0 GATEWAY0=192.168.1.1 adds a network route to the 192.168.2.0 network via the gateway at 192.168.1.1. Since you must already have a route to the network of the gateway, there is no need to specify a device. Note: The ifup-routes script also supports an older syntax designed to be used directly as an argument to "/sbin/ip route add". This syntax is deprecated, but if no "ADDRESSn" lines are found the following will still work: 192.168.2.0/24 dev ppp0 adds a network route to the 192.168.2.0 network through ppp0. |
Let’s say you want to add two static routes to eth1. The first routes 10.10.10.0/255.255.255.0 to 10.10.10.1 and the second routes traffic from 10.10.11.0/255.255.255.0 to 10.10.11.1. To accomplish this create a file at:
1 |
/etc/sysconfig/network-scripts/route-eth1 |
And place the following lines in the file:
1 2 3 4 5 6 |
ADDRESS0=10.10.10.0 NETMASK0=255.255.255.0 GATEWAY0=10.10.10.1 ADDRESS1=10.10.11.0 NETMASK1=255.255.255.0 GATEWAY1=10.10.11.1 |
Then restart networking with:
1 |
/sbin/service network restart |