How to "prioritise" multiple network connections

Solution 1:

If I understand your question correctly, you have a local-only WiFi connection (or at least you want to use it for local connections only) and an internet-connected mobile broadband connection. Is that correct?

Background

Here's some background. Both your WiFi and mobile broadband connection are claiming the "default route" as in, the route to all the addresses I am not otherwise aware of, i.e. the Internet. As there's just one routing table and your applications aren't (and shouldn't be) aware of those two connections, the kernel just follows the routing table.

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.11.254  0.0.0.0         UG    0      0        0 eth0
192.168.11.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0

In the example above, the local network addresses are available directly on the interface and all other ones are routed via 192.168.11.254. This is the gateway and this address is usually announced by the DHCP server. It's telling the computer requesting for an IP address not just an available host address to use, but also the gateway, DNS servers, NTP time server, etc.

Now, what you would want, is to disable your DHCP client on your PC to ignore the announcement "this is the default gateway: 192.168.11.254", yet still listen to the rest to be able to keep the ability to talk in the local network. Below is how to do that.

Network Manager settings

Try disabling the default route to be assigned to your WiFi adapter when connected. Assuming you're running the default NetworkManager, you should be able to change the behaviour of how routes are assigned.

Below is how it looks like in KDE, but it should be similar in other Desktop Environments. It's important to find the two settings in the "Routes" section of the "IPv4 Address" tab in the settings window of the specific network.

  • Ignore automatically obtained routes (tick it)
  • Use only for resources on this connection (tick it)

Both on the bottom of this window:

enter image description here

You might also want to ignore the information about the DNS servers for the WiFi connection if you don't rely on it for local addresses. This can be done in the "Basic settings" section of the "IPv4 Address" tab by selecting the "Automatic (DHCP) addresses only".