NetworkManager network priority broken?

Hi all,
I have my network connections managed by NetworkManager.
At the office, I usually connect my laptop to the docking station, which gives it a wired network connection. The laptop also automatically connects to the office wifi network.
When I am at the office I need to use to wired connection; this has never been a problem: the wired connection has a higher priority (-100 vs 0 for wifi) in NetworkManager, so even if the laptop automatically connects to the wifi network, all connections go through the wired one.

Well, that was until some time ago. Now I am forced to disable the wifi connection because as soon as it connects it “takes over”.
Moreover, when I try to change the priority of the wired connection, I see that the “Apply” button is not automatically enabled. In fact, even if I change it and click on “OK”, when I reopen the configuration dialog I see the priority has not changed.
On the other hand, the wifi connection priority behaves normally.

Has anybody else seen this?

TIA
Cris

I’m not using TW so can’t comment directly on the behaviour you’re desribing. With both connections active what is shown by the following?

ip route

It is possible to force the routing metric if desired by modifying the connection profiles eg for a connection named “Office”

nmcli connection modify "Office" ipv4.route-metric 10

or via uuid eg

nmcli connection modify uuid 42275eb4-0b52-4b9b-be74-018817b5e51d ipv4.route-metric 10

Confirm the changes (connection profiles are saved in /etc/NetworkManager/system-connections/) with

nmcli connection show  42275eb4-0b52-4b9b-be74-018817b5e51d|grep metric

Once the connections are restarted, the metric will be reflected in the routing table

ip route

I forgot to mention that the ipv6.route-metric can be similarly modified for a given connection…

nmcli connection modify "Office" ipv6.route-metric 10

Thank you Deano!
Your reply is very appreciated, although I’d still like to know if something has changed in the way NetworkManager handles priority or if it’s a problem/misconfiguration on my part.

Cris

Me too, which is why I wanted to see the routing table (in particular the metric values) when you have both connections active. :wink:

For reference (using openSUSE Leap 42.3) I get

ip route
default via 192.168.1.1 dev eth0  proto static  metric 100 
default via 192.168.9.1 dev wlan0  proto static  metric 600 
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.49  metric 100 
192.168.9.0/24 dev wlan0  proto kernel  scope link  src 192.168.9.8  metric 600

How does that compare?

The ‘autoconnect-priority’ settings only set the order preference for a given connection type AFAIU eg ordering a preferred wireless AP. If you have wired and wireless connections set to auto-connect, both can do so concurrently. It’s the ‘route-metric’ that determines which gateway is preferred (and by default it will be via the wired interface).

More info

man nm-settings

Hi Deano,
this is what I get on my laptop (first is with wired only, second is with wifi enabled and connected):

cristiano@xmper8q3 ~]**$** ip route
default via 172.24.252.1 dev enp0s25 proto static metric 20100
172.24.252.0/22 dev enp0s25 proto kernel scope link src 172.24.253.121 metric 100
cristiano@xmper8q3 ~]**$** ip route
default via 10.232.0.1 dev wlp3s0 proto static metric 600
default via 172.24.252.1 dev enp0s25 proto static metric 20100
10.232.0.0/23 dev wlp3s0 proto kernel scope link src 10.232.0.153 metric 600
172.24.252.0/22 dev enp0s25 proto kernel scope link src 172.24.253.121 metric 100

Cris

Thank you Deano!! So I was wrong assuming that the priority affected the preferred connection.
There is something wrong in my metric, as you can see in my previous post, but I don’t know where that comes from.
I’ll see if I can locate the problem.

Cris

Hi Deano!

Yesterday I did some test, but even after following your instructions and restarting the connection, I still had that strange 20100 metric on the Default route.
The “nmcli connection show” command correctly showed 100, which was the value I set it to.
Have you ever seen something like this? I don’t get where that 20100 comes from.

TIA
Cris

No, I’m not sure why NM is behaving like that. However, following a quick search I did find this thread (different topic though) where similar values are evident…

https://bbs.archlinux.org/viewtopic.php?id=226689

Can you show the connection profile (defined in /etc/NetworkManager/system-connections/)?

Yes, sure (I amended the MAC address):

cristiano@xmper8q3 ~]**$** sudo cat /etc/NetworkManager/system-connections/Wired\ connection\ 1
[connection]
id=Wired connection 1
uuid=df4972e8-98d0-3428-8d4e-9db5c09ffa00
type=ethernet
autoconnect-priority=-100
permissions=
timestamp=1501753749

[ethernet]
auto-negotiate=true
mac-address=AMENDED
mac-address-blacklist=

[ipv4]
dns-search=
may-fail=false
method=auto
route-metric=100

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto

TIA
Cris

That looks as expected. I’m trying to understand whether this is server-defined or not…I wouldn’t have thought so though. (FWIW, Windows DHCP servers and clients support the default router metric base option, but I’m not aware of any such thing being supported by dhclient/dhcpcd.) What does the lease file look like?

cat /var/lib/dhcp/dhclient.leases

I’m still wondering why the specify ‘route-metric’ value is not get applied to the connection’s default route as expected. Maybe it is a bug. It does work for me using openSUSE Leap 42.3, NM 1.0.12 though.

That file is empty :frowning:

cristiano@xmper8q3 ~]**$** cat /var/lib/dhcp/dhclient.leases
cristiano@xmper8q3 ~]**$** ll /var/lib/dhcp/dhclient.leases
-rw-r--r-- 1 root root 0 ott 26  2014 /var/lib/dhcp/dhclient.leases

Cris

Looking at other threads on Google (like the one you posted a few messages ago) I am starting to suspect that the problem is not that the wired default route has a 20100 metric, but that the wifi default route should have a 20600 metric instead of 600.

Still don’t understand where those metrics come from… :
Something has clearly changed since a few weeks but don’t know what.

Cris

Hmmm…is dhclient even in use? That’s a very old timestamp! Maybe NM is using a different DHCP client. Apparently it has its own internal client that can be used. That can be checked with

cat /etc/NetworkManager/NetworkManager.conf

*If not specified then dhclient is used by default AFAIU.

Yes, it’s definitely something in the internal NM logic involved here. It would be useful for other TW users with wired and wifi connections to chime in with the metric values for comparison.

Here is my NetworkManager.conf:

cristiano@xmper8q3 ~]**$** cat /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifcfg-suse,keyfile

[connectivity]
uri=http://conncheck.opensuse.org

However, changing the wifi metric to 20600 fixed my problem.

Here are my routes now:

cristiano@xmper8q3 ~]**$** ip route
default via 172.24.252.1 dev enp0s25 proto static metric 20100
default via 10.232.0.1 dev wlp3s0 proto static metric 20600
10.232.0.0/23 dev wlp3s0 proto kernel scope link src 10.232.0.153 metric 20600
172.24.252.0/22 dev enp0s25 proto kernel scope link src 172.24.253.121 metric 100

Cris

The problem is being caused by the rp_filter that tries to work out the best route based on connectivity. If you work for exact does not have outside world access, or that access is a extra step, this can cause exactly the problems you see.

The solution tell the kernal to turn off (0) or loosen (1) the rp_filter for your wired connection.
To see the seetinsg for your networks use…

grep . /proc/sys/net/ipv4/conf/*/rp_filter

to ‘loosen’ say the enp0x25 device as your route shows…

echo 1 > /proc/sys/net/ipv4/conf/enp0x25/rp_filter

now when you connect it should not add the 20000 value to that device due to connectivity test failure (it uses the libcurl library for that test, though I don’t know the details)