Make wifi preferable over wired connection in Ubuntu 14.04?

How do I make Ubuntu choose wifi connection over wired connection when both are connected to internet? I edited the Ethernet connection to route using the preference "Use this connection only for resources on this network", which other people have reported having success with as a means of getting WiFi preferred, but it doesn't work for me. The issue persists. Ethernet is still being preferred for internet, and WiFi gets ignored.

another thing, is it possible to use wired connection as fail over connection to wireless?


Solution 1:

You can change metric. route add default dev eth0 metric 20 When you change metric you default route to wless0 will have less metric and traffic will go via wless0. When wless0 is down you default route to wless0 will be deleted from routing table and traffic will go via eth0. After when you wless0 is again up, default metric will be less then 20 on eth0 and traffic will again go to wless0.

Also you can edit /etc/network/interfaces and set metric permanent for interface.

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
network xxx.xxx.xxx.xxx
broadcast xxx.xxx.xxx.xxx
metric XXX

@gunjan parashar Elaborate:

Network service route packages on several parameters. First of that is that packet is for local net or not. For this decision network service use netwotk mask from nic setup. If packet is not fol local net, pc will sendit to default gateway.

If you have 2 interfaces in the same subnet / local network and the same gateway for both interfaces, pc must use some "parameters" for routing decision. Parameter for routing is metric. Practically less metric is better route and pc will send packet to gateway based on that. In case that you have same metric and same gw and both interfaces on local net, traffic to gw will not working because pc can not make routing decision.

When you change metric, practically you say pc "Link over eth0 is worse. Use wlan0" But when is wlan0 down, any connection is better then no connection and pc will be use "worse" connection. When you wlan is again up automatically will be with better because default metric parameter is less then metric parameter configured manually on eth0.