Ubuntu Network Priority

12

6

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?

Wilgert

Posted 2010-11-30T11:46:18.490

Reputation: 391

1

I have asked for a similar question - http://superuser.com/questions/331720/how-do-i-set-the-priority-of-network-connections-in-ubuntu

– Praveen Sripati – 2011-09-09T18:57:11.377

Answers

17

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.

Wilgert

Posted 2010-11-30T11:46:18.490

Reputation: 391

1Tip: It works! but I didn't find Routes button while editing connections in ubuntu 18.04 default Network Manger but I was able to find it when editing via GUI after executing nm-connection-editor command. – Omid – 2019-07-22T11:54:06.420

1

WHen you setup the static IP for eth0, don't set a gateway for the connection. This is a common configuration when there are multiple ports such as eth1, eth2 etc. If no gateway is specified, then no gateway routing gets defined.

Example configuration using /etc/network/interfaces.

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.169.10.1
        netmask 255.255.255.0

BillThor

Posted 2010-11-30T11:46:18.490

Reputation: 9 384

0

From what I understand, you want eth0 to be used only for local connections (printers, etc.) and your usb0 connection for the "outside world".

I figure the best way to get this done is to modify your routing table so that your local traffic gets routed through eth0 and outside traffic gets routed to usb0.

An easy way to get this done is using IPTables, it will allow you to route specific traffic through the specified interface. Check out the website below for a complete tutorial.

http://www.tldp.org/HOWTO/Adv-Routing-HOWTO/index.html

Good luck!

akseli

Posted 2010-11-30T11:46:18.490

Reputation: 3 796