Page 1 of 1

Raspberry pi DHCP server

Posted: Mon Aug 26, 2013 11:50 pm
by dirksoccer
I have been following this guide
http://learn.adafruit.com/setting-up-a- ... l-software
to set up my Pi as a wireless router/access point (it is also acting as a NAS/UPnP server). Hostapd starts fine, and I've double checked that I've followed the steps correctly (caught a few typos), but I'm still getting errors when I try to launch the isc-dhcp-server service. Here is a copy of the syslog error...

Code: Select all

Wrote 0 leases to leases file.
Aug 26 14:34:25 raspberrypi dhcpd:
Aug 26 14:34:25 raspberrypi dhcpd: No subnet declaration for eth0 (192.168.1.10).
Aug 26 14:34:25 raspberrypi dhcpd: ** Ignoring requests on eth0.  If this is not what
Aug 26 14:34:25 raspberrypi dhcpd:    you want, please write a subnet declaration
Aug 26 14:34:25 raspberrypi dhcpd:    in your dhcpd.conf file for the network segment
Aug 26 14:34:25 raspberrypi dhcpd:    to which interface eth0 is attached. **
Aug 26 14:34:25 raspberrypi dhcpd:
Aug 26 14:34:25 raspberrypi dhcpd:
Aug 26 14:34:25 raspberrypi dhcpd: Not configured to listen on any interfaces!
Aug 26 14:47:52 raspberrypi ntpd[2205]: Listen normally on 3 wlan0 192.168.42.1 UDP 123
Aug 26 14:47:52 raspberrypi ntpd[2205]: peers refreshed
Aug 26 14:59:45 raspberrypi kernel: [321545.035060] ip_tables: (C) 2000-2006 Netfilter Core Team
Aug 26 14:59:45 raspberrypi kernel: [321545.067062] nf_conntrack version 0.5.0 (7012 buckets, 28048 max)
Aug 26 15:03:18 raspberrypi udhcpd[7588]: udhcpd (v1.20.2) started
Aug 26 15:03:18 raspberrypi udhcpd[7588]: can't open '/var/lib/misc/udhcpd.leases': No such file or directory
Aug 26 15:17:01 raspberrypi /USR/SBIN/CRON[7653]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug 26 15:17:19 raspberrypi kernel: imklog 5.8.11, log source = /proc/kmsg started.
Aug 26 15:17:19 raspberrypi rsyslogd: [origin software="rsyslogd" swVersion="5.8.11" x-pid="2018" x-info="http://www.rsyslog.com"] start
and here is my dhcpd.conf file

Code: Select all

#
# Sample configuration file for ISC dhcpd for Debian
#
#

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;

# 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;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

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

#subnet 10.152.187.0 netmask 255.255.255.0 {
#}

# This is a very basic subnet declaration.

#subnet 10.254.239.0 netmask 255.255.255.224 {
#  range 10.254.239.10 10.254.239.20;
#  option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
#}

# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.

#subnet 10.254.239.32 netmask 255.255.255.224 {
#  range dynamic-bootp 10.254.239.40 10.254.239.60;
#  option broadcast-address 10.254.239.31;
#  option routers rtr-239-32-1.example.org;
#}

# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
#  range 10.5.5.26 10.5.5.30;
#  option domain-name-servers ns1.internal.example.org;
#  option domain-name "internal.example.org";
#  option routers 10.5.5.1;
#  option broadcast-address 10.5.5.31;
#  default-lease-time 600;
#  max-lease-time 7200;
#}

# Hosts which require special configuration options can be listed in
# host statements.   If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.

#host passacaglia {
#  hardware ethernet 0:0:c0:5d:bd:95;
#  filename "vmunix.passacaglia";
# Fixed IP addresses can also be specified for hosts.   These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP.   Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
#host fantasia {
#  hardware ethernet 08:00:07:26:c0:a5;
#  fixed-address fantasia.fugue.com;
#}

# You can declare a class of clients and then do address allocation
# based on that.   The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.

#class "foo" {
#  match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
#}

#shared-network 224-29 {
#  subnet 10.17.224.0 netmask 255.255.255.0 {
#    option routers rtr-224.example.org;
#  }
#  subnet 10.0.29.0 netmask 255.255.255.0 {
#    option routers rtr-29.example.org;
#  }
#  pool {
#    allow members of "foo";
#    range 10.17.224.10 10.17.224.250;
#  }
#  pool {
#    deny members of "foo";
#    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;
}
The only other relevant thing I can think of is that my Pi is currently receiving a static IP from my router via LAN because of the way my samba shares are set up.

Any help would be awesome!!
Thanks

Re: Raspberry pi DHCP server

Posted: Tue Aug 27, 2013 12:21 am
by JustThisGuy

Code: Select all

Aug 26 15:03:18 raspberrypi udhcpd[7588]: udhcpd (v1.20.2) started
Aug 26 15:03:18 raspberrypi udhcpd[7588]: can't open '/var/lib/misc/udhcpd.leases': No such file or directory
Since you are trying to set up 'isc-dhcp-server' which runs as 'dhcpd' you should probably stop 'udhcpd' from starting.

Beyond that it appears that dhcpd isn't recognizing your wlan0 subnet. Off the top of my head, check /etc/network/interfaces points wlan0 to dhcp correctly.

Re: Raspberry pi DHCP server

Posted: Tue Aug 27, 2013 1:03 am
by dirksoccer
Not sure what exactly you mean in the first part? I have no clue what that service is but I assumed it was part of the dhcp server since that is the log I get when I run
sudo service isc-dhcp-server start

As for the second part here is my /etc/network/interfaces

Code: Select all

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp
iface wlan0 inet static
        adress 192.168.42.1
        netmask 255.255.255.0
up iptables-restore < /etc/iptables.ipv4.nat


Re: Raspberry pi DHCP server

Posted: Tue Aug 27, 2013 2:49 am
by SirLagz
What does ifconfig -a output ?

Re: Raspberry pi DHCP server

Posted: Tue Aug 27, 2013 3:14 am
by dirksoccer

Code: Select all

eth0      Link encap:Ethernet  HWaddr b8:27:eb:3e:73:ae
          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:27982 errors:0 dropped:0 overruns:0 frame:0
          TX packets:41641 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2559187 (2.4 MiB)  TX bytes:56598887 (53.9 MiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:34 errors:0 dropped:0 overruns:0 frame:0
          TX packets:34 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1700 (1.6 KiB)  TX bytes:1700 (1.6 KiB)

wlan0     Link encap:Ethernet  HWaddr c4:3d:c7:77:7e:d3
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:28004 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Re: Raspberry pi DHCP server

Posted: Tue Aug 27, 2013 4:01 am
by SirLagz
wlan0 doesn't have an IP Address, so it won't be able to hand out any IP addresses.

disable ifplugd for wlan0 and try again

Re: Raspberry pi DHCP server

Posted: Tue Aug 27, 2013 5:15 am
by dirksoccer
Any chance you could walk me through that? I'm really new to linux

Re: Raspberry pi DHCP server

Posted: Tue Aug 27, 2013 5:29 am
by SirLagz
http://sirlagz.net/2013/02/10/how-to-us ... r-part-3b/

Follow my blog post there and restart ifplugd afterwards by running /etc/init.d/ifplugd restart

Re: Raspberry pi DHCP server

Posted: Wed Aug 28, 2013 2:56 am
by dirksoccer
Didn't work...
Although I am getting a slightly different syslog error now,

Code: Select all

Aug 27 21:50:30 raspberrypi dhclient: DHCPREQUEST on eth0 to 192.168.1.1 port 67
Aug 27 21:50:30 raspberrypi dhclient: DHCPNAK from 192.168.1.1
Aug 27 21:50:30 raspberrypi dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
Aug 27 21:50:30 raspberrypi dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
Aug 27 21:50:30 raspberrypi dhclient: DHCPOFFER from 192.168.1.1
Aug 27 21:50:30 raspberrypi dhclient: DHCPACK from 192.168.1.1
Aug 27 21:50:31 raspberrypi dhclient: bound to 192.168.1.10 -- renewal in 38215 seconds.
Aug 27 21:52:26 raspberrypi dhcpd: Internet Systems Consortium DHCP Server 4.2.2
Aug 27 21:52:26 raspberrypi dhcpd: Copyright 2004-2011 Internet Systems Consortium.
Aug 27 21:52:26 raspberrypi dhcpd: All rights reserved.
Aug 27 21:52:26 raspberrypi dhcpd: For info, please visit https://www.isc.org/software/dhcp/
Aug 27 21:52:26 raspberrypi dhcpd: Internet Systems Consortium DHCP Server 4.2.2
Aug 27 21:52:26 raspberrypi dhcpd: Copyright 2004-2011 Internet Systems Consortium.
Aug 27 21:52:26 raspberrypi dhcpd: All rights reserved.
Aug 27 21:52:26 raspberrypi dhcpd: For info, please visit https://www.isc.org/software/dhcp/
Aug 27 21:52:26 raspberrypi dhcpd: Wrote 0 leases to leases file.
Aug 27 21:52:26 raspberrypi dhcpd:
Aug 27 21:52:26 raspberrypi dhcpd: No subnet declaration for wlan0 (no IPv4 addresses).
Aug 27 21:52:26 raspberrypi dhcpd: ** Ignoring requests on wlan0.  If this is not what
Aug 27 21:52:26 raspberrypi dhcpd:    you want, please write a subnet declaration
Aug 27 21:52:26 raspberrypi dhcpd:    in your dhcpd.conf file for the network segment
Aug 27 21:52:26 raspberrypi dhcpd:    to which interface wlan0 is attached. **
Aug 27 21:52:26 raspberrypi dhcpd:
Aug 27 21:52:26 raspberrypi dhcpd:
Aug 27 21:52:26 raspberrypi dhcpd: Not configured to listen on any interfaces!

Also, Thanks for all the help/advice guys!

Re: Raspberry pi DHCP server

Posted: Wed Aug 28, 2013 3:09 am
by SirLagz
Can you paste the contents of /etc/default/isc-dhcp-server

Re: Raspberry pi DHCP server

Posted: Wed Aug 28, 2013 5:50 pm
by dirksoccer

Code: Select all

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

#
# This is a POSIX shell fragment
#

# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPD_CONF=/etc/dhcp/dhcpd.conf

# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPD_PID=/var/run/dhcpd.pid

# Additional options to start dhcpd with.
#       Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""

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


Re: Raspberry pi DHCP server

Posted: Thu Aug 29, 2013 2:40 am
by SirLagz
And also ifconfig again please.
Sorry forgot to mention ifconfig.

Re: Raspberry pi DHCP server

Posted: Thu Aug 29, 2013 1:54 pm
by subbustrato
Aug 26 15:03:18 raspberrypi udhcpd[7588]: udhcpd (v1.20.2) started
Aug 26 15:03:18 raspberrypi udhcpd[7588]: can't open '/var/lib/misc/udhcpd.leases': No such file or directory
"udhcpd.leases" seems to be absent, could you verify if is present in /var/lib/misc/ ?

Re: Raspberry pi DHCP server

Posted: Thu Aug 29, 2013 5:27 pm
by dirksoccer
Here is my ifconfig output

Code: Select all

eth0      Link encap:Ethernet  HWaddr b8:27:eb:3e:73:ae
          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:63796 errors:0 dropped:0 overruns:0 frame:0
          TX packets:21768 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:11708671 (11.1 MiB)  TX bytes:9171396 (8.7 MiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:460 errors:0 dropped:0 overruns:0 frame:0
          TX packets:460 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:23704 (23.1 KiB)  TX bytes:23704 (23.1 KiB)

wlan0     Link encap:Ethernet  HWaddr c4:3d:c7:77:7e:d3
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:679 errors:0 dropped:250771 overruns:0 frame:0
          TX packets:183 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:123912 (121.0 KiB)  TX bytes:48410 (47.2 KiB)
How exactly do I verify the leases file exists??

Thanks

Re: Raspberry pi DHCP server

Posted: Thu Aug 29, 2013 7:23 pm
by subbustrato
you should go to dir /var/lib/misc/, and verify if there is the file udhcpd.leases, if there isn't create it and restart dhcp.

Re: Raspberry pi DHCP server

Posted: Thu Aug 29, 2013 7:30 pm
by dirksoccer
It appears that udhcpd.leases does exist
(just to make sure I'm doing this right, I ran

Code: Select all

cd /var/lib/misc
then the ls command and it spit out udhcpd.leases as the only output)

Re: Raspberry pi DHCP server

Posted: Thu Aug 29, 2013 7:45 pm
by subbustrato
ok, create it empty:

sudo nano udhcpd.leases

then save the file and reboot

Re: Raspberry pi DHCP server

Posted: Fri Aug 30, 2013 12:15 am
by dirksoccer
...didn't work...
I got the same error/syslog as before (wrote 0 leases, wlan0 issues, not configured to listen...see above for full copy/paste)

Thanks for the help guys, we're bound to figure it out soon!

Re: Raspberry pi DHCP server

Posted: Fri Aug 30, 2013 1:47 am
by SirLagz
dirksoccer wrote:...didn't work...
I got the same error/syslog as before (wrote 0 leases, wlan0 issues, not configured to listen...see above for full copy/paste)

Thanks for the help guys, we're bound to figure it out soon!
wlan0 still has no IP address...
can you run "ps aux | grep ifplugd" and paste the output

Re: Raspberry pi DHCP server

Posted: Fri Aug 30, 2013 2:25 am
by dirksoccer
Hopefully I ran it right, here's the output I got

Code: Select all

root      1717  0.0  0.1   1744   504 ?        S    19:11   0:03 /usr/sbin/ifplugd -i eth0 -q -f -u0 -d10 -w -I
pi        2553  0.0  0.1   3544   868 pts/0    S+   21:24   0:00 grep --color=au            to ifplugd

Re: Raspberry pi DHCP server

Posted: Fri Aug 30, 2013 8:01 am
by SirLagz
Yes, you ran it right.
Can you run ifdown wlan0 && ifup wlan0 and then run ifconfig again and paste the results ?

Re: Raspberry pi DHCP server

Posted: Fri Aug 30, 2013 2:50 pm
by dirksoccer
I ran them both and ifconfig, but got weird outputs for ifdown and ifup, take a look

Code: Select all

pi@raspberrypi ~ $ ifdown wlan0
ifdown: failed to open statefile /run/network/ifstate: Permission denied
pi@raspberrypi ~ $ sudo ifdown wlan0
ifdown: interface wlan0 not configured
pi@raspberrypi ~ $ sudo ifup wlan0
Missing required variable: address
Missing required configuration variables for interface wlan0/inet.
Failed to bring up wlan0.
pi@raspberrypi ~ $ ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:3e:73:ae
          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:27117 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9132 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5548075 (5.2 MiB)  TX bytes:3685655 (3.5 MiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:140 errors:0 dropped:0 overruns:0 frame:0
          TX packets:140 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:7000 (6.8 KiB)  TX bytes:7000 (6.8 KiB)

wlan0     Link encap:Ethernet  HWaddr c4:3d:c7:77:7e:d3
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:94685 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Re: Raspberry pi DHCP server

Posted: Fri Aug 30, 2013 4:07 pm
by bqaggie2006
Not sure if this is it, but it looks like "Address" is missing a "d" in the declaration for wlan0 in your /etc/network/interfaces file. Try fixing that and then issue the following command:

Code: Select all

sudo service networking restart
Then run

Code: Select all

sudo ifconfig -a
to see if wlan0 has gotten an address yet.

Re: Raspberry pi DHCP server

Posted: Fri Aug 30, 2013 7:01 pm
by dirksoccer
......I'm an idiot. That worked, it fixed it, rebooted the pi and the server started up perfectly. Days of troubleshooting because I can't spell address...such is programming I guess LoL.

Anyway, self-deprecating rant over now. Thanks a ton for all the help guys!! The pi is now successfully a NAS/DLNA server that also broadcasts wifi, and just in time for college (I move in tomorrow, and the security measures on their network are the whole reason I'm setting this up). Anyway, thanks a ton!