Restart dhcpd when interface is reset

I have an Ubuntu 16.04 system acting as a wifi access point and router, including as a DHCP server (isc-dhcp-server). There is something slightly flaky with the USB wifi card, and occasionally it resets, appearing to the host machine as if it has disconnected and reconnected. When this happens, DHCP stops working until I manually do /etc/init.d/isc-dhcp-server restart.

The only log message from dhcpd is receive_packet failed on wlan4: Network is down. strace appears to show that the daemon is continuing to select, but doesn't see any new packets that come in, as if it is listening on a socket connected to the "old" instance of the interface.

The logs show many other services being restarted when the interface comes back up (ntpd, sshd, named, etc) but dhcpd is not restarted. What's the difference between them? Is there a way to arrange for dhcpd to be automatically restarted when the interface bounces?

1 Answer

I added a line to the wlan4 stanza of /etc/network/interfaces saying

up /etc/init.d/isc-dhcp-server restart || true

Not sure if this is the "right" way to accomplish this, but it seems to work. I tested it by unplugging and reconnecting the wifi card, and dhcpd was restarted.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like