Pages

How to Add / Remove Static route in a RHEL



List all the current static routes

# route -n

Add a route to the network 192.56.76.x via "eth1"

# route add -net 192.56.76.0 netmask 255.255.255.0 dev eth1

Add a route to a host 192.168.76.10 via "eth1"

# route add -host 192.56.76.10 dev eth1

Delete a existing route to the network 192.56.76.x via "eth1"

# route del -net 192.56.76.0 netmask 255.255.255.0 dev eth1


To Make the route Persistent across reboots make the route entries are added in the route file "/etc/sysconfig/network-scripts/route-<interface> " ,for example to add static route for eth1 create a file "/etc/sysconfig/network-scripts/route-eth1" and add the below mentioned entries to make a persistent route for the network 192.56.76.0/24 via the gateway 192.168.1.3

# vi /etc/sysconfig/network-scripts/route-eth1

default via 192.168.1.2
192.56.76.0/24 via 192.168.1.3

No comments:

Post a Comment