Saturday, May 18, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 4099  / 2 Years ago, fri, november 4, 2022, 10:59:30

I've been following this tutorial from Ubuntu to set up a DHCP server on my machine, but I just can't get it work. When I run


sudo systemctl restart isc-dhcp-server.service
sudo systemctl status isc-dhcp-server.service

it gives me the error status failed, and the following output in /var/log/syslog:


systemd[1303]: gnome-launched-code.desktop-6211.scope: Succeeded.
Apr 20 18:51:20 dragonfly systemd[1]: Started ISC DHCP IPv4 server.
Apr 20 18:51:20 dragonfly dhcpd[6757]: Internet Systems Consortium DHCP Server 4.4.1
Apr 20 18:51:20 dragonfly sh[6757]: Internet Systems Consortium DHCP Server 4.4.1
Apr 20 18:51:20 dragonfly sh[6757]: Copyright 2004-2018 Internet Systems Consortium.
Apr 20 18:51:20 dragonfly sh[6757]: All rights reserved.
Apr 20 18:51:20 dragonfly sh[6757]: For info, please visit https://www.isc.org/software/dhcp/
Apr 20 18:51:20 dragonfly dhcpd[6757]: Copyright 2004-2018 Internet Systems Consortium.
Apr 20 18:51:20 dragonfly dhcpd[6757]: All rights reserved.
Apr 20 18:51:20 dragonfly dhcpd[6757]: For info, please visit https://www.isc.org/software/dhcp/
Apr 20 18:51:20 dragonfly dhcpd[6757]: Config file: /etc/dhcp/dhcpd.conf
Apr 20 18:51:20 dragonfly sh[6757]: Config file: /etc/dhcp/dhcpd.conf
Apr 20 18:51:20 dragonfly sh[6757]: Database file: /var/lib/dhcp/dhcpd.leases
Apr 20 18:51:20 dragonfly sh[6757]: PID file: /run/dhcp-server/dhcpd.pid
Apr 20 18:51:20 dragonfly dhcpd[6757]: Database file: /var/lib/dhcp/dhcpd.leases
Apr 20 18:51:20 dragonfly sh[6757]: Wrote 0 leases to leases file.
Apr 20 18:51:20 dragonfly dhcpd[6757]: PID file: /run/dhcp-server/dhcpd.pid
Apr 20 18:51:20 dragonfly dhcpd[6757]: Wrote 0 leases to leases file.
Apr 20 18:51:20 dragonfly dhcpd[6757]:
Apr 20 18:51:20 dragonfly sh[6757]: No subnet declaration for eth4 (no IPv4 addresses).
Apr 20 18:51:20 dragonfly sh[6757]: ** Ignoring requests on eth4. If this is not what
Apr 20 18:51:20 dragonfly sh[6757]: you want, please write a subnet declaration
Apr 20 18:51:20 dragonfly sh[6757]: in your dhcpd.conf file for the network segment
Apr 20 18:51:20 dragonfly sh[6757]: to which interface eth4 is attached. **
Apr 20 18:51:20 dragonfly sh[6757]: Not configured to listen on any interfaces!
Apr 20 18:51:20 dragonfly sh[6757]: If you think you have received this message due to a bug rather
Apr 20 18:51:20 dragonfly sh[6757]: than a configuration issue please read the section on submitting
Apr 20 18:51:20 dragonfly sh[6757]: bugs on either our web page at www.isc.org or in the README file
Apr 20 18:51:20 dragonfly sh[6757]: before submitting a bug. These pages explain the proper
Apr 20 18:51:20 dragonfly sh[6757]: process and the information we find helpful for debugging.
Apr 20 18:51:20 dragonfly sh[6757]: exiting.
Apr 20 18:51:20 dragonfly dhcpd[6757]: No subnet declaration for eth4 (no IPv4 addresses).
Apr 20 18:51:20 dragonfly dhcpd[6757]: ** Ignoring requests on eth4. If this is not what
Apr 20 18:51:20 dragonfly dhcpd[6757]: you want, please write a subnet declaration
Apr 20 18:51:20 dragonfly dhcpd[6757]: in your dhcpd.conf file for the network segment
Apr 20 18:51:20 dragonfly dhcpd[6757]: to which interface eth4 is attached. **
Apr 20 18:51:20 dragonfly dhcpd[6757]:
Apr 20 18:51:20 dragonfly dhcpd[6757]:
Apr 20 18:51:20 dragonfly dhcpd[6757]: Not configured to listen on any interfaces!
Apr 20 18:51:20 dragonfly dhcpd[6757]:
Apr 20 18:51:20 dragonfly dhcpd[6757]: If you think you have received this message due to a bug rather
Apr 20 18:51:20 dragonfly dhcpd[6757]: than a configuration issue please read the section on submitting
Apr 20 18:51:20 dragonfly dhcpd[6757]: bugs on either our web page at www.isc.org or in the README file
Apr 20 18:51:20 dragonfly dhcpd[6757]: before submitting a bug. These pages explain the proper
Apr 20 18:51:20 dragonfly dhcpd[6757]: process and the information we find helpful for debugging.
Apr 20 18:51:20 dragonfly dhcpd[6757]:
Apr 20 18:51:20 dragonfly dhcpd[6757]: exiting.
Apr 20 18:51:20 dragonfly systemd[1]: isc-dhcp-server.service: Main process exited, code=exited, status=1/FAILURE
Apr 20 18:51:20 dragonfly systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.
Apr 20 18:52:39 dragonfly PackageKit: daemon quit
Apr 20 18:52:39 dragonfly systemd[1]: packagekit.service: Succeeded.

I guess the relevant part of the error code is this:


No subnet declaration for eth4 (no IPv4 addresses).
Ignoring requests on eth4. If this is not what
you want, please write a subnet declaration
in your dhcpd.conf file for the network segment
to which interface eth4 is attached.

Does anyone know what to do with this?
I also found this related question, but it is quite old, and I am still confused.


Edit:


/etc/dhcp/dhcpd.conf


default-lease-time 600;
max-lease-time 7200;

subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.150 192.168.1.200;
option routers 192.168.1.254;
option domain-name-servers 192.168.1.1, 192.168.1.2;
option domain-name "mydomain.example";
}

/etc/default/isc-dhcp-server


INTERFACESv4="eth4"

Output of ip addr:


1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether f0:2f:74:dd:bb:18 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.240/24 brd 192.168.0.255 scope global dynamic noprefixroute enp4s0
valid_lft 4978sec preferred_lft 4978sec
inet6 fe80::8452:bb97:94cd:6ea6/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: wlo1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 7c:50:79:76:23:f2 brd ff:ff:ff:ff:ff:ff
altname wlp0s20f3

More From » networking

 Answers
7

Based on @Doug Smythies comments I got it working.


First of all, I changed /etc/default/isc-dhcp-server to INTERFACESv4="enp4s0", since that is my wired interface, which I want to use for DHCP.


When I ran ip addr, it was telling me that interface enp4s0 is on inet 192.168.0.240/24. However, in my /etc/dhcp/dhcpd.conf I was defining the subnet as subnet 192.168.1.0 netmask 255.255.255.0. Note difference in the subnet here, the 192.168.0.x vs the 192.168.1.x part. To make the DHCP server work, these have to be matching. So I had to move my interface to 192.168.1.x. To do this, follow these steps:



  1. Go to Network Settings.

  2. Remove the current Wired setting.

  3. Create a new one with the + icon.

  4. Go to IPv4 settings, change IPv4 Method to Manual, and set the Addresses fields to match your dhcpd.conf configurations.
    Wired connection IPv4 configuration

  5. Click to add and save the changes.

  6. When you reopen the settings, you should see the correct IPv4 address you just set. Wired connection IPv4 configuration check


Or, I also could have rewritten my /etc/dhcp/dhcpd.conf to match the subnet by changing everything to its 192.168.0.x equivalent, and leaving my interface settings untouched.




So, now my correct setup is:


Network Settings: My correct setup


ip addr


1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 04:42:1a:2c:9e:a1 brd ff:ff:ff:ff:ff:ff
altname enp0s31f6
inet 192.168.1.0/24 brd 192.168.1.255 scope global noprefixroute enp4s0
valid_lft forever preferred_lft forever
inet6 fe80::8a50:e8aa:63c1:f6fa/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: wlo1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 20:1e:88:2e:cc:f0 brd ff:ff:ff:ff:ff:ff
altname wlp0s20f3
inet 192.168.50.169/24 brd 192.168.50.255 scope global dynamic noprefixroute wlo1
valid_lft 15594sec preferred_lft 15594sec
inet6 fe80::45f1:e127:53a0:e49c/64 scope link noprefixroute
valid_lft forever preferred_lft forever

/etc/dhcp/dhcpd.conf


default-lease-time 600;
max-lease-time 7200;
authoritative;

subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.254;
option domain-name-servers 192.168.1.1, 192.168.1.2;
}

/etc/default/isc-dhcp-server


INTERFACESv4="enp4s0"

[#658] Saturday, November 5, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lowovey

Total Points: 287
Total Questions: 98
Total Answers: 117

Location: Bosnia and Herzegovina
Member since Thu, Jan 14, 2021
3 Years ago
;