10

I have just setup isc-dhcp on my server. I even setup the correct interface. But still the dhcp server won't boot. Its says Not configured to listen on any interfaces! in the syslog. And when I try dhcpd -t /etc/dhcp/dhcpd.conf it gives this error : /etc/dhcp/dhcpd.conf: interface name too long (is 20

Here's my dhcpd.conf :

ddns-update-style none;

option domain-name "thpi";
option domain-name-servers 208.67.222.222, 208.67.220.220;

default-lease-time 86400;
max-lease-time 604800;

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;


subnet 10.0.0.0 netmask 255.255.255.0 {
    ## dhcp start  and end IP range ##
    range 10.0.0.20 10.0.0.90;
    option subnet-mask 255.255.255.0;     ## subnet
    option broadcast-address 10.0.0.255; ## broadcast
    option routers 10.0.0.1; ## router IP


    host pc1 {
        hardware ethernet 60:a4:4c:3d:76:fa;
        fixed-address 10.0.0.100;
    }

    host lap1 {
        hardware ethernet 6c:71:d9:1e:f3:4f;
        fixed-address 10.0.0.150;
    }

    host thnote {
        hardware ethernet d0:22:be:d3:be:e1;
        fixed-address 10.0.0.200;
    }
}

/etc/default/isc-dhcp-server file :

# 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:0"

Interfaces file :

auto lo

iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

auto eth0:0
iface eth0:0 inet static
name Lan
address 10.0.0.1
netmask 255.255.255.0
network 10.0.0.0

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

What might be the issue?

4

9 Answers 9

6

I got the same issue and it got solved after assigning an IP address to my interface

like,

ifconfig eth0 192.168.1.100
2
  • this worked for me i just hope that it will work when i reboot the computer. Apr 24, 2018 at 20:57
  • this worked for me right away Mar 31, 2021 at 18:48
5

Your /etc/default/isc-dhcp-server file should have

INTERFACES="eth0"
3

I had this same problem. For Ubuntu 20.04 1 LTS. I had two NICs and I only wanted to use one of them to vend IPs via dhcp to clients on a LAN.

My fix was a combination of things as shown below. However I belive the real fix was the addition of interface to /etc/dhcp/dhcpd.conf

/etc/dhcp/dhcpd.conf
was (broken):

default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
authoritative;

subnet 192.168.0.0 netmask 255.255.255.0 {
   range 192.168.0.2 192.168.0.99;
   option routers 192.168.0.1;
   option subnet-mask 255.255.255.0;
   option domain-name-servers 1.1.1.1, 1.0.0.1, 8.8.8.8;
}


changed to (added interface and it worked):

default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
authoritative;

subnet 192.168.0.0 netmask 255.255.255.0 {
   interface enp6s0;
   range 192.168.0.2 192.168.0.99;
   option routers 192.168.0.1;
   option subnet-mask 255.255.255.0;
   option domain-name-servers 1.1.1.1, 1.0.0.1, 8.8.8.8;
}

In hacking around I also changed the following, but not sure now I needed to. Shown for completeness.

/etc/default/isc-dhcp-server
was:
INTERFACESv4=""
INTERFACESv6=""

changed to (the interface I want dhcp to use):
INTERFACESv4="enp6s0"
INTERFACESv6="enp6s0"

1
  • 1
    OH DEAR GOD! I wasted so much time on this annoying dhcp server!!!! Why do you need to define the interface in 15 different places!? Thanks so much for pointing this out! :)
    – tftd
    Jun 22, 2021 at 2:20
3
  1. Set the static IP of the server...

    ifconfig (yourinterface)  (your static IP)/(mask number) example 
    sudo ifconfig enp4s0 10.8.0.2/24
    
  2. Start the DHCP server...

    sudo systemctl start isc-dhcp-server
    
  3. And retrieve its status...

    sudo systemctl status isc-dhcp-server
    
1
  • On Kubuntu 20.04 following equivalent worked for me: ip address add 10.0.0.1 dev enp2s0, however, I was not configuring a virtual interface.
    – cbugk
    Feb 28, 2023 at 11:50
1

There are two ways to start networking

  1. via /etc/network/interfaces

  2. via NetworkManager

    1. start early
    2. start late

DHCPD try to start after 1) but before 2)

If dhcpd can not detect network, try method 1)

2
  • 1
    Could you please explain that better?
    – derHugo
    Nov 9, 2017 at 5:58
  • You can set ip address of your computer with GUI based applet sitting on panel of your GUI. this starts setting ip address later than DHCPD application start. If you set up address in /etc/network/interfaces it will set ip first and then start DHCPD. Nov 24, 2017 at 9:47
1

http://www.braindisconnect.com/wiki/index.php?title=Linux_DHCP_Server

This message has nothing to do with your dhcpd.conf file or configuration. The error is because dhcpd is interpreting the /etc/dhcp/dhcpd.conf as an interface. The 20 is the character count of "/etc/dhcp/dhcpd.conf" and not the file contents.

Add the -cf to your syntax and so that config file is actually getting tested or just use dhcpd -t.

1
  • I think this is the real issue too
    – jouell
    Mar 14 at 19:12
1

I was also getting the same error. I found that I was starting the isc-dhcp-server6.service(IPV6), instead of isc-dhcp-server.service(IPV4). My configuration files were defined for ipv4 only. Hence I was getting "Not configured to listen on any interface" when I tried to do "systemctl start isc-dhcp-server6.service".

0

I had this issue as well. Dhcpd was starting before the network interface was ready. You can add this to your /etc/init/isc-dhcp-server.conf file (for IPv4).

Near the bottom of the file you will see a line like this (the "exec" is what you are looking for):

exec dhcpd -user dhcpd -group dhcpd -f -q -4 -pf /run/dhcp-server/dhcpd.pid -cf $CONFIG_FILE $INTERFACES

Add this to the line above it

sleep 30

This will delay the start of your dhcpd server. It will not slow down the rest of your boot process.

The bottom of that file now looks like this:

respawn
script
        if [ -f /etc/ltsp/dhcpd.conf ]; then
            CONFIG_FILE=/etc/ltsp/dhcpd.conf
        else
            CONFIG_FILE=/etc/dhcp/dhcpd.conf
        fi

        . /etc/default/isc-dhcp-server

        # Allow dhcp server to write lease and pid file as 'dhcpd' user
        mkdir -p /var/run/dhcp-server
        chown dhcpd:dhcpd /var/run/dhcp-server

        # The leases files need to be root:root even when dropping privileges
        [ -e /var/lib/dhcp/dhcpd.leases ] || touch /var/lib/dhcp/dhcpd.leases
        chown root:root /var/lib/dhcp /var/lib/dhcp/dhcpd.leases
        if [ -e /var/lib/dhcp/dhcpd.leases~ ]; then
            chown root:root /var/lib/dhcp/dhcpd.leases~
        fi

        sleep 30

        exec dhcpd -user dhcpd -group dhcpd -f -q -4 -pf /run/dhcp-server/dhcpd.pid -cf $CONFIG_FILE $INTERFACES
    end script
1
  • It does not work
    – ras212
    May 23, 2018 at 14:50
0

I had this issue also, but despite all the above, I needed to declare a scope for the subnet my NIC was directly connected to. This allowed the service to start without error.

You must log in to answer this question.

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