I'd like to start the busybox udhcpd service using systemd.
I have a simple /etc/udhcpd.conf file:
start 192.168.8.20 #default: 192.168.0.20
end 192.168.8.254 #default: 192.168.0.254
interface wlan0
Here's my /lib/systemd/system/udhcpd.service
[Unit]
Description=DHCP Service
[Service]
ExecStart=/usr/sbin/udhcpd /etc/countx-udhcpd.conf
ExecStartPre=/usr/bin/ip-up.sh
[Install]
WantedBy=multi-user.target
Here's my /usr/bin/ip-up.sh
#!/bin/sh
ip addr add 192.168.8.1 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/bin/udhcpd-ip-up.sh
/usr/sbin/udhcpd /etc/countx-udhcpd.conf
Anyone get this working with systemd?
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
All the other files above are needed. They work properly as is.