I'm having an issue with isc-dhcp-server. When I reboot I can see that it loads because it says "Starting LSB: DHCP server ...". However when trying to connect a PXE node to the server it does not work and I need to exectute "sudo service isc-dhcp-server restart". I have another PXE server that I've set up successfully that, for whatever reason, does not exhibit this issue. This is all on Raspbian Jessie. I also want to add that upon installation of isc-dhcp-server I get:

What does sudo systemctl -l isc-dhcp-server say? Does the ISC DHCP server stop because it cannot find any subnets (yet) to serve?
– TheDiveOJul 31 '17 at 5:39

It says unknown operation 'isc-dhcp-server' . Did you mean sudo systemctl status isc-dhcp-server? Because that doesn't give much information other than the service failed to start. Also, when installing the program i get Job for isc-dhcp-server.service failed. See 'systemctl status isc-dhcp-server.service' and 'journalctl -xn' for details. invoke-rc.d: initscript isc-dhcp-server, action "start" failed.
– chaoticslackerJul 31 '17 at 12:04

sorry, I forgot the operation, so it's sudo systemctl status -l isc-dhcp-server. This gives the status of the service, as well as the messages it logged.
– TheDiveOJul 31 '17 at 12:05

1 Answer
1

The reason why the ISC DHCPv4 server service fails is that at the time it is started the network interface configuration might not have been finished. As systemd cannot know when a service really has become ready (as opposed to have been started successfully), the usual start dependency service unit settings don't help either. Often, you'll find ugly workarounds using /etc/rc.local in combination with sleep 5 or something similar. Luckily, there's a better systemd way to do it (that is actually one of the features where I consider systemd to be better than previous init systems).

From my own experience with an Raspberry Pi 3B with an additional wlan1 USB WLAN dongle as an AP, I came up with an automatic restart of the DHCPv4 server in case it fails because it was too early.

Add the [Install] section which is missing, and add the follow line to it:

WantedBy=multi-user.target

sudo systemctl daemon-reload

sudo systemctl disable isc-dhcp-server

sudo systemctl enable isc-dhcp-server

This tells systemd to automatically restart the ISC DHCPv4 server if it fails, but to wait 5 seconds before attempting to restart it. If this works for you, you can try to reduce the sleep time; it defaults to 100ms, which is probably much small for this situation.

@chaoticslacker Please note that I've updated my answer after I noticed some issues on my own installation regarding the missing [Install] section and the correct reregistering of the service.
– TheDiveOJul 31 '17 at 13:04