isc-dhcp-server fails if interface not connected on reboot
On Ubuntu 18.04 on my gateway server, I've installed and configured isc-dhcp-server, but it doesn't start up (i.e. it fails to start) if there's nothing connected to enp2s0 after a reboot.
Note it says "Not configured to listen on any interfaces!"
$ service isc-dhcp-server status
● isc-dhcp-server.service - ISC DHCP IPv4 server
Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2020-01-18 19:05:34 GMT; 1s ago
Docs: man:dhcpd(8)
Process: 3475 ExecStart=/bin/sh -ec CONFIG_FILE=/etc/dhcp/dhcpd.conf; if [ -f /etc/ltsp/dhcpd.conf ]; then CONFIG_FILE=/etc/ltsp/dhcpd.conf; fi; [ -e /var/lib/dhcp/dhcpd.leases ] || touch /v
Main PID: 3475 (code=exited, status=1/FAILURE)
Jan 18 19:05:34 user-Default-string dhcpd[3475]:
Jan 18 19:05:34 user-Default-string dhcpd[3475]: Not configured to listen on any interfaces!
Jan 18 19:05:34 user-Default-string dhcpd[3475]:
Jan 18 19:05:34 user-Default-string dhcpd[3475]: If you think you have received this message due to a bug rather
Jan 18 19:05:34 user-Default-string dhcpd[3475]: than a configuration issue please read the section on submitting
Jan 18 19:05:34 user-Default-string dhcpd[3475]: bugs on either our web page at www.isc.org or in the README file
Jan 18 19:05:34 user-Default-string dhcpd[3475]: before submitting a bug. These pages explain the proper
Jan 18 19:05:34 user-Default-string dhcpd[3475]: process and the information we find helpful for debugging..
Jan 18 19:05:34 user-Default-string dhcpd[3475]:
Jan 18 19:05:34 user-Default-string dhcpd[3475]: exiting.
My gateway server has two ethernet ports, enp1s0, and enp2s0. I use enp1s0 for internet access via a router, and enp2s0 simply for serving a web app to ethernet-connected laptops. enp2s0 is the one for which the DHCP server assigns IP addresses (for the laptops needing the web app). I want enp1s0 to get a random IP address from the internet-conneted router on the 192.168.1.0 subnet, so that interface is not managed by isc-dhcp-server, only enp2s0.
Here's "ip route" with nothing connected to enp2s0, if that might help...
$ ip route
default via 192.168.1.254 dev enp1s0 proto dhcp metric 100
169.254.0.0/16 dev enp1s0 scope link metric 1000
192.168.1.0/24 dev enp1s0 proto kernel scope link src 192.168.1.76 metric 100
Here's my dhcpd.conf setup:
default-lease-time 600;
max-lease-time 7200;
# 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;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;
# This is a very basic subnet declaration.
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.200 192.168.2.250;
# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
option broadcast-address 192.168.2.255;
}
Here's my isc-dhcp-server setup:
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACESv4="enp2s0"
INTERFACESv6=""
One solution is to restart the isc-dhcp-server after plugging a laptop into enp2s0, but I don't want to have to do that after every reboot, or every time someone plugs in a laptop to enp2s0. The DHCP server works after restarting the service...
$ sudo service isc-dhcp-server restart
$ service isc-dhcp-server status
● isc-dhcp-server.service - ISC DHCP IPv4 server
Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2020-01-18 18:22:01 GMT; 14min ago
Docs: man:dhcpd(8)
Main PID: 2437 (dhcpd)
Tasks: 1 (limit: 2016)
CGroup: /system.slice/isc-dhcp-server.service
└─2437 dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf enp2s0
Any ideas? I'm sure there's a configuration thing I'm missing, that will solve this problem...
EDIT: Output from command "nmcli connection show lan" (AKA: nmcli c s lan)
$ nmcli connection show lan
connection.id: lan
connection.uuid: 96fbb458-1178-4af2-a1b7-ccce301176e0
connection.stable-id: --
connection.type: 802-3-ethernet
connection.interface-name: enp2s0
connection.autoconnect: yes
connection.autoconnect-priority: 0
connection.autoconnect-retries: -1 (default)
connection.auth-retries: -1
connection.timestamp: 1579379514
connection.read-only: no
connection.permissions: --
connection.zone: --
connection.master: --
connection.slave-type: --
connection.autoconnect-slaves: -1 (default)
connection.secondaries: --
connection.gateway-ping-timeout: 0
connection.metered: unknown
connection.lldp: default
connection.mdns: -1 (default)
802-3-ethernet.port: --
802-3-ethernet.speed: 0
802-3-ethernet.duplex: --
802-3-ethernet.auto-negotiate: no
802-3-ethernet.mac-address: --
802-3-ethernet.cloned-mac-address: --
802-3-ethernet.generate-mac-address-mask:--
802-3-ethernet.mac-address-blacklist: --
802-3-ethernet.mtu: auto
802-3-ethernet.s390-subchannels: --
802-3-ethernet.s390-nettype: --
802-3-ethernet.s390-options: --
802-3-ethernet.wake-on-lan: default
802-3-ethernet.wake-on-lan-password: --
ipv4.method: manual
ipv4.dns: --
ipv4.dns-search: --
ipv4.dns-options: ""
ipv4.dns-priority: 0
ipv4.addresses: 192.168.2.2/24
ipv4.gateway: --
ipv4.routes: --
ipv4.route-metric: -1
ipv4.route-table: 0 (unspec)
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-timeout: 0 (default)
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.dhcp-fqdn: --
ipv4.never-default: no
ipv4.may-fail: yes
ipv4.dad-timeout: -1 (default)
ipv6.method: auto
ipv6.dns: --
ipv6.dns-search: --
ipv6.dns-options: ""
ipv6.dns-priority: 0
ipv6.addresses: --
ipv6.gateway: --
ipv6.routes: --
ipv6.route-metric: -1
ipv6.route-table: 0 (unspec)
ipv6.ignore-auto-routes: no
ipv6.ignore-auto-dns: no
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: -1 (unknown)
ipv6.addr-gen-mode: stable-privacy
ipv6.dhcp-send-hostname: yes
ipv6.dhcp-hostname: --
ipv6.token: --
proxy.method: none
proxy.browser-only: no
proxy.pac-url: --
proxy.pac-script: --
EDIT2: Added output from "nmcli -f name,autoconnect connection show"
$ nmcli -f name,autoconnect connection show
NAME AUTOCONNECT
Wired connection 1 yes
lan yes
EDIT3: Added output from "cat /etc/NetworkManager/system-connections/lan"
[connection]
id=lan
uuid=96fbb458-1178-4af2-a1b7-ccce301176e0
type=ethernet
interface-name=enp2s0
permissions=
timestamp=1579379263
[ethernet]
mac-address-blacklist=
[ipv4]
address1=192.168.2.2/24
dns-search=
method=manual
[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto
Is the interface (enp2s0) up at all ? It needs to have an ipv4 address added and then started (up)
It shouldn't matter if any clients is connected to the hub/switch.
Edit: Network Manager ?
I hate that thing with a passion, but either way: if the iface isn't up with a correct address dhcpd wont start, so you need to figure out how to with nmcli create a static configuration which is always up.
Edit: What shows this ?
nmcli connection show lan
The connection.autoconnection property is interesting.
Edit: What shows this:
nmcli -f name,autoconnect connection show
Ok, what is the status
nmcli -f name,autoconnect connection show
after reboot without your hack ? The autoconnect property should be enough to bring up the interface... not knowing why somethings fails in something which is basically very simple is one of my dislikes about NetworkManager (to much complexity for unknown benefits, i see the point for clients which is constantly on the move but servers which must simply work??)
Edit: any files in etc/NetworkManger/system-connections ? That is at least how i configured the devices in my system (it is a bridged config), so i do use NetworkManager to bring up the machine. The machine is host for three guests so the enp1s0 device is a slave.
Edit: what happens if you define the lan device (remove it completely first) ie something like:
nmcli connection down lan
nmcli connection delete lan
nmcli connection add type ethernet ifname enp2s0 con-name lan autoconnect on
nmcli connection modify lan ipv4.method manual ipv4.addresses 192.168.2.2/24
nmcli connection lan up