Monday, October 25, 2010

Persistent Route Ubuntu 10.10

Background:

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:
  1. System, Preferences, Network Connections
  2. Click "Auto (eth0)" and click "Edit"
    *Note: This may be "eth1", "wlan0", etc depending on your connection
  3. Click "IPv4 Settings"
  4. At the bottom right, click "Routes"
  5. Click "Add"
  6. 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.
  7. Click "Ok"
  8. Click "Apply"
  9. Click "Close"
  10. Optionally, reboot computer and ping a known good address to test if settings were persistent.



-Tres

No comments: