dnsmasq requires a restart of the networking system on BeagleBone Black (Debian 8.5)

1

I am currently trying to configure a BeagleBone Black running debian 8.5 as a WiFi Access Point. The programs used are hostapd and dnsmasq. I've made huge progress, in principle the access point is working as intended (I can connect to it and access the Lighty-hosted website), but with a little gotcha. After a reboot I cannot connect, since dnsmasq complains about wlan0 not having an address.

Excerpt from /var/log/syslog:

Jun 24 12:01:03 arm dnsmasq[487]: warning: interface wlan0 does not currently exist
Jun 24 12:01:03 arm dnsmasq-dhcp[487]: DHCP, IP range 192.168.3.20 -- 192.168.3.200, lease time infinite
Jun 24 12:01:53 arm dnsmasq-dhcp[487]: DHCP packet received on wlan0 which has no address

When I restart the networking system with /etc/init.d/networking restart everything is working fine, as described above. Restarting dnsmasq or calling ifup wlan0 does not help with the issue. Based on the log I'd guess that there is some sort of timing issue (i.e. USB WiFi stick gets recognized after dnsmasq has started, or the like), but I do not really know how to overcome. I have added allow-hotplug wlan0 to /etc/network/interfaces but it did not change anything.

Except from /etc/network/interfaces:

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
    address 192.168.3.1

My /etc/dnsmasq.conf is quite basic:

# Disable DNS
port=0
interface=wlan0
no-dhcp-interface=eth0
dhcp-range=interface:wlan0,192.168.3.20,192.168.3.200,infinite

Edit:

Running ifconfig wlan0 192.168.3.1 works, too.

Paul K

Posted 2016-06-24T12:31:46.063

Reputation: 132

Even though it technically does not solve the issue, I have been able to solve my issue (Getting DHCP working, not Getting dnsmasq working) by using udhcpwhich more or less works out of the box. – Paul K – 2016-06-27T08:57:25.693

Looks as if my issues have been related to connman. I'll check and if it holds I will write an answer. – Paul K – 2016-06-27T11:15:12.953

Answers

0

You can create an if-up script that will check if dnsmasq must restart.

/etc/network/if-up.d/dnsmasq:

#!/bin/sh
[ "$IFACE" != "lo" ] || exit 0

restartDnsMasq() {
    if [ -d /run/systemd/system ]; then
        systemctl reload --no-block dnsmasq >/dev/null 2>&1 || true
    else
        invoke-rc.d dnsmasq restart >/dev/null 2>&1 || true
    fi
}

# Find out if dnsmasq is configured to run on a single interface
interface=$(cat /etc/dnsmasq.conf | grep interface | awk -F '=' '{print $2}')
if  [ "x${interface}" = "x" ]; then
    # all interfaces
    logger DnsMasq not configured for any particular interface, restarting because $IFACE came up.
    restartDnsMasq
else
    if [ "${interface}" = "$IFACE" ]; then
        # The interface that dnsmasq is running on is being brought up
        logger DnsMasq configured for interface ${interface}, restarting because $IFACE came up.
        restartDnsMasq
    else
        logger DnsMasq configured for interface ${interface}, not restarting because $IFACE came up.
    fi 
fi

Solar.gy

Posted 2016-06-24T12:31:46.063

Reputation: 116