Monday, October 25, 2010

Persistent Route Ubuntu 10.10

This may seem obvious to some, but Ubuntu has built-in support for adding static network routes.

This is useful when a connection to a secondary network requires a different gateway than the one normally used to access the internet.

In windows, this is done through the "route -p" command, but the same command doesn't work for Ubuntu Linux.

Originally, I found a temporary solution. I would not recommend this method as a permanent solution.

sudo route add -net 10.8.0.0/16 gw 10.7.1.1 dev eth0

The problem with this method is settings are lost after restarting the network.

Other tutorials mention changes to /etc/network/interfaces. I would not recommend this method for Ubuntu Desktop as the syntax seems to have changed between tutorials.

The best solution I have found is through the built-in Network Connection dialogs for Ubuntu/Gnome desktop.

Steps:

System, Preferences, Network Connections

Click "Auto (eth0)" and click "Edit"*Note: This may be "eth1", "wlan0", etc depending on your connection

Click "IPv4 Settings"

At the bottom right, click "Routes"

Click "Add"

Type your route settings into the table. In this case, we're sending all "10.8" traffic over the "10.7.1.1" gateway.*Note: For "192.168" networks, the subnet mask will likely be "255.255.255.0", so make sure to adjust the subnet mask accordingly.

Click "Ok"

Click "Apply"

Click "Close"

Optionally, reboot computer and ping a known good address to test if settings were persistent.