DHCP churn with Google Fiber and systemd-networkd

Towards the end of 2023, I switched my home Internet connection to Google Fiber. I was accustomed to having a pretty stable IPv4 address with my prior service providers, but I quickly found that my IP address was changing a few times per week. This annoyed me, but I was able to work around it with some automation to update my DNS entries.

This weekend I set up DHCPv6 to acquire a /56 prefix delegation from the ISP, and quickly discovered that the changing IP address was more severe with IPv6. I was observing that my assigned prefixes came with lifetimes of only 600 seconds. That would make for some disruptive calls if I didn't figure out how to get longer living prefixes.

I use an old workstation running Gentoo Linux as my home router, and I use systemd-networkd to manage my network interfaces on the device. My friend Jonathan and I were wondering whether systemd might be requesting short leases. I used tcpdump to collect packets from a few DHCP interactions, and while analyzing those pcap files he noticed that my DHCP client (systemd-networkd) was sending a DHCP RELEASE message each time I restarted systemd-networkd. We observed that after this release, I would be assigned a different address by the ISP.

After a bit of /ing around in the systemd.network(5) man page, we noticed that there was an option to disable this behavior:

SendRelease=

       When true, the DHCPv4 client sends a DHCP release packet when it stops. Defaults to true.

This setting is available in both the [DHCPV4] and [DHCPV6] sections. With that setting, my WAN interface network config file looks similar to this:

[Match]
Name=enp3s0

[Network]
DHCP=yes
IPForward=yes

# Because we are a router and thus have IPForward enabled, systemd by default
# doesn't listen to route advertisements. However, we do want a route from the
# ISP, so turn it back on.
IPv6AcceptRA=yes

[DHCPv4]
# Without this, I get a different IP address every time my lease ends.
SendRelease=no

[DHCPv6]
# Ask for a /56 from the ISP.
PrefixDelegationHint=::/56
# By default, systemd doesn't do DHCPv6 unless it sees routes being
# advertised. However, the ISP doesn't seem to advertise a route unless we
# do DHCPv6, so there's a chicken and egg problem. This tells systemd to
# start DHCPv6 before seeing a route advertised.
WithoutRA=solicit
# Without this, I get a different prefix every time my lease ends.
# Furthermore, the ISP seems to hand out 10 minute leases without this.
SendRelease=no

I now seem to get 24 hour DHCPv6 leases, and so far I haven't noticed my DHCPv4 lease changing when rebooting like it had before I made this change. It's possible that this post is premature, but so far things look promising, or at least improved over my prior experience.

links

social