Add a Persistent Static Route in Redhat Enterprise Linux

If you know there is always going to be a permanent route for a destination then a static route can be a viable option.To add a persistent static route in Redhat Enterprise Linux create a file called route-X in the /etc/sysconfig/network-scripts/ directory

where is the interface number and X is the interface number. As you would expect, these are specified in seperate file for each of the available interface.

Example:

/etc/sysconfig/network-scripts/route-eth0
/etc/sysconfig/network-scripts/route-eth1

Every entry or a route has three entities as follows:

GATEWAY=xxx.xxx.xxx.xxx
NETMASK=yyy.yyy.yyy.yyy
ADDRESS=zzz.zzz.zzz.zzz

As the names implies, they are the gateway IP, Netmask and the IP/Network Address

Note the next to each of the three entities. This number defines the route entry number and should be the same on all the entities.

Example:

GATEWAY0=192.168.1.1
NETMASK0=255.255.255.0
ADDRESS0=10.10.10.0

GATEWAY1=192.168.1.1
NETMASK1=255.255.255.0
ADDRESS1=20.20.20.2

A sample file /etc/sysconfig/static-routes is available for your reference.

Once the file is created, restart the network service as follows:

# service network restart

To view the routes type

# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
192.168.2.0 * 255.255.255.0 U 0 0 0 eth1
10.10.10.0 * 255.255.255.0 U 0 0 0 eth0
20.20.20.2 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth1
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0

Comments

Popular posts from this blog

configure Netbackup email notification on Unix