3

I'm trying to setup AP mode on BCM4313 wireless card.

My very basic hostapd config looks like this:

interface=wlan0
driver=nl80211
ssid=test
hw_mode=b
channel=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=1234567890
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

The network is set up successfully an I'm able to connect to my network. However, connection process stops at obtaining IP address.

So, my dhcpd.conf file looks pretty much the same as default with following insertions:

# option definitions common to all supported networks...
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;

#default-lease-time 600;
#max-lease-time 7200;
...
option broadcast-address 10.10.0.255;

subnet 10.10.0.0 netmask 255.255.255.0 {
        interface wlan0;
        range 10.10.0.2 10.10.0.16;
        option domain-name-servers 8.8.8.8, 8.8.4.4;
        option routers 10.10.0.1;
}

My wlan0 interface is configured (I guess) properly:

wlan0: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        inet 10.10.0.1  netmask 255.255.255.0  broadcast 10.10.0.255
        ether 55:28:cc:23:14:a6  txqueuelen 1000  (Ethernet)

When /etc/default/isc-dhcp-server has following lines:

DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
INTERFACESv4="wlan0"

After all, journalctl -xe gives me this output:

Jul 10 10:11:25 srv dhcpd[3296]: Wrote 0 leases to leases file.
Jul 10 10:11:25 srv dhcpd[3296]: 
Jul 10 10:11:25 srv dhcpd[3296]: No subnet declaration for wlan0 (no IPv4 addresses).
Jul 10 10:11:25 srv dhcpd[3296]: ** Ignoring requests on wlan0.  If this is not what
Jul 10 10:11:25 srv dhcpd[3296]:    you want, please write a subnet declaration
Jul 10 10:11:25 srv dhcpd[3296]:    in your dhcpd.conf file for the network segment
Jul 10 10:11:25 srv dhcpd[3296]:    to which interface wlan0 is attached. **
Jul 10 10:11:25 srv dhcpd[3296]: 
Jul 10 10:11:25 srv dhcpd[3296]: 
Jul 10 10:11:25 srv dhcpd[3296]: Not configured to listen on any interfaces!
Jul 10 10:11:25 srv dhcpd[3296]: 
Jul 10 10:11:25 srv dhcpd[3296]: If you think you have received this message due to a bug rather
Jul 10 10:11:25 srv dhcpd[3296]: than a configuration issue please read the section on submitting
Jul 10 10:11:25 srv dhcpd[3296]: bugs on either our web page at www.isc.org or in the README file
Jul 10 10:11:25 srv dhcpd[3296]: before submitting a bug.  These pages explain the proper
Jul 10 10:11:25 srv dhcpd[3296]: process and the information we find helpful for debugging..
Jul 10 10:11:25 srv dhcpd[3296]: 
Jul 10 10:11:25 srv dhcpd[3296]: exiting.
Jul 10 10:11:27 srv isc-dhcp-server[3283]: Starting ISC DHCPv4 server: dhcpdcheck syslog for diagnostics. ... failed!
Jul 10 10:11:27 srv isc-dhcp-server[3283]:  failed!
Jul 10 10:11:27 srv systemd[1]: isc-dhcp-server.service: Control process exited, code=exited status=1
Jul 10 10:11:27 srv systemd[1]: Failed to start LSB: DHCP server.

This is my /etc/network/interfaces:

auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet static
address 10.10.0.1
netmask 255.255.255.0

The sudo apt-get install -f command has already been tried without effect.

I've seen plenty questions similar to mine(1,2,3) but they are all not suitable for my case. How do I get dhcp server working?

3 Answers 3

3

isc-dhcp-server and hostapd work for me (on debian sid) but I have my wlan interface defined in dhcpd.conf inside a shared-network. I also have the option broadcast-address inside the subnet {...} definition.

Try something like this:

shared-network net_wlan0 {
    subnet 10.10.0.0 netmask 255.255.255.0 {
        authoritative;
        range 10.10.0.2 10.10.0.16;
        option broadcast-address 10.10.0.255;
        option domain-name-servers 8.8.8.8, 8.8.4.4;
        option routers 10.10.0.1;
    }
}

I also have the following in my /etc/default/isc-dhcp-server:

INTERFACESv4="br0 br1 wlan0"

This tells dhcpd what interfaces to listen to, and results in it running with these args (note the interfaces at the end of the command-line).

# ps h -o cmd -C dhcpd
/usr/sbin/dhcpd -4 -q -cf /etc/dhcp/dhcpd.conf br0 br1 wlan0

NOTE: previous versions of the isc-dhcp-server package used an INTERFACES variable rather than INTERFACESv4. This change happened in February this year. According to etckeeper, my most recent commit of /etc/default/isc-dhcp-server was on Feb 10 2016


I'd also recommend running a local caching DNS resolver (e.g. unbound or dnsmasq or one of several others). Point it at google's DNS servers as forwarder, but a local cache is IMO essential. A proxy server such as squid is also worthwhile. As is a local NTP server so all machines on your network can be synchronised to the exact same time.


BTW, I'm using an ath9k usb wifi NIC, with dhcpd also serving two other networks, eth0 and eth1 (actually, bridged for my VMs as br0 and br1), but that shouldn't make any difference.

I had major problems trying to get an RTL 8192 based USB NIC working, ended up giving up on it and buying the AR9271:

0cf3:9271 Atheros Communications, Inc. AR9271 802.11n

Both USB wifi devices were cheap, around $10-15 each (same brand, same manufacturer (TP-Link), different chipset), so it wasn't worth spending too much time trying to get the 8192 working (IMO the 8192-based NIC is probably just junk, it wouldn't even work reliably as a client. it would start working OK and then drop the connection and hang...needed to be removed and reinserted before it would work again).

2
  • Thank you for your comment. Unfortunately, your solution did not help me - still getting that error. Also I'm not sure that DNS and proxy can help me configure address leasing for my devices. I wish I have separate wifi module, but there is no possibility to get one now. Jul 10, 2016 at 9:49
  • well, no, of course DNS and NTP and proxy servers won't help with getting dhcpd working. I never suggested they would. They're general networking recommendations that will improve performance on ANY network...e.g. your current wired LAN (if any) or the wireless network when you get it working.
    – cas
    Jul 10, 2016 at 9:59
2

Finally, I've found solution. Maybe some of these steps are redudant, but I do not care because everything finally works.

  1. Wi-fi could be hardware locked. Check it's not;
  2. Wi-fi could be down. sudo ifconfig wlan0 up (or wlanX in some other case)
  3. Add binding between mac and host. Finally, it looks like this:

subnet 10.10.0.0 netmask 255.255.255.0 {
        interface wlan0;
        range 10.10.0.2 10.10.0.16;
        option domain-name-servers 8.8.8.8, 8.8.4.4;
        option routers 10.10.0.1;
  host wlan0 {
        hardware ethernet 40:2c:f4:36:d4:16;
        fixed-address 10.10.0.1;
  }
}
1
  • and one more forgotten thing to reach out internet: sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE. Of course, could be ethX. Jul 11, 2016 at 6:18
1

Accordingly to your error message "please write a subnet declaration in your dhcpd.conf file for the network segment to which interface wlan0 is attached."

This is a known feature/limitation of isc-dhcpd; there is a need to mandatorily define the net block/subnet of the main interface where you are listening for DHCP requests.

As your interface has as address 10.10.0.1 and netmask 255.255.255.0, add as your first DHCP subnet:

subnet 10.10.0.0 netmask 255.255.255.0 {
  option routers 10.10.0.1
  option subnet-mask 255.255.255.0;
}

Restart the DHCP daemon, it ought to work now.

3
  • I've tried to append this snippet to the end of /etc/dhcp/dhcpd.conf, but still getting same error. Jul 10, 2016 at 12:20
  • Try do append it as your first DHCP subnet Jul 10, 2016 at 12:26
  • 1
    There is only one subnet (which I added myself) in that file, but I've tried to relocate it at the beginning of the file - nothing changed. Jul 10, 2016 at 12:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .