Skip to content

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.

IPCop DHCP Fixed/Static Lease Script

About a year ago I found the need to create a lot of fixed leases for use with IPCop. I sat down and using some loop and awk magic I was able to develop a fairly decent script to get the job done. I will post the file with a day or two but here are the details…

To execute:

sh ./leasecreate.txt CVSInputfilename

CVS File Format

IP,MAC Address,Computer Name,Location,User,Hostname,Default Router

This will create two files, dhcpd.conf and fixleases. These files then need to be copied to /var/ipcop/dhcp/ and the DHCP server should be restarted.

To Download:

[download#1#nohits]

or

[download#2#nohits]