bls
Posts: 596
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: No subnet declaration for eth0. Setting up DHCP server.

Sat Mar 28, 2020 3:42 am

agasfer wrote:
Sat Mar 28, 2020 1:19 am
guys, any more ideas on this?

I am suffering from the same problem, am using R-Pi as a DHCP server on the home network, and it does not come up on its own after power interruptions (of which we started having a few :P) Note that in my setup the Pi is also configured with static IPv4 address, and IPv6 is disabled.

I sure hope some folks in the know read this thread :D
What does your /etc/default/isc-dhcp-server look like? Please post. Also, please post your /etc/dhcp/dhcpd.conf.
Super-useful tools:
RPi SD Card Image Manager: https://github.com/gitbls/sdm
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo
Easy-Peasy VPN installer/manager: https://github.com/gitbls/pistrong

agasfer
Posts: 16
Joined: Fri Feb 17, 2017 5:13 am
Location: East Bay, California, USA

Re: No subnet declaration for eth0. Setting up DHCP server.

Sat Mar 28, 2020 4:21 am

here you are:

Code: Select all

ra^i: /home/pi 3 > egrep -v '(^#|^$)' /etc/default/isc-dhcp-server 
INTERFACESv4="eth0"
ra^i: /home/pi 4 > egrep -v '(^#|^$)' /etc/dhcp/dhcpd.conf         
option domain-name "example.org";
option domain-name-servers 8.8.8.8, 8.8.4.4;
default-lease-time 36000;
max-lease-time 36000;
ddns-update-style none;
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.100 192.168.1.139;
  option routers 192.168.1.1;
}
ra^i: /home/pi 5 > 

epoch1970
Posts: 5016
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: No subnet declaration for eth0. Setting up DHCP server.

Sat Mar 28, 2020 11:42 am

I bet the sleep you tried adding went actually in the wrong direction.
Try delaying the server, not the client.
The client sets a static IP address on the interface used by the server.
The server will not start if its listening interface doesn’t have an IP address.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

bls
Posts: 596
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: No subnet declaration for eth0. Setting up DHCP server.

Sat Mar 28, 2020 2:55 pm

epoch1970 wrote:
Sat Mar 28, 2020 11:42 am
I bet the sleep you tried adding went actually in the wrong direction.
Try delaying the server, not the client.
The client sets a static IP address on the interface used by the server.
The server will not start if its listening interface doesn’t have an IP address.
epoch1970 nailed it. Your log shows dhcpcd getting it's address after dhcpd has exited. Put the delay on isc-dhcp-server, remove it from dhcpcd, and then try again.
Super-useful tools:
RPi SD Card Image Manager: https://github.com/gitbls/sdm
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo
Easy-Peasy VPN installer/manager: https://github.com/gitbls/pistrong

agasfer
Posts: 16
Joined: Fri Feb 17, 2017 5:13 am
Location: East Bay, California, USA

Re: No subnet declaration for eth0. Setting up DHCP server.

Sat Mar 28, 2020 3:18 pm

but how do I delay isc-dhcpd startup - I don't see any systemd files controlling it?

epoch1970
Posts: 5016
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: No subnet declaration for eth0. Setting up DHCP server.

Sat Mar 28, 2020 5:38 pm

No idea I haven’t used that thing in maybe 20 years :D
Isn’t there something in /etc/init.d ?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

bls
Posts: 596
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: No subnet declaration for eth0. Setting up DHCP server.

Sat Mar 28, 2020 7:40 pm

I run isc-dhcp-server on my Pi as well. I use dhcpcd to configure the host's IP. I don't use /etc/network/interfaces at all.

Here are the lines I've added to my /etc/dhcpcd.conf. My LAN subnet is 192.168.92.0/24

Code: Select all

noipv6
interface eth0
static ip_address=192.168.92.3/24
static routers=192.168.92.1
static domain_name_servers=192.168.92.3
If you're running Buster, you'd be much better off using dhcpcd to statically configure your IP address than /etc/network/interfaces. Plus, those of us running isc-dhcp-server and dhcpcd would be more able to assist you.
Super-useful tools:
RPi SD Card Image Manager: https://github.com/gitbls/sdm
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo
Easy-Peasy VPN installer/manager: https://github.com/gitbls/pistrong

agasfer
Posts: 16
Joined: Fri Feb 17, 2017 5:13 am
Location: East Bay, California, USA

Re: No subnet declaration for eth0. Setting up DHCP server.

Sat Mar 28, 2020 9:14 pm

I am using /etc/dhcpd.conf to configure static IP for the Pi.

epoch1970 was right, isc-dhcp-server startup had to be delayed.

This is the change which made it work:

Code: Select all

root@raspberrypi:/etc# git diff --cached init.d/isc-dhcp-server 
diff --git a/init.d/isc-dhcp-server b/init.d/isc-dhcp-server
index 37f899f..3d461b8 100755
--- a/init.d/isc-dhcp-server
+++ b/init.d/isc-dhcp-server
@@ -136,8 +136,18 @@ stop_daemon()
 	fi
 }
 
+wait_for_dhcpd()
+{
+	while [ ! -f "/var/run/dhcpcd.pid" ]; do
+		echo "waiting for dhcpd to start"
+		sleep 1
+	done
+	sleep 10
+}
+
 case "$1" in
 	start)
+		wait_for_dhcpd
 		if test -n "$INTERFACES" -a -z "$INTERFACESv4"; then
                         echo "DHCPv4 interfaces are no longer set by the INTERFACES variable in" >&2
                         echo "/etc/default/isc-dhcp-server.  Please use INTERFACESv4 instead." >&2
root@raspberrypi:/etc# 
thank you for your help, guys.

This seems wrong though, vanilla installation should just work, and I am not sure the above solution is the most elegant possible.

adam van gaalen
Posts: 33
Joined: Sun Jul 01, 2012 11:51 am

Re: No subnet declaration for eth0. Setting up DHCP server.

Tue Apr 21, 2020 1:22 pm

Now, would it be possible to send the complete (correct) 'isc-dhcp-server' file?

It's easier to replace the faulty file by a correct file than to try to interpret your 'diff-output'.

Thanks in advance,
Adam

agasfer
Posts: 16
Joined: Fri Feb 17, 2017 5:13 am
Location: East Bay, California, USA

Re: No subnet declaration for eth0. Setting up DHCP server.

Tue Apr 21, 2020 3:47 pm

adam van gaalen wrote:
Tue Apr 21, 2020 1:22 pm
Now, would it be possible to send the complete (correct) 'isc-dhcp-server' file?

It's easier to replace the faulty file by a correct file than to try to interpret your 'diff-output'.

Thanks in advance,
Adam
you can find the file here: https://pastebin.com/TfG0ijCj (I am not sure what the rules are on the forum on adding large files in posts, and there is no way to attach the file here).

You click 'Download' on that page and the file will be copied to your computer albeit with a different name.

Return to “Networking and servers”