I was having another one of those "and this is why people don't use Linux" moments just prior to my writing this. You would think that Linux itself would have some easy-to-figure out mechanism for creating persistent static routes. Well, it does... but no one seems to know how to do it. Some people even suggested the extreme step of actually modifying network startup scripts by adding calls to the route command!
It turns out that creating such things with Redhat Enterprise Linux (RHEL) is pretty easy. You start by creating a file as root in your /etc/sysconfig/network-scripts directory called route-ethX where X is the number of your network interface. For example, to create a persistant static route for eth1 you would create a file called route-eth1.
An example of the contents of this file are as follows:
| GATEWAY0=192.168.71.1 |
| NETMASK0=255.255.255.0 |
| ADDRESS0=192.168.2.0 |
After saving the file you will need to restart networking for the change to take effect. For most systems, this is done by invoking the command /etc/init.d/network restart.
The above example creates a single static route that route requests to the 192.168.2.0/24 network to the gateway at 192.168.71.1. This file can contain any number of static routes, provided the numbers which suffix the keys in the file all match up. For the above example, a second static route would have the keys GATEWAY1, NETMASK1, and ADDRESS1.
If the phrase "persistent static route" sounds foreign to you, then you really should not be attempting this.
If you have a console hooked up to the server on which you are working, try not to plug a USB and PS/2 keyboard in simultaneously.
Unless you are really feeling ballsy or have a death wish, don't attempt this from a remote login.
| Back to Stupid Networking Tricks | philatfacebook@gmail.com |