8

Im trying to set up my pi as an access point with the instructions from Adafruit. However, for some reason, sudo apt-get install isc-dhcp-server always fails. I have looked at this link, but there is a subnet defined in my dhcpd.conf (from Adafruit):

/etc/dhcp/dhcpd.conf

              .
              .
              .
#    range 10.0.29.10 10.0.29.230;
#  }
#}

subnet 192.168.42.0 netmask 255.255.255.0 {
range 192.168.42.10 192.168.42.50;
option broadcast-address 192.168.42.255;
option routers 192.168.42.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}

When I do sudo apt-get install isc-dhcp-server, i get:

Generating /etc/default/isc-dhcp-server...
[FAIL] Starting ISC DHCP server: dhcpd[....] check syslog for diagnostics. ... failed!
 failed!

and

pi@raspberrypi ~ $ sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
pi@raspberrypi ~ $ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
pi@raspberrypi ~ $ sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED \
> -j ACCEPT
pi@raspberrypi ~ $ sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
pi@raspberrypi ~ $ sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
pi@raspberrypi ~ $ sudo service hostapd start
[ ok ] Starting advanced IEEE 802.11 management: hostapd.
pi@raspberrypi ~ $ sudo service isc-dhcp-server start
[FAIL] Starting ISC DHCP server: dhcpd[....] check syslog for diagnostics. ... failed!
 failed!

/var/log/syslog:

Jul 26 03:05:25 raspberrypi dhcpd: Wrote 0 leases to leases file.
Jul 26 03:05:25 raspberrypi dhcpd:
Jul 26 03:05:25 raspberrypi dhcpd: No subnet declaration for wlan0 (192.168.42.\
1).
Jul 26 03:05:25 raspberrypi dhcpd: ** Ignoring requests on wlan0.  If this is n\
ot what
Jul 26 03:05:25 raspberrypi dhcpd:    you want, please write a subnet declarati\
on
Jul 26 03:05:25 raspberrypi dhcpd:    in your dhcpd.conf file for the network s\
egment
Jul 26 03:05:25 raspberrypi dhcpd:    to which interface wlan0 is attached. **
Jul 26 03:05:25 raspberrypi dhcpd:
Jul 26 03:05:25 raspberrypi dhcpd:
Jul 26 03:05:25 raspberrypi dhcpd: Not configured to listen on any interfaces!

How do i fix this?

11

if you are sure that subnet set in dhpcd config belongs to already configured interface (I'm guessing, wlan0). Compare IP subnets in /etc/network/interfaces and /etc/dhcp/dhcpd.conf .

Also, on Debian (and thus Raspbian), check /etc/default/isc-dhcp-server, as it should contain name of your interface, like this:

# Defaults for dhcp initscript
# sourced by /etc/init.d/dhcp
# installed at /etc/default/isc-dhcp-server by the maintainer scripts

#
# This is a POSIX shell fragment
#

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
#   Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES="wlan0"

both things were set in the tutorial, so I'm assuming you omit at least one of them.

  • I checked everything, and everything seemed correct, but something worked – calccrypto Jul 26 '13 at 16:25
  • 2
    this is wrong! You need to have INTERFACES="" in defaults as it shipped! All you need is to define ALL the /etc/network/interfaces subnets by a subnet {} clause. For the subnets you do not need to be served by DHCPD you need an empty subnet clause. Putting interface name in INTERFACES, as suggested here, breaks DHCPD. Verified on Raspbian Jessie. – Alexey Vesnin Jan 29 '16 at 19:12
5

You need to have INTERFACES="" in defaults as it shipped! Even more - automatic update can overwrite it btw. This issue is DHCPD-dependent, not an OS-dependent. All you need is to define ALL the /etc/network/interfaces subnets by a subnet {} clause. For the subnets you do not need to be served by DHCPD you need an empty subnet clause like this :

# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.

subnet 192.168.0.0 netmask 255.255.255.0 {
}

the comment above is from the original config sample shipped. In my case on this network it was no need to serve any IP requests, but without this empty subnet clause DHCPD refused to start like this :

Jan 29 19:08:44 pi dhcpd: Internet Systems Consortium DHCP Server 4.3.1
Jan 29 19:08:44 pi dhcpd: Copyright 2004-2014 Internet Systems Consortium.
Jan 29 19:08:44 pi dhcpd: All rights reserved.
Jan 29 19:08:44 pi dhcpd: For info, please visit https://www.isc.org/software/dhcp/
Jan 29 19:08:44 pi dhcpd: Internet Systems Consortium DHCP Server 4.3.1
Jan 29 19:08:44 pi dhcpd: Copyright 2004-2014 Internet Systems Consortium.
Jan 29 19:08:44 pi dhcpd: All rights reserved.
Jan 29 19:08:44 pi dhcpd: For info, please visit https://www.isc.org/software/dhcp/
 Jan 29 19:08:44 pi dhcpd: Wrote 2 leases to leases file.
 Jan 29 19:08:44 pi dhcpd:
 Jan 29 19:08:44 pi dhcpd: No subnet declaration for wlan0 (no IPv4 addresses).
 Jan 29 19:08:44 pi dhcpd: ** Ignoring requests on wlan0.  If this is not what
 Jan 29 19:08:44 pi dhcpd:    you want, please write a subnet declaration
 Jan 29 19:08:44 pi dhcpd:    in your dhcpd.conf file for the network segment
 Jan 29 19:08:44 pi dhcpd:    to which interface wlan0 is attached. **
 Jan 29 19:08:44 pi dhcpd:
 Jan 29 19:08:44 pi dhcpd:
 Jan 29 19:08:44 pi dhcpd: Not configured to listen on any interfaces!
 Jan 29 19:08:44 pi dhcpd:
 Jan 29 19:08:44 pi dhcpd: If you think you have received this message due to a bug rather
 Jan 29 19:08:44 pi dhcpd: than a configuration issue please read the section on submitting
 Jan 29 19:08:44 pi dhcpd: bugs on either our web page at www.isc.org or in the README file
 Jan 29 19:08:44 pi dhcpd: before submitting a bug.  These pages explain the proper
 Jan 29 19:08:44 pi dhcpd: process and the information we find helpful for debugging..
 Jan 29 19:08:44 pi dhcpd:
 Jan 29 19:08:44 pi dhcpd: exiting.
 Jan 29 19:08:46 pi isc-dhcp-server[3332]: Starting ISC DHCP server: dhcpdcheck syslog for diagnostics. ... failed!
 Jan 29 19:08:46 pi isc-dhcp-server[3332]: failed!
 Jan 29 19:08:46 pi systemd[1]: isc-dhcp-server.service: control process exited, code=exited status=1
 Jan 29 19:08:46 pi systemd[1]: Unit isc-dhcp-server.service entered failed state.

The hell-weird thing about all this error message is that /etc/dhcp/dhcpd.conf actually had a full-featured subnet clause for wlan0's subnet. Adding an empty clause for eth0 subnet fixed all the things up.

Putting interface name in INTERFACES, as suggested here, breaks DHCPD. Verified on Raspbian Jessie, and on other OS'es.

  • 2
    I am not sure that it is the best idea to start one's answer with This is wrong, people might think that it is wrong... – Ghanima Feb 1 '16 at 16:10
  • @Ghanima thanks! I've copied my comment to a wrong answer =) missed it =) Fixed! – Alexey Vesnin Feb 1 '16 at 16:29
1

ISC DHCP server is OK.

change /etc/default/isc-dhcp-server INTERFACES="wlan0" to eth0

service isc-dhcp-server start OK?

change /etc/default/isc-dhcp-server INTERFACES="eth0" to wlan0

...... interface wlan0 does IP address

ifconfig , wlan0 IP?

.. nano /etc/network/interfaces

iface wlan0 inet static address 192.168.42.2 netmask 255.255.255.0 ..

ifdown wlan0 ifup wlan0 ifconfig wlan0

wlan0 Link encap:Ethernet HWaddr 00:00:xx:xx:xx:xx inet addr:192.168.42.2 Bcast:192.168.42.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1153 errors:0 dropped:0 overruns:0 frame:0 TX packets:1178 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:219204 (214.0 KiB) TX bytes:245615 (239.8 KiB)

service isc-dhcp-server start

  • 3
    your answer reads a bit cryptic, please, add more explanation next time? – lenik Aug 18 '13 at 14:20
1

Had exactly the same problem and found the answer in this short tutorial: http://sirlagz.net/2013/02/10/how-to-use-the-raspberry-pi-as-a-wireless-access-pointrouter-part-3b/

Hope it works for you too!

Barney

  • Hi Barney, welcome to Raspberry Pi SE :) usually answers are better if they summarise the pages that they link off to. This means that if the link moves the answer is still useful. – Jivings Dec 30 '13 at 9:04
-1

Common mistake when I config/edit headless servers is to use Windows IDE to edit the files. If you do so, use Notepad++, then don't forget to check the Format is => UNIX format && Encode in UTF-8 without BOM

Solves most of the weird behavior like this one.

protected by Jivings Apr 30 '14 at 14:43

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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