1

I'm trying to configure a Linux host running systemd-networkd on a switch trunk port. The host has a single interface, enp4s0. There are only a couple VLAN ports in the switch, others are untagged. I would like to add a DHCP server on the trunk port.

My configuration file with the new DHCP server setting looks like the following.

[Match]
Name=enp4s0

[Network]
DHCPServer=true
VLAN=enp4s0.10
VLAN=enp4s0.20
VLAN=enp4s0.30
DNS=192.168.1.1
Gateway=192.168.1.1
Address=192.168.1.2/24

[DHCPServer]
PoolOffset=100
PoolSize=150
DefaultLeaseTimeSec=300s

This combination fails with the following error:

systemd-networkd[]: enp4s0: Could not start DHCPv4 server instance: Device or resource busy
systemd-networkd[]: enp4s0: Failed

Running route -n shows all the routes except the default gateway. Following the suggestion in: systemd-networkd and direct routes, I added the following:

[Address]
Address=192.168.1.2/24
Peer=192.168.1.1/32

This allowed the DHCP Server to start, the interface to come up, and the route to the gateway to appear. Everything appeared to be working. However, the DHCP server never responded to queries. Using tcpdump I could see the queries come in but there was no response from the server.

I then added a link level route to 255.255.255.255 but this didn't work (I thought it did when I was testing it manually but I can't reproduce it). The section I added was:

[Route]
Destination=255.255.255.255/32
Scope=link

Going back to the original configuration but commenting out two of the VLANs also works. With the following configuration the network comes up, the VLAN ... actually, all 3 VLAN interfaces come up (?!) ... and the DHCPServer responds to queries.

[Match]
Name=enp4s0

[Network]
DHCPServer=true
VLAN=enp4s0.10
#VLAN=enp4s0.20
#VLAN=enp4s0.30
DNS=192.168.1.1
Gateway=192.168.1.1
Address=192.168.1.2/24

[DHCPServer]
PoolOffset=100
PoolSize=150
DefaultLeaseTimeSec=300s

I need to test the configuration above with the VLANs that come up but are commented out, but I am not currently able to do so. Finally, reverting to the configuration without DHCP but running an external DHCP server works fine. That is, running udhcpd standalone with this works:

[Match]
Name=enp4s0

[Network]
VLAN=enp4s0.10
VLAN=enp4s0.20
VLAN=enp4s0.30
DNS=192.168.1.1
Gateway=192.168.1.1
Address=192.168.1.2/24

I fear there is something fundamental that I'm not understanding, preventing me from saying this is a bug in systemd-networkd. Does anyone have this scenario working? I'm using systemd-237.

2
  • systemctl daemon-reload after every change in the config? how exactly did you reload the network configuration did you check the systemd logs via journalctl? with the external isc-dhcp-server we had the issue that the DHCP server was started before the interface was up (trivial to fix via f.e. targets) did you verify there is actually a dhcp server started by systemd? Aug 17, 2018 at 14:42
  • Thanks Dennis. I think the problem is user error. I've been pulled away to other things but I think what was happening is that when I comment out the VLAN statement, networkd doesn't take the interface down on a restart because it no longer sees it as an interface to manage. I believe this is resolved and will update/correct my question when I can re-verify it. But I didn't see a way to tell whether systemd-networkd was running its DHCP server aside from the log message indicating an error.
    – rand'Chris
    Aug 21, 2018 at 14:35

1 Answer 1

0

This appears to be working as-expected. When commenting out the VLAN identifiers and restarting the network, the already-configured interfaces (now commented out) aren't removed. Working headless it's not possible to take the interface down, edit, and then bring it back up, so I just remove the stale VLANs manually as necessary.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .