You are not logged in.

#1 2024-12-12 20:40:41

zf
Member
Registered: 2019-03-04
Posts: 10

systemd-networkd not auto-switching to ethernet when connected

On my laptop, I have systemd-networkd manage the network connections and use iwd for wireless. My attempt at configuring systemd-networkd to prefer ethernet when both ethernet and wifi are available is not working:

`journalctl -xeu systemd-networkd`:

    systemd-networkd[674]: eth0: Interface name change detected, renamed to enp57s0u1.
    systemd-networkd[674]: enp57s0u1: Configuring with /etc/systemd/network/20-wired.network.
    systemd-networkd[674]: enp57s0u1: Link UP
    systemd-networkd[674]: enp57s0u1: Gained carrier
    systemd-networkd[674]: enp57s0u1: Gained IPv6LL
    systemd-networkd[674]: wlan0: Lost carrier
    systemd-networkd[674]: wlan0: Connected WiFi access point: home-net

`networkctl` also shows the ethernet connection as "Configuring" for an indefinite amount of time.

Here are the [systemd-networkd configs](https://0x0.st/XFsQ.txt). I tried to explicitly set the metric to be lower for ethernet to prioritize it over wireless. For wired and for home network, I intend to use the same static IP address.

If I restart systemd-networkd, it does prefer ethernet over wireless with `networkctl` showing ethernet as configured and the service showing:

    systemd-networkd[28789]: lo: Link UP
    systemd-networkd[28789]: lo: Gained carrier
    systemd-networkd[28789]: wlan0: Link UP
    systemd-networkd[28789]: wlan0: Gained carrier
    systemd-networkd[28789]: enp57s0u1: Link UP
    systemd-networkd[28789]: enp57s0u1: Gained carrier
    systemd-networkd[28789]: wlan0: Gained IPv6LL
    systemd-networkd[28789]: enp57s0u1: Gained IPv6LL
    systemd-networkd[28789]: wlan0: Connected WiFi access point: home-net
    systemd-networkd[28789]: Enumeration completed
    systemd[1]: Started Network Configuration.
    systemd-networkd[28789]: wlan0: Configuring with /etc/systemd/network/21-wireless-home-static.network.
    systemd-networkd[28789]: enp57s0u1: Configuring with /etc/systemd/network/20-wired.network.


Any comments are much appreciated. I'm finding I need to manually restart systemd-networkd and it also happens to be the fastest way to restore network connection on the interface,

Offline

#2 2024-12-12 21:10:47

pvtvega
Member
Registered: 2024-11-25
Posts: 91

Re: systemd-networkd not auto-switching to ethernet when connected

zf wrote:

For wired and for home network, I intend to use the same static IP address.

Why? This will cause conflicts with routing on your network. If you want to use static IPs, assign each adapter a different one. What is the full output of

journalctl -u systemd-networkd

Offline

#3 2024-12-12 22:03:45

zf
Member
Registered: 2019-03-04
Posts: 10

Re: systemd-networkd not auto-switching to ethernet when connected

pvtvega wrote:
zf wrote:

For wired and for home network, I intend to use the same static IP address.

Why? This will cause conflicts with routing on your network. If you want to use static IPs, assign each adapter a different one. What is the full output of

journalctl -u systemd-networkd

No reason, I will try different static IP addresses. Output of `journalctl -u systsemd-networkd` when on wifi plugging to ethernet (I plugged in at (15:51):

    Dec 12 15:23:40 zf systemd-networkd[8184]: wlan0: Connected WiFi access point: home-net
    Dec 12 15:23:41 zf systemd-networkd[8184]: wlan0: Gained carrier
    Dec 12 15:25:02 zf systemd-networkd[8184]: wlan0: Lost carrier
    Dec 12 15:25:02 zf systemd-networkd[8184]: wlan0: Connected WiFi access point: home-net
    Dec 12 15:25:02 zf systemd-networkd[8184]: wlan0: Gained carrier
    Dec 12 15:51:17 zf systemd-networkd[8184]: enp57s0u1: Link DOWN
    Dec 12 15:51:17 zf systemd-networkd[8184]: enp57s0u1: Lost carrier
    Dec 12 15:51:32 zf systemd-networkd[8184]: eth0: Interface name change detected, renamed to enp57s0u1.
    Dec 12 15:51:32 zf systemd-networkd[8184]: enp57s0u1: Configuring with /etc/systemd/network/20-wired.network.
    Dec 12 15:51:32 zf systemd-networkd[8184]: enp57s0u1: Link UP
    Dec 12 15:51:34 zf systemd-networkd[8184]: enp57s0u1: Gained carrier
    Dec 12 15:51:36 zf systemd-networkd[8184]: enp57s0u1: Gained IPv6LL

it just remains on wifi connection. When I restart the service, then it uses ethernet immediately:

    Dec 12 15:58:59 zf systemd[1]: Stopping Network Configuration...
    Dec 12 15:58:59 zf systemd[1]: systemd-networkd.service: Deactivated successfully.
    Dec 12 15:58:59 zf systemd[1]: Stopped Network Configuration.
    Dec 12 15:58:59 zf systemd[1]: Starting Network Configuration...
    Dec 12 15:59:00 zf systemd-networkd[14765]: lo: Link UP
    Dec 12 15:59:00 zf systemd-networkd[14765]: lo: Gained carrier
    Dec 12 15:59:00 zf systemd-networkd[14765]: wlan0: Link UP
    Dec 12 15:59:00 zf systemd-networkd[14765]: wlan0: Gained carrier
    Dec 12 15:59:00 zf systemd-networkd[14765]: enp57s0u1: Link UP
    Dec 12 15:59:00 zf systemd-networkd[14765]: enp57s0u1: Gained carrier
    Dec 12 15:59:00 zf systemd-networkd[14765]: wlan0: Gained IPv6LL
    Dec 12 15:59:00 zf systemd-networkd[14765]: enp57s0u1: Gained IPv6LL
    Dec 12 15:59:00 zf systemd-networkd[14765]: wlan0: Connected WiFi access point: home-net
    Dec 12 15:59:00 zf systemd-networkd[14765]: Enumeration completed
    Dec 12 15:59:00 zf systemd[1]: Started Network Configuration.
    Dec 12 15:59:00 zf systemd-networkd[14765]: wlan0: Configuring with /etc/systemd/network/21-wireless-home-static.network.
    Dec 12 15:59:00 zf systemd-networkd[14765]: enp57s0u1: Configuring with /etc/systemd/network/20-wired.network.

Offline

Board footer

Powered by FluxBB