charleslinquist
Posts: 112
Joined: Wed Sep 05, 2012 12:43 pm

dhcpcd hangs

Sun Apr 07, 2019 7:35 pm

I have written on this before, but so far none of the suggestions have worked. During boot, my Raspberry reports

A dhcpd start job is running on all interfaces (xx sec / 120 sec) and "xx" counts up, once per second. After a few seconds, some more drivers load and the message again appears :
A dhcpd start job is running on all interfaces (yy sec / 120 sec). Here, "yy" starts where the previous "xx" left off.
Some more drivers load -
Then I again get the message:
A dhcpd start job is running on all interfaces (zz sec / 120 sec). When "zz" reaches 20-23 seconds), the program hangs - forever.

Nothing but a CTL-ALT-DEL or power cycle will recover. If I reboot the Raspberry, it will usually work (finish booting) on the second try - but not always. If it completes the boot process, the network connection is always made.

I cannot use a static ip in this application.
The source of the network connection takes from 50 - 80 sec to come up and it is booted at the same time as the Raspberry.

So, I have a few questions:

I cannot determine where the message is coming from. I did a grep to look for the msg and couldn't find it. So what program is generating the "A start job ...."?

Is there a way I could delay dhcpcd for awhile? It looks like dhcpcd is started from several run levels (hence the multiple messages), but STRETCH doesn't appear to have an "rc.d" file that fires off the various rcx.d tasks. Which file does that?

Why is it hanging in the first place? Shouldn't it just go on? Could it be that dhcpcd is getting part of the network information (ip assignment), but not other things such as the gateway, etc - and that is causing it to hang?

Is there a way to add a timeout, so that if dhcpcd fails, it doesn't just hang?

User avatar
default_user8
Posts: 680
Joined: Mon Nov 18, 2013 3:11 am

Re: dhcpcd hangs

Sun Apr 07, 2019 9:22 pm

A google search found this page:
https://wiki.archlinux.org/index.php/dhcpcd

Scroll down to "timeout delay" if you are booting your router at the same time, your pi is just asking for it's ip address before the router is ready to hand it out.
Two heads are better than one, unless one's a goat head.

charleslinquist
Posts: 112
Joined: Wed Sep 05, 2012 12:43 pm

Re: dhcpcd hangs

Mon Apr 08, 2019 3:26 pm

The switches for Raspbian are a little different than Arch. I have it working better, but I would like to delay the actual invocation of dhcpcd. That is - wait until the first attempt to run.

I would like to change the boot order, so that dhcpcd is not started until much later in the boot process but I can't find the file that contains all that information.

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

Re: dhcpcd hangs

Mon Apr 08, 2019 7:15 pm

Another approach that might work for you is to simply stop using dhcpcd altogether and use systemd-networkd. It will still use wpa_supplicant, so all the wireless configuration details are the same. If any additional network configuration (IP Address, etc) is required for any networking interfaces, see https://www.freedesktop.org/software/sy ... twork.html for details. The config files are in /etc/systemd/network and are named something.network. Here are some simple examples that use DHCP:

Code: Select all

(This is my /etc/systemd/network/10-eth0.network)

[Match]
Name=eth0

[Network]
DHCP=Yes
LinkLocalAddressing=no
IPv4LL=false
#IPv6LL=false
# to use static IP uncomment these instead of DHCP
#Address=192.168.1.201/24
#Gateway=192.168.1.1
#DNS=192.168.1.1
#Domains=mydomain.com
#NTP=192.168.1.1

Code: Select all

(This is my /etc/systemd/network/11-wlan0.network)

[Match]
Name=wlan0

[Network]
DHCP=ipv4
IPv6AcceptRA=no
LinkLocalAddressing=no
# to use static IP uncomment these instead of DHCP
#Address=192.168.1.87/24
#Gateway=192.168.1.1
#DNS=192.168.1.1
#Domains=mydomain.com
#NTP=192.168.1.1

[DHCP]
RouteMetric=20
UseDomains=yes

To switch from dhcpcd to systemd-networkd:

Code: Select all

sudo systemctl disable dhcpcd
sudo systemctl enable systemd-network
sudo systemctl enable wpa_supplicant@wlan0  
sudo reboot
Pi tools:
Quickly and easily build customized-just-for-you SD Cards: https://github.com/gitbls/sdm
Easily run your network's DHCP/DNS on a Pi: https://github.com/gitbls/ndm
Easy strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

charleslinquist
Posts: 112
Joined: Wed Sep 05, 2012 12:43 pm

Re: dhcpcd hangs

Mon Apr 08, 2019 7:48 pm

Thanks, but I am NOT using wireless at all. In fact, I have disabled wifi and bluetooth altogether. My application is Ethernet over USB (my network presents itself as ETH1 - or ETH0 in the case of a Raspberry Pi 3A+). I'll try your suggestions.

charleslinquist
Posts: 112
Joined: Wed Sep 05, 2012 12:43 pm

Re: dhcpcd hangs

Mon Apr 08, 2019 7:50 pm

And how do I stop using dhcpcd altogether? It runs automatically. Would I have to use systemctl and disable the service?

charleslinquist
Posts: 112
Joined: Wed Sep 05, 2012 12:43 pm

Re: dhcpcd hangs

Mon Apr 08, 2019 7:50 pm

Nevermind... I see where you disabled dhcpcd.

charleslinquist
Posts: 112
Joined: Wed Sep 05, 2012 12:43 pm

Re: dhcpcd hangs

Mon Apr 08, 2019 9:12 pm

I can't win for losing! Your suggestion works great - except now I have two more issues.... my Ethernet connection comes up much more slowly than the Raspberry, so I sit in a loop and ping a server every two seconds (in rc.local). When I get a good ping, I load autoSSH. All network functions worked - as long as dhcpcd didn't hang.

But I now notice there are a couple of other programs (uv4L for one) that used to automatically load, but no longer do. I'll have to disable their automatic startup and put them in rc.local to see if loading them after a successful ping makes them work again.

I suspect they see no network and quit trying to load.

Return to “Networking and servers”