3

I did setup hostapd and udhcpd for my wlan0. After startup, the hostapd is running and I see the ssid with another device, but I don't receive a dhcp address. Well, I can't, because the udhcpd is not running, and systemctl status udhcpd.service claims:

● udhcpd.service - LSB: Start busybox udhcpd at boot time
   Loaded: loaded (/etc/init.d/udhcpd)
   Active: active (exited) since Thu 2017-03-16 14:24:06 CET; 7min ago
  Process: 611 ExecStart=/etc/init.d/udhcpd start (code=exited, status=0/SUCCESS)

Mar 16 14:24:06 testo-mx6 systemd[1]: Starting LSB: Start busybox udhcpd at boot time...
Mar 16 14:24:06 testo-mx6 systemd[1]: Started LSB: Start busybox udhcpd at boot time.
Mar 16 14:24:06 testo-mx6 udhcpd[611]: Starting very small Busybox based DHCP server: udhcpd.

Active, but exited? And why did it exit? I tried a bunch of restarts and interface resets and finally found this script to be reliable:

#!/bin/sh
systemctl stop udhcpd.service
systemctl stop hostapd.service
ifdown wlan0
ifup wlan0
sleep 1
systemctl start udhcpd.service

Now everything is running as expected. But using this script is a nasty workaround. I want the services to start up as supposed.

My /etc/udhcpd.conf looks like

start           192.168.42.20   #default: 192.168.0.20
end             192.168.42.254  #default: 192.168.0.254
interface       wlan0           #default: eth0
max_leases      2               #default: 254
siaddr          192.168.42.42   #default: 0.0.0.0
sname           foobar          #default: (none)
option  domain  local
option  lease   864000          # 10 days of seconds

And /etc/network/interfaces

auto wlan0
iface wlan0 inet static
    hostapd /etc/hostapd/hostapd.conf
    address 192.168.42.42
    netmask 255.255.255.0

And in case it is relevant also the /etc/hostapd/hostapd.conf:

interface=wlan0
driver=nl80211
channel=1
hw_mode=g
wmm_enabled=0
max_num_sta=1
ssid=foobar

I tried to put a sleep in the /etc/init.d/udhcpd startup (seemed to have helped in another posting I found), but to no avail.

1

I had this problem on a system with an Atheros wifi card that didn't come up quickly enough for either systemd or udhcpd. It is extremely frustrating to diagnose, since there are several layers of abstraction involved. Here's what I did to fix it:

Add export _SYSTEMCTL_SKIP_REDIRECT=1 near the top of /etc/init.d/udhcpd, after the LSB header. This disables one layer of systemd abstraction and allows the sysv startup script to function more normally.

Add sleep 30 to the beginning of the start) section of /etc/init.d/udhcpd. This gives some time for the wifi interface to come up before starting the DHCP server. Otherwise, it will just quietly exit.

Once it's working, you can adjust the sleep time downward.

0

I had the same issue with atheros wifi card associate to a bridge, the udhcpd server run on br0. udhcpd seem to start before br0 came up. My solution was to let in /etc/default/udhcpd DHCPD_ENABLED to "no" and add the following network configuration to /etc/network/interfaces for br0 :

    post-up /usr/sbin/udhcpd -S /etc/udhcpd.conf

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.