Related to this question
How do you get systemd-networkd to honor the [DHCPv4] setting FallbackLeaseLifetimeSec=forever? (Or more probably, what am I doing wrong that is preventing this?)
When it receives a reply with no DHCP lease, it logs:
enp0s1: DHCPv4 client: received lease lacks address, server address or lease lifetime, ignoring
Background
We have a prospective customer with a requirement that our device can operate in a BOOTP (i.e. non-DHCP) environment. Specifically, we must not require DHCP Option 51 (Lease Time) to be present, and must treat replies as permanent IP assignments.
We use systemd-networkd for everything else, so ideally we'd like to use its built-in DHCP client for this as well. The primary issue is that systemd-networkd is rejecting BOOTP replies that do not contain DHCP Option 51 (IP Address Lease Time). It appears that the entire purpose of FallbackLeaseLifetimeSec=forever is to bypass this constraint. However, whether we set it or not, we get the same log message (above), and the systemd does not configure the interface.
Details/what I've tried
networkctl --versionreportssystemd 252. The doc say this option was added in 246.- We are running Debian 12 (Bookworm) as a testbed client, w/ a 6.1.0 kernel.
- We are running the Debian
bootpdpackage on a separate device, w/ the same Debian & Linux- Probably irrelevant, but the server is using
/etc/network/interfacesandifup/ifdownfor network config.
- Probably irrelevant, but the server is using
- I've captured the replies via
tcpdumpand verified the following:- They contain
yiaddr, akaYour (client) IP Address - They contain
siaddr, akaServer Ip Address - They do also contain option 54 (DHCP Server Identifier)
- They contain
- I've captured replies from a normal DHCP server, and compared as well. The only substantive differences I can see are:
- The expected
IP Address Lease Timeis present - The options are in a different order (53,54,51,1,3,6,42,255 vs 1,3,53,54,6,12,255)
- The expected
- Our network config file is in
/etc/systemd/network/20-enp0s1.network - We have no other network config files, except
/etc/systemd/networkd.confwhich is untouched, and effectively blank (it has only comments and some empty sections) - I have verified that our config file, and the
FallbackLeaseLifetimeSecoption in particular, are being parsed as follows:- I set the options's value to
garbage, and restarted systemd-networkd. journalctlreportsInvalid LeaseLifetime= value, ignoring: garbage.- When I switch it back to
forever,journalctldoesn't mention it- I found the error message in the source code, and it's clear that it is quiet if it finds an acceptable value.
- I set the options's value to
- Here is
20-enp0s1.network:
[Match]
Name=enp0s1
[Network]
DHCP=ipv4
[DHCPv4]
FallbackLeaseLifetimeSec=forever
ClientIdentifier=mac
# Padding b/c `bootpd` rejects packets that it thinks are too short
SendOption=254:string:"UUUUUUUUUUUUUUUUUUUUUUUUUUU"
client_handle_offer(), specificallyif (lease->address == 0 || lease->server_address == 0 || lease->lifetime == 0), so one of those is obviously 0.addressshould be coming fromyiaddrwhich is in my packet;leaseshould be set to non-zero on line 1478;server_addressshould be set to my server's ip duringdhcp_option_parse()on line 1468 from opt 54 which I've verified in the packet.