You are not logged in.

#1 2020-03-30 13:48:32

early_adopter
Member
Registered: 2011-03-30
Posts: 19

systemd-networkd RouteMetric with wired and wireless adapters

I recently switched to systemd-networkd on my laptop and I'm very happy with it. I find it really clean and it just works.

Except for one thing.

I followed the instructions in Wired and wireless adapters on the same machine exactly but I'm finding that when I have both wifi and ethernet connected, it's slower than when I have ethernet only connected.

Could it be that the RouteMetric setting is not taken into account?

Offline

#2 2020-03-30 14:43:47

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: systemd-networkd RouteMetric with wired and wireless adapters

early_adopter wrote:

Could it be that the RouteMetric setting is not taken into account?

The applied RouteMetric value should be shown in the output of

ip r

Here's mine:

empty@E485:~ $ ip r
default via 192.168.0.1 dev enp2s0 proto static metric 10 
default via 192.168.0.1 dev wlp3s0 proto static metric 20 
192.168.0.0/24 dev wlp3s0 proto kernel scope link src 192.168.0.50 
192.168.0.0/24 dev enp2s0 proto kernel scope link src 192.168.0.51 
empty@E485:~ $

^ That's using static addressing so it shows the metric instead. If it wasn't taken into account at all then you wouldn't observe a switch from wireless to ethernet when connecting the cable.

How are you measuring your connection speed? Is the difference significant? Does the journal say anything about it?

Offline

#3 2020-03-30 19:42:44

Stellarator
Member
Registered: 2019-01-12
Posts: 32

Re: systemd-networkd RouteMetric with wired and wireless adapters

early_adopter wrote:

Could it be that the RouteMetric setting is not taken into account?

Yes, it's possible. The guide looks a bit outdated.
DHCPv4 Section Options should give you a hint about new naming convention wink.

Offline

#4 2020-03-31 10:31:31

Omar007
Member
Registered: 2015-04-09
Posts: 368

Re: systemd-networkd RouteMetric with wired and wireless adapters

Ignore Stellarator here. I have no clue on what information he has based that the quide would be 'outdated'...
It's still RouteMetric, that hasn't changed at all.

What Head_on_a_stick is showing you would be the same for dynamic addressing.
Here is the example output for a system with 2 connections available outward. For both the addresses and routes are provided over DHCP(v4).
The second interface (eth1) has RouteMetric=2048, the first (eth0) is using the default and does not explicitly specify it.

$ ip r
default via 192.168.88.1 dev eth0 proto dhcp src 192.168.88.155 metric 1024 
default via 192.168.77.1 dev eth1 proto dhcp src 192.168.77.104 metric 2048 
192.168.77.0/24 dev eth1 proto kernel scope link src 192.168.77.104 
192.168.77.1 dev eth1 proto dhcp scope link src 192.168.77.104 metric 2048 
192.168.88.0/24 dev eth0 proto kernel scope link src 192.168.88.155 
192.168.88.1 dev eth0 proto dhcp scope link src 192.168.88.155 metric 1024

Last edited by Omar007 (2020-03-31 10:32:24)

Offline

#5 2020-03-31 16:55:20

Stellarator
Member
Registered: 2019-01-12
Posts: 32

Re: systemd-networkd RouteMetric with wired and wireless adapters

I do not pretend to be always correct in my life, but I try not to make mistakes in simple things. My "information" is based on official man pages to which I gave the link above.

ArchWiki contains the following fragment (pointed by early_adopter):

[Match]
Name=wlp2s0

[Network]
DHCP=ipv4

[DHCP]
RouteMetric=20

The "problem" is that [DHCP] section is now named [DHCPv4], what I pointed out...

Offline

#6 2020-03-31 18:43:23

Omar007
Member
Registered: 2015-04-09
Posts: 368

Re: systemd-networkd RouteMetric with wired and wireless adapters

That isn't the problem either, as of 245.3-2 the [DHCP] section is still perfectly fine for use and will be respected.

EDIT: Apologies if I'm coming across a bit harsh, that was not my intent but I'm relatively short on time so posting this in-between a few spare moments and thus keeping it brief.
If we're talking about deprecated, then yes. So it would it be nicer to convert. But as long as it is a valid configuration, it isn't outdated (yet).
I.o.w. I don't say no to an update of the wiki if you desire to do so, but it's still perfectly valid atm  wink

Last edited by Omar007 (2020-03-31 18:54:23)

Offline

#7 2020-03-31 20:44:46

Stellarator
Member
Registered: 2019-01-12
Posts: 32

Re: systemd-networkd RouteMetric with wired and wireless adapters

NP. Now, I can definitely be wrong here, but in my opinion I ran into some options that did not want to work without specifying the correct section. And from memory it was somehow connected with [DHCPv4] vs [DHCP], which surprised me a little, because deprecated section still works for the vast majority of options but, apparently, not for all, since I decided to change the name of the section. Or, maybe, it was somehow related to systemd-networkd <> systemd-resolved integration and option values exchange roll. I do not remember the context, unfortunately.

So I recommended checking the configuration file again.

Offline

#8 2020-04-03 13:33:56

early_adopter
Member
Registered: 2011-03-30
Posts: 19

Re: systemd-networkd RouteMetric with wired and wireless adapters

Thanks to those who replied.

Over the last few days I've been puzzling about this on and off and reading more about link-local addressing and how systemd-networkd works but I still can't get to the bottom of it.

I have one ethernet connection and one wireless. When both are connected I want the ethernet connection to be favoured for routing. As I mentioned in my earlier posting, I set it up as suggested with RouteMetric settings of 10 for ethernet and 20 for wireless.

Now this is the routing table I get:

    $ ip r
    default via 192.168.44.1 dev wlp3s0 proto dhcp src 192.168.0.109 metric 20 
    default via 192.168.44.1 dev enp0s25 proto dhcp src 192.168.0.110 metric 202 
    192.168.0.0/16 dev wlp3s0 proto kernel scope link src 192.168.0.109 
    192.168.0.0/16 dev enp0s25 proto dhcp scope link src 192.168.0.110 metric 202 
    192.168.44.1 dev enp0s25 proto dhcp scope link src 192.168.0.111 metric 10 
    192.168.44.1 dev wlp3s0 proto dhcp scope link src 192.168.0.109 metric 20 
    $ 

What I don't understand is where the metric of 202 comes from. Nor do I understand which of these lines is relevant. If I look at the default lines, it appears that wireless is favoured whereas if I look at the lines for 192.168.44.1 it appear ethernet is favoured. And where does the 202 come from?

Would anyone like to decipher this for me?

Last edited by early_adopter (2020-04-03 13:36:24)

Offline

#9 2020-04-12 09:31:04

Omar007
Member
Registered: 2015-04-09
Posts: 368

Re: systemd-networkd RouteMetric with wired and wireless adapters

My best guess would be that something else is setting a route. You mentioned that you recently switched. Could it be that you've left around some software and/or configuration of the previous setup?

EDIT: Going over the defaults of the different networking tools, it looks like DHCPCD might be the most likely culprit in your case. Quoting from the docs:

dhcpcd will supply a default metic of 200 + if_nametoindex(3).  An extra 100 will be added for wireless interfaces.

So systemd-netword and DHCPCD might be fighting each other currently. That said, if they are that would not only result in the wireless interface going first if it has the lower metric from systemd-networkd but should also make your whole connection unstable as they will keep fighting each other for control over the interface.

Last edited by Omar007 (2020-04-12 09:39:00)

Offline

#10 2020-04-12 09:54:08

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: systemd-networkd RouteMetric with wired and wireless adapters

Omar007 wrote:

systemd-netword and DHCPCD might be fighting each other currently

We can confirm or refute that if the OP provides the output of

systemctl list-unit-files --state=enabled

Offline

Board footer

Powered by FluxBB