You are not logged in.

#1 Today 09:07:52

thomastc
Member
Registered: 2016-04-22
Posts: 9

[SOLVED] What could cause my default route to be lost after resume?

My Arch machine is connected through a wired Ethernet network to a home router, which also serves as a DHCP server. This usually works fine, but since a month or two ago, I keep having trouble after resuming the machine from suspend. IPv6 seems fine, but IPv4 has lost its default route:

$ ping -6 google.com
PING google.com (2a00:1450:400e:811::200e) 56 data bytes
64 bytes from ams15s48-in-x0e.1e100.net (2a00:1450:400e:811::200e): icmp_seq=1 ttl=119 time=7.76 ms
^C
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 7.762/7.762/7.762/0.000 ms
$ ping -4 google.com
ping: connect: Network is unreachable
$ ip route 
192.168.1.0/24 dev enp6s0 proto kernel scope link src 192.168.1.55 metric 1024

I'm using systemd-networkd, and I double-checked that I have no other network managers installed. The configuration looks like this:

/etc/systemd/network/20-ether.network

[Match]
Name=enp6s0

[Network]
DHCP=yes

[DHCPv4]
UseDomains=yes

These are the relevant parts of the journal after resuming from suspend:

Jan 17 09:29:44 craig systemd-networkd[552]: enp6s0: Lost carrier
Jan 17 09:29:44 craig systemd-networkd[552]: enp6s0: DHCP lease lost
Jan 17 09:29:44 craig systemd-networkd[552]: enp6s0: DHCPv6 lease lost
Jan 17 09:29:44 craig systemd-networkd[552]: enp6s0: Gained carrier
Jan 17 09:29:44 craig systemd-networkd[552]: enp6s0: DHCPv4 address 192.168.1.55/24, gateway 192.168.1.1 acquired from 192.168.1.1
Jan 17 09:29:44 craig systemd-networkd[552]: enp6s0: Reconfiguring with /etc/systemd/network/20-ether.network.

In order to fix things, I need to manually renew the lease after each resume. That works:

$ sudo networkctl renew enp6s0 
$ ip route
default via 192.168.1.1 dev enp6s0 proto dhcp src 192.168.1.55 metric 1024 
192.168.1.0/24 dev enp6s0 proto kernel scope link src 192.168.1.55 metric 1024 
192.168.1.1 dev enp6s0 proto dhcp scope link src 192.168.1.55 metric 1024 

It's not clear to me whether the obtained default gateway is not applied at all, or immediately removed by some other process without leaving a trace in the journal.

Any idea what could be going on here?

Last edited by thomastc (Today 12:30:17)

Offline

#2 Today 09:55:01

harriboman
Member
Registered: Today
Posts: 1

Re: [SOLVED] What could cause my default route to be lost after resume?

Hi there,

It seems like you're facing an issue with the default IPv4 route not being properly re-applied after resuming from suspend. Since your system seems to have no issues with IPv6 and the DHCP lease for IPv4 is obtained correctly, the problem may lie in the network stack not fully refreshing after the resume.

Based on your journal logs and configuration, here are a few things to try:

Check if systemd is handling routes correctly:
Sometimes, even though the DHCP lease is obtained, systemd-networkd might not apply the default route correctly after resuming. To troubleshoot, you can enable more verbose logging for systemd-networkd to check if the route is indeed being requested but not applied. Add this to your 20-ether.network file for more detailed logs:

[Network]
DHCP=yes
LogLevel=debug

Check for conflicting network managers:
You mentioned you have confirmed no other network managers are installed, but it’s still worth checking that there’s no leftover process or conflicting configuration. Sometimes, services like NetworkManager or older network tools can interfere with systemd-networkd.

Check if there is a networkd issue with resume events:
Systemd has a known bug where the default gateway might not be reinstated correctly after suspend. You can try forcing the DHCP client to reconfigure and renew the lease automatically after a suspend event. One way to achieve this is by setting up a script that runs networkctl renew automatically after resume. You can create a systemd service or use systemd's sleep hooks to do this:

Here's an example:

sudo systemctl enable systemd-networkd-wait-online.service

Test using static routes:
If you're comfortable with a temporary solution, you can try manually adding a static route to see if that resolves the issue for now, as a workaround:

sudo ip route add default via 192.168.1.1

Investigate the journal logs after resume:
You might also want to look into other logs around the suspend/resume process to see if something else is interfering. Sometimes, kernel or hardware issues can cause network interfaces to not properly re-establish connections after resume.

Hope this helps! Let me know if any of these suggestions work or if you'd like further troubleshooting.

Best,
Cyril

Offline

#3 Today 11:27:14

thomastc
Member
Registered: 2016-04-22
Posts: 9

Re: [SOLVED] What could cause my default route to be lost after resume?

I don't mean to be rude, but are you using ChatGPT? If not, you might want to adjust your writing style to be less verbose and patronizing. In any case, I thank you for your reply and will take it at face value.

harriboman wrote:

Add this to your 20-ether.network file for more detailed logs:

[Network]
DHCP=yes
LogLevel=debug

There is no LogLevel= option mentioned in systemd.network(5). The correct way to enable debug logging is described here. Let me try that.

Systemd has a known bug where the default gateway might not be reinstated correctly after suspend.

Do you have a link to the bug report? I found this one but it's from 2023, so it would be strange if it started affecting me only recently. And in any case, it is supposedly fixed by this commit which is present in v257.2, which I have.

You can try forcing the DHCP client to reconfigure and renew the lease automatically after a suspend event. One way to achieve this is by setting up a script that runs networkctl renew automatically after resume. You can create a systemd service or use systemd's sleep hooks to do this:

Here's an example:

sudo systemctl enable systemd-networkd-wait-online.service

How will that command fix anything?

Offline

#4 Today 12:29:46

thomastc
Member
Registered: 2016-04-22
Posts: 9

Re: [SOLVED] What could cause my default route to be lost after resume?

I'm increasingly certain that this is a systemd-networkd bug. I've piled onto https://github.com/systemd/systemd/issues/28358 with my debug logs. Meanwhile, I'll work around the issue with a manual

sudo networkctl renew enp6s0

if half the internet appears broken. It's a nice detector for what sites do and don't support IPv6 these days smile

Offline

#5 Today 15:25:14

seth
Member
Registered: 2012-09-03
Posts: 60,466

Re: [SOLVED] What could cause my default route to be lost after resume?

Just use dhcpcd instead?

Offline

#6 Today 15:39:10

thomastc
Member
Registered: 2016-04-22
Posts: 9

Re: [SOLVED] What could cause my default route to be lost after resume?

Yeah, could do. When I installed this system, I figured, since systemd-networkd comes preinstalled, might as well use it.

Offline

Board footer

Powered by FluxBB