Ubuntu Network Priority – How to Set

linuxnetworkingUbuntu

Situation
I'm temporarily without a fixed Internet connection on my desktop computer. I'm using my HTC Magic as a 3G dongle through usb0.
I also want to be able to print on my Samsung printer connected through Ethernet on eth0. So i set up eth0 to have static IP and installed dhcp3 server.

The problem
As soon as I enable eth0 I cannot browse the Internet anymore because the static IP-address gets added to my routing table.

Found solution
Manually delete eth0 as the default gateway after enabling the interface.

Possible better solution
Give permanent priority to my usb0 connection.

Question
Is it possible to give priority to a certain network connection? How?

Best Answer

As I was using the Networking utility in Ubuntu to configure my Network Connections the settings in /etc/network/interfaces are apparently ignored.

When I right-click on the network icon then Edit connections -> eth0 -> IPv4 Settings I cannot Apply the settings without a Gateway set. Yet on the dialog opening from the Routes button I can tick the "Use this connection only for resources on its network" box. This will prevent the route from getting added and I can still access the internet through my other connection.

Related Question