Adding a persistent static route

Whether your Windows server or Linux server has multiple NICs to connect it to multiple VLANs and/or networks, sometimes you’ll need to configure a static route so that your server knows which interface to use in order to get to the syslog server, ntp server etc if it is to use a route other than the default gateway.


vi /etc/gateways    (if this file doesn’t exist read on…)

Underneath>>    net gateway metric 1 passive

Add the following>>       net gateway metric 1 active

Note:  The default gateway is set in the /etc/defaultrouter file

If the /etc/gateways file doesn’t exist, then static routes may have been added “the old way”

cd /etc/rc2.d

ls | grep static

You may see a startup file called Snnnstatic_routes.  Inside this script will be non-persistent static routes added using lines that read something like /usr/sbin/route add 1   Append your routes to the ‘start’ section, not forgetting to add a corresponding route delete command in the ‘stop’ section.

Red Hat Linux

echo ‘ via’ >> /etc/sysconfig/network-scripts/route-eth0

service network restart

route -n to view the current routing table


route -p ADD MASK

netstat -rn to view the routing table

Excellent examples here: