Introduction

On any linux machine, if you add a route through the command line, after reboot or network restart the route will be deleted. There are couple of ways to keep the route after a reboot/network restart.

One of the ways is to create and edit /etc/sysconfig/static-routes :

 

Static route configuration for HOST

If you type in the following command:

# route add -host 192.168.12.1 gw 192.168.1.1

The equivilant static-route line will be:

any host 192.168.12.1 gw 192.168.1.1

 

Static route configuration for a network

If you type in the following command:

# route add -net 192.168.12.0/24 gw 192.168.1.1

The equivilant static-route line will be:

any net 192.168.12.0/24 gw 192.168.1.1

 

For FreeBSD you should do the following:

If you type in the following command:
# route add -net 192.168.1.1/24 192.168.1.1

The equivilant static-route line will be by editing /etc/rc.conf for example:

static_routes="lan"

route_lan="-net 192.168.12.0/24 192.168.1.1"

 

Remember to restart the network service after you've edited the file - to verify the route works.

# service network restart

or

# /etc/init.d/network restart

 

Enjoy!

Viewed 19409 times.
Share |
How to migrate from o... (Daniel, 16:52 06/04/2013)
How to redirect SNMP ... (Daniel, 18:32 24/08/2012)
How to add httpd.conf... (Daniel, 19:20 24/03/2012)
How to avoid entering... (Daniel, 03:11 27/12/2011)
How to configure SOFT... (Daniel, 23:24 26/12/2011)
Subversion - Tortoise... (21:02 17/01/2010, 119857 views)
How to install Nagios... (01:08 23/12/2011, 46373 views)
How to avoid entering... (03:11 27/12/2011, 29300 views)
Byte Order Mark (BOM)... (17:36 22/02/2010, 29045 views)
Raid Types (17:54 09/02/2010, 21323 views)