I'd like to start the busybox udhcpd service using systemd.

I have a simple /etc/udhcpd.conf file:

start     #default:
end      #default:
interface       wlan0

Here's my /lib/systemd/system/udhcpd.service

Description=DHCP Service

ExecStart=/usr/sbin/udhcpd /etc/countx-udhcpd.conf


Here's my /usr/bin/ip-up.sh


ip addr add dev wlan0
ip link set wlan0 up

When I run the scripts manually, everything works properly.

But when I run the scripts with systemd, it fails.

systemctl start udhcpd

This is what works:

/usr/sbin/udhcpd /etc/countx-udhcpd.conf

Anyone get this working with systemd?

  • What exactly doesn't work? Why does it fail? What are the error messages? – Michael Hampton Sep 7 '20 at 15:03

I got this working with a few modifications.

First I had to use the -f flag when starting udhcpd from systemd. This is putting udhcpd into the foreground. Though this makes no sense, it works.

Second, I need to wait for the networking to come up before running this.

Below are my fixes that get things working in /lib/systemd/system/udhcpd.service

Description=DHCP Service
# wait for network to come up before we run

# -f means foreground--not sure why, but it works now
ExecStart=/usr/sbin/udhcpd -f /etc/countx-udhcpd.conf


All the other files above are needed. They work properly as is.

  • 1
    You need to set -f because by default systemd services are of Type=simple meaning that systemd expect the process NOT to fork, this is the preferred way of running a daemon in systemd. If your process has to fork, you need to set the type of the service to Type=forking – Bigon Jun 11 '18 at 23:09

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.