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-<int>X in the /etc/sysconfig/network-scripts/ directory
where <int> 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.
Every entry or a route has three entities as follows:
As the names implies, they are the gateway IP, Netmask and the IP/Network Address
Note the <N> next to each of the three entities. This number defines the route entry number and should be the same on all the entities.
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
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
22.214.171.124 * 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
# ip route show
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.1
192.168.2.0/24 dev eth1 proto kernel scope link src 192.168.2.1
10.10.10.0/24 via 192.168.1.1 dev eth0
126.96.36.199/24 via 192.168.1.1 dev eth0
default via 192.168.1.1 dev eth0
To dynamically add a route, try the folowing:
# ip route add <Net/IP>/<Mask> via <Gateway> dev <Int>X
# ip route add 10.10.10.0/24 via 192.168.1.1 dev eth0
# route add [-net|-host] <IP/Net> netmask <Mask> gw <Gateway IP> dev <Int>X
# route add -net 10.10.10.0 netmask 255.255.255.0 gw 192.168.1.1 dev eth0
This should help.
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
Apparently your syntax is also supported, but the latest search I did of the RHEL4 support documentation yields the following URL for persistent static routes and the syntax of the route-ethX file:
The Redhat recommended syntax is:
10.0.1.0/24 via 192.168.2.4 dev eth0
default via 192.168.2.4 dev eth0
how to add permant route in RHEL4 is any file in that i need to change any conf
how to start samba service in aix5.3
I have one problem. I need add static route under /etc/sysconfig/network-scripts/route-eth0.2 and
GATEWAY0=192.168.1.1 ( this is vlan 2 ip address configured in router)
GATEWAY0=192.168.2.1( this is vlan 3 ip address configured in router)
the problem is destination IP address is same. the different is gateway address. because, VLAN2(etho.2) and VLAN 3(eth0.3) are routed by different paths( i mean different layer-3 devices)
once i add those and restart the network services, it shows only one route for that destination
could you please help me to figure out the problem
it worked for me by using the following command:
route add [ipadd] netmask [mask] gw [gateway] interface name
Hii, Its work for me with route-dev file, Thanks man
Hi, thanks a lot for your article is very helpful for me, thanks a lot man
freaking RHEL… what a pain.
can just add a -p switch or something to the route add command like solaris does… no, you have to go in and edit some obscure file and add three stanzas
freaking RHELâ€¦ what a pain.
can’t just add a -p switch or something to the route add command like solaris doesâ€¦ no, you have to go in and edit some obscure file and add three stanzas
It’s works very well on my Red Hat Linux Server release 5