Persistent static routes
I wanted to direct traffic to the network 192.168.1 via 192.168.0.200 rather than via the default gateway and this is how I did it. It is kind of basic, but it varies between platforms.
In Windows it is very easy, simply run:
route -p add 192.168.1.0 mask 255.255.255.0 192.168.0.200 metric 10
The route is added immediately and will survive restarts.
For Red Hat Linux, CentOS and their relatives, create a file in
route-ethX where X is the interface number. In my case I created the file
/etc/sysconfig/network-scripts/route-eth0. The file should contain:
GATEWAY-N=xxx.xxx.xxx.xxx NETMASK-N=yyy.yyy.yyy.yyy ADDRESS-N=zzz.zzz.zzz.zzz
where N is the route number. In my example:
GATEWAY0=192.168.0.200 NETMASK0=255.255.255.0 ADDRESS0=192.168.1.0
Finally for Ubuntu and other Debian-related Linux versions, modify the file
/etc/network/interfaces and add an up command. In my case I added:
up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.200 eth0
Including the other lines for eth0 this resulted in:
iface eth0 inet static address 192.168.0.20 netmask 255.255.255.0 gateway 192.168.0.1 up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.200 eth0 auto eth0