LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How to add the permanent route in linux fedora core 6 (https://www.linuxquestions.org/questions/linux-networking-3/how-to-add-the-permanent-route-in-linux-fedora-core-6-a-664532/)

cmx08 08-22-2008 03:13 AM

How to add the permanent route in linux fedora core 6
 
Hi All

Can any body tell me how to add the permanent route in linux fc6. I add the route by using the route command but after the server restart all the route table gone. This is very troublesome for me. Which file i should go to add the permanent route?

Thx.

keratos 08-22-2008 07:58 PM

1. are you using DHCP
2. where in the table are you adding the hop
3. did you try changing the config files.

cmx08 08-23-2008 05:17 AM

1st thx for reply. I not using DHCP. I add the static route by directly type the route command for example:

[root@localhost ~]# route add -net 10.1.40.0 netmask 255.255.254.0 gw 192.168.102.40
[root@localhost ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
203.188.239.0 * 255.255.255.192 U 0 0 0 eth0
192.168.102.0 * 255.255.255.0 U 0 0 0 eth1
192.168.10.0 192.168.102.40 255.255.255.0 UG 0 0 0 eth1
10.1.40.0 192.168.102.40 255.255.254.0 UG 0 0 0 eth1
169.254.0.0 * 255.255.0.0 U 0 0 0 eth1
default 203.188.239.1 0.0.0.0 UG 0 0 0 eth0

My question is which file should I go to add the permanent route to prevent the route table gone after the server reboot? This route table will gone after I restart the server. I am still new in using Linux so I don't know which file should I refer to add permanent route.

Thx.

keratos 08-23-2008 01:31 PM

hi pal

there is not config file (i.e something in /etc/???) for route

there are several options however to embed your route command in a startup file.

perhaps the best is in /etc/init.d/rc.local which is run at each system startup.

just add your route command to the end of the file

other files that could be modified are /etc/sysconfig/network-scripts/* , /etc/login /etc/bash_rc and so on and alike however linux etiquette kind of discourages this, rc.local is the "defacto" system startup tweak.

cmx08 08-27-2008 08:11 AM

Hi. Thx for help. Its working fine now. One more question after I add the route in etc/rc.local, can I run the rc.local without reboot the machine?

keratos 08-27-2008 01:04 PM

hang on , I'm talking SHITE

the file for static routing is in:

/etc/sysconfig/network-scripts/route-<interface>

where <interface> is your net physical device, e.g. eth0 , so

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

a sample static route where:
a) default gateway is 192.168.0.1 via interface eth0
and
b) static route for 10.10.10.0/24 subnet via the default gateway

would look like
Code:

default 192.168.0.1 dev eth0
10.10.10.0/24 via 192.168.0.1 dev eth0

( you may have to restart networking , i.e. /etc/init.d/network restart )

Warning! If you use the Network Manager GUI then it *may* overwrite the above, thats why I suggested rc.local

To run any of the startup scripts just "use" it , i.e. issue the command /etc/init.d/rc.local to run rc.local without rebooting) !!! Easy

cmx08 08-27-2008 11:29 PM

Thx a lot.

cmx08 09-01-2010 12:00 PM

Example for route

Quote:

[root@mahkamah ~]# cd /etc/sysconfig/network-scripts/
[root@mahkamah network-scripts]#
[root@mahkamah network-scripts]# less route-eth1
[root@mahkamah network-scripts]#
Quote:

0.0.0.0/0 via 192.168.100.235
192.168.100.24/30 via 192.168.100.235
192.168.100.28/30 via 192.168.100.235
192.168.100.32/30 via 192.168.100.235
192.168.100.36/30 via 192.168.100.235
192.168.100.40/30 via 192.168.100.235
192.168.100.44/30 via 192.168.100.235
192.168.100.48/30 via 192.168.100.235
192.168.100.52/30 via 192.168.100.235
192.168.100.56/30 via 192.168.100.235
192.168.100.60/30 via 192.168.100.235
192.168.100.64/30 via 192.168.100.235
192.168.100.68/30 via 192.168.100.235
192.168.100.72/30 via 192.168.100.235
10.254.100.0/24 via 192.168.100.235
10.254.21.0/24 via 192.168.100.235
10.254.23.0/24 via 192.168.100.235
10.254.31.0/24 via 192.168.100.235
10.254.32.0/24 via 192.168.100.235
10.254.22.0/24 via 192.168.100.235
10.254.13.0/24 via 192.168.100.235
10.254.12.0/24 via 192.168.100.235
10.254.11.0/24 via 192.168.100.235
10.254.10.0/24 via 192.168.100.235
10.254.9.0/24 via 192.168.100.235
10.254.8.0/24 via 192.168.100.235
10.254.6.0/24 via 192.168.100.235
10.254.5.0/24 via 192.168.100.235
10.254.4.0/24 via 192.168.100.235
10.254.3.0/24 via 192.168.100.235
10.254.2.0/24 via 192.168.100.235
10.254.1.0/24 via 192.168.100.235
10.254.7.0/24 via 192.168.100.235
10.254.50.0/24 via 192.168.100.235
#192.168.100.52/30 via 192.168.100.249
#192.168.100.24/30 via 192.168.100.249
#192.168.100.72 via 192.168.100.249




route-eth1 (END)



All times are GMT -5. The time now is 03:21 AM.