Static Routes in Linux
Something that I have found very useful in small networks that have more than one subnet is the occasional static route. Routes can be added temporarily or permanently. The syntax is the same it is just a matter of where to enter the command.
The command is:
route add -net 10.0.0.0 netmask 255.255.255.0 gw 10.0.0.1
This is the form of the command that I use but you may add an interface parameter on the end to make it specific to an interface. by adding ‘dev eth0’ to the end. More details on other options can be found here.
To add it permanently for IPCop add this command to the end of ‘/etc/rc.d/rc.netaddress.up’.
For Ubuntu/Debian based linux add the following to ‘/etc/network/interface’
up route add [-net|-host] host/net netmask subnet-mask gw host/IP dev Interface
substituting as we did earlier.
For CentOS/RedHat/Fedora add the following to ‘/etc/rc.local’
route add [-net|-host] host/net netmask subnet-mask gw host/IP dev Interface
Again substituting as earlier. There are better ways to handle this on CentOS by placing it in a interface specific route file but this will work for now.