On CentOS 5 I manually added a static route to make all packets to one specific IP address use the second network interface:
ip route add 123.456.7.89/32 via 192.168.10.101 dev eth1
Is there a way to make this change be persistent on reboot without adding it to the startup script /etc/rc.d/rc.local
?
Yes. Add the line:
to
/etc/sysconfig/network-scripts/route-eth1
as shown here.While this answer works, the current preferred format for
/etc/sysconfig/network-scripts/route-ethX
is:Be sure to increment the value of the numeral when you add a route.
Unfortunately, the new preferred format of
GATEWAYX:/ADDRESSx:/NETMASKx:/
makes it harder to programmatically add static routes via the older format of192.168.1.0/24 via 10.1.1.1
. It can be worked around, but adds unnecessary complications to scripting routes.