Score:0

Ubuntu 20.04. How to prioritize wireless (or any other network) card?

cn flag

There are a lot of similar questions, but all of them ask about prioritizing traffic (with metric as a solution). I want to use only one network card at the same time. For example, if the external card (wlan1) is plugged try to use it, else use the internal one (wlan0). I tried to use connection.autoconnect-priority in /etc/NetworkManager/system-connections/*.nmconnection files, but it doesn't prioritize connections with different interfaces. Here is my connection section of /etc/NetworkManager/system-connections/my_home_from_usb.nmconnection:

id=my_home_usb
uuid=c481eb20-a299-4703-9537-e2e4849e4983
type=wifi
autoconnect-priority=10
interface-name=wlan1
permissions=
timestamp=1581203793

and /etc/NetworkManager/system-connections/my_home.nmconnection:

[connection]
id=my_home_internal
uuid=9d4cdada-1550-497e-b3b7-a82619bbd072
type=wifi
autoconnect-priority=5
interface-name=wlan0
permissions=
timestamp=1581203793

and nmcli -f NAME,UUID,AUTOCONNECT,AUTOCONNECT-PRIORITY,ACTIVE,DEVICE,STATE,ACTIVE-PATH c output

NAME              UUID                                  AUTOCONNECT  AUTOCONNECT-PRIORITY  ACTIVE  DEVICE   STATE      ACTIVE-PATH                                        
lan               153501bf-9e36-43e8-b63e-67d2d6d18076  yes          3                     yes     eth0     activated  /org/freedesktop/NetworkManager/ActiveConnection/2 
my_home_internal  9d4cdada-1550-497e-b3b7-a82619bbd072  yes          5                     yes     wlan0    activated  /org/freedesktop/NetworkManager/ActiveConnection/4 
my_home_usb       c481eb20-a299-4703-9537-e2e4849e4983  yes          10                    yes     wlan1    activated  /org/freedesktop/NetworkManager/ActiveConnection/5

So, how can I use only one network card simultaneously?

uz flag
Jos
Have you tried setting a different `metric` value?
alokym avatar
cn flag
@Jos Nope, cause using `metric` isn't my case. I want to use only one interface, not all with prioritized traffic.
waltinator avatar
it flag
You could adapt my `net-o-matic` script: `https://github.com/waltinator/net-o-matic` It watches the connection, and when the connection drops, does a user-specified thing
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.