How to create Persistent Static Routes within Censornet

July 15, 2011 • Customer Services       
Synopsis

You want to create a static route on CensorNet that persists reboots

Article

The usual way to add persistent static routes would be to modify the /etc/network/interfaces file, however CensorNets' setup program can and will modify this file and may overwrite changes made to it.

Therefore we need to make a new init script, add the rules to it and then tell the system to run it at boot time.

1. Login as root to the system console.

2. Using a text editor (nano, vi, emacs etc...) create a file:

/etc/init.d/routing

In this file add the following two lines:

#!/bin/sh
/sbin/route add –net 10.0.0.0 netmask 255.255.0.0 gw 10.0.1.1 metric 1 dev br0

(replace network, subnet and gateway addresses with your own route information)


3. Save the file, exit the editor, then at the command prompt execute the following two commands:

chmod +x /etc/init.d/routing
update-rc.d routing defaults 99

That should make the script you created run at boot time.

NOTE:

If you need to create persistent static routes with non standard Gateway Addresses, then you can also utilize the "ip route" command. This only changes Step Number #2 above. Instead of adding the '/sbin/route' command, one can add the '/sbin/ip route' command. The CIDR Notation can be used instead of the traditional netmask notation ex:"255.255.255.0" = "/24" in CIDR as it outlines the number of bits that are needed to be masked. The "" is the device (interface) name as outlined in the 'ifconfig' command, an example would be "eth0" the standard default Ethernet device.

#!/bin/sh
/sbin/ip route add 172.16.200.0/24 src 128.127.254.254 dev eth0

(replace network, subnet and gateway addresses with your own route information)
 

Related articles


Last modified on Fri, July 15, 2011 « Back