Operating System - Linux
1829596 Members
1959 Online
109992 Solutions
New Discussion

Re: Which file to add route ?

 
SOLVED
Go to solution
Patrick Chim
Trusted Contributor

Which file to add route ?

Hi

Which file should I modify to add a route to the system even though the linux machine has rebooted and the route still exist ?

Regards,
Patrick
2 REPLIES 2
John-Thomas Gaietto
Trusted Contributor
Solution

Re: Which file to add route ?

Patrick,
I'll assume you have Red hat Linux or similar based distro. The file you want to edit to add a permanent route is /etc/sysconfig/static-routes. Also to add / remove a route on the fly for a host

route add -host 10.10.10.45 gw 192.168.0.1
route del -host 10.10.10.45 gw 192.168.0.1

To Add / Remove a network

route add -net 10.10.10.0/24 gw 192.168.0.1
route del -net 10.10.10.0/24 gw 192.168.0.1


To add / remove a default gateway

route add default gw 192.168.0.1
route del default gw 192.168.0.1

Also as always netstat -rn to check current routing table. I hope I covered all the bases for you if this helps please don't forget the points.


U.SivaKumar_2
Honored Contributor

Re: Which file to add route ?

Hi,
you can add the following two lines to the file "/etc/sysconfig/static-routes":
eth0 net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1
eth1 net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.2
In this Example
network number - 192.168.2.0
network mask - 255.255.255.0
gateway - 192.168.2.1

regards,
U.SivaKumar

Innovations are made when conventions are broken