Thursday, September 24, 2009

Static Routes

To add a static route to say the 10.10.1.0/24 network from your machine through your gateway router who's IP is 192.168.1.1


route add -net 10.10.1.0 netmask 255.255.255.0 gw 192.168.1.1 dev eth0

will add the route to your kernel and it will be available immediately. However this will not survive a reboot.
To make this persistent after a reboot you need to input the route into a configuration file

on Ubuntu edit

/etc/network/interfaces

and Red hat / Centos / Fedora

edit /etc/sysconfig/network-scripts/route-eth0

if the route-eth0 file file does not exist (it probably won't) then create it
and add the following

10.10.1.0/24 via 192.168.1.1

save the file and then restart networking to read in the new route
/etc/init.d/networking restart

No comments: