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.