0

I'm trying to get a DHCP server running on a Raspberry Pi 3 Model B. I've followed instructions in several guides I've found and keep seeing the same error when I try to start the server:

root@killarney:/etc/network# service isc-dhcp-server restart.
/etc/init.d/isc-dhcp-server: 23: /etc/default/isc-dhcp-server: subnet: not found
/etc/init.d/isc-dhcp-server: 24: /etc/default/isc-dhcp-server: range: not found
/etc/init.d/isc-dhcp-server: 26: /etc/default/isc-dhcp-server: Syntax error: "}" unexpected
root@killarney:/etc/network# 

Contents of /etc/default/isc-dhcp-server

# 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="eth0"

subnet 192.168.12.0 netmask 255.255.255.0 {
  range 192.168.12.5 192.168.12.100;
  #option routers pepper.spices.org;
}

Line 23 is the one starting with 'subnet'. I do not understand the error message.

Other info...

root@killarney:/etc/network# cat interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

#config eth0 for dhcp
iface eth0 inet static
address 192.168.12.2
netmask 255.255.255.0
gateway 192.168.12.254


allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

root@killarney:/etc/network#

root@killarney:/etc/network# ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:1a:4b:e6  
          inet addr:192.168.12.2  Bcast:192.168.12.255  Mask:255.255.255.0
          inet6 addr: fe80::3f6b:9d4c:b66f:161f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:82718 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15543 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:121229265 (115.6 MiB)  TX bytes:1498876 (1.4 MiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1097 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1097 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:110224 (107.6 KiB)  TX bytes:110224 (107.6 KiB)

wlan0     Link encap:Ethernet  HWaddr b8:27:eb:4f:1e:b3  
          inet addr:192.168.1.217  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: 2601:249:e00:b215:167c:a6f7:a793:93d5/64 Scope:Global
          inet6 addr: fe80::7764:92ff:8797:f8f9/64 Scope:Link
          inet6 addr: 2601:249:e00:b215::1d53/128 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:32960 errors:0 dropped:3278 overruns:0 frame:0
          TX packets:18197 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:32901505 (31.3 MiB)  TX bytes:2421876 (2.3 MiB)

root@killarney:/etc/network# 

What have I overlooked?

Thanks!

PS Should be tagged dhcpd but I cannot create that tag. :(

  • You appear to be running (or attempting to run) a dhcp server and a dhcp client. Decide what you want to do. – Milliways Jan 19 '17 at 22:41
  • I can't have both? DHCP client on wlan0 and DHCP server on eth0? The host is multi-homed. – HankB Jan 21 '17 at 2:28
0

I don't think you put your subnet stuff in the /etc/default/isc-dhcp-server file. That should live in the config file /etc/dhcp/dhcpd.conf here.

  • I tried moving the information from '/etc/default/isc-dhcp-server' to '/etc/dhcp/dhcpd.conf' and it did change the error messages. No Joy. I moved on and configured the device that needed the IP address for a static IP. – HankB Jan 21 '17 at 2:31
  • To clarify my answer, you'd leave the INTERFACES line in the default and only move the subnet stanza out into the config file. I-D-S throws another error if that INTERFACES block isn't in the default file. You have to be careful about formatting and semicolons in the config file. If its a simple setup i'd look into dnsmasq as an alternative, its a bit more at the scale Pi's get used at. Glad its sorted one way or the other though. – tobyd Jan 21 '17 at 8:51

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.