mikey32094
Posts: 38
Joined: Sat Jul 25, 2015 10:07 am

Only Connect to One of Multiple Interfaces at a Time, Using Priority? (DHCPCD)

Tue Jun 11, 2019 2:01 am

Hello all,

RPi 3 on the latest Stretch. I have a spare Wifi USB dongle I'd like to use, for the most part. I have it configured for a static IP so I can reach via home-local domain name.

But sometimes I need to steal that adapter for a different machine. When that happens, I would like the network to fallback to the built-in Wifi, but use the same static IP address, automatically. Furthermore, when the USB dongle is plugged in, it should always take priority over the built-in Wifi.

Is there a way to do this with DHCPCD, or something else? I've been using wicd-curses but it's just ... buggy as hell sometimes and I worry about using abandonware.

I've added the following to my dhcpcd.conf file, but the default Wifi always seems to take priority:

Code: Select all

ssid [my ssid]
interface wlan0
metric=1
static ip_address=192.168.1.202/24
static ip6_address=[sorry too lazy]
static routers=192.168.1.1
static domain_name_servers=192.168.1.101 192.168.1.102

ssid [my ssid]
interface wlan1
metric=0
static ip_address=192.168.1.202/24
static ip6_address=[sorry too lazy]
static routers=192.168.1.1
static domain_name_servers=192.168.1.101 192.168.1.102
Please note that I've tried this with and without specifying my SSID. Also tried reversing the metric order in case I read incorrectly (the metric property specifies priority, yes?).

Any help appreciated! I'm happy to switch to NetworkManager or anything that works, if needed. I might switch to wicd for awhile if I can get it going there instead.

epoch1970
Posts: 4206
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Only Connect to One of Multiple Interfaces at a Time, Using Priority? (DHCPCD)

Tue Jun 11, 2019 10:33 am

it's not "metric=" but "metric"
No idea if that is the solution though. Metric applies to route selection. Disabling redundant/conflicting interfaces on the fly is a systemd or dhcpcd heuristic, AFAIK. No idea if it makes use of metric.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Networking and servers”