0

I using Raspbery pi zero w.

my dhcpcd.service always fail, I do not know the reason: my linux is:

PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

My dhcpcd.service status:

root@raspberrypi:/var/lib/dhcpcd5# systemctl status dhcpcd.service
● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2020-10-08 01:12:21 BST; 5 days ago
  Process: 284 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -b (code=exited, status=6)  #####dhcpcd service failed.

Oct 08 01:12:18 raspberrypi systemd[1]: Starting dhcpcd on all interfaces... Oct 08 01:12:18 raspberrypi dhcpcd[284]: Not running dhcpcd because /etc/network/interfaces Oct 08 01:12:18 raspberrypi dhcpcd[284]: defines some interfaces that will use a Oct 08 01:12:18 raspberrypi dhcpcd[284]: DHCP client or static address Oct 08 01:12:21 raspberrypi systemd[1]: dhcpcd.service: Control process exited, code=exited, status= Oct 08 01:12:21 raspberrypi systemd[1]: dhcpcd.service: Failed with result 'exit-code'. Oct 08 01:12:21 raspberrypi systemd[1]: Failed to start dhcpcd on all interfaces.

My /etc/network/interfaces

iface lo inet loopback

auto wlan0 allow-hotplug wlan0 iface wlan0 inet dhcp pre-up wpa_supplicant -B -Dwext -i wlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf post-down killall -q wpa_supplicant

auto usb0 allow-hotplug usb0 iface usb0 inet auto

I do not change dhcpcd.conf

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

Allow users of this group to interact with dhcpcd via the control socket.

#controlgroup wheel

Inform the DHCP server of our hostname for DDNS.

hostname

Use the hardware address of the interface for the Client ID.

clientid

or

Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.

Some non-RFC compliant DHCP servers do not reply with this set.

In this case, comment out duid and enable clientid above.

#duid

Persist interface configuration when dhcpcd exits.

persistent

Rapid commit support.

Safe to enable by default because it requires the equivalent option set

on the server to actually work.

option rapid_commit

A list of options to request from the DHCP server.

option domain_name_servers, domain_name, domain_search, host_name option classless_static_routes

Respect the network MTU. This is applied to DHCP routes.

option interface_mtu

Most distributions have NTP support.

#option ntp_servers

A ServerID is required by RFC2131.

require dhcp_server_identifier

Generate SLAAC address using the Hardware Address of the interface

#slaac hwaddr

OR generate Stable Private IPv6 Addresses based from the DUID

slaac private

Example static IP configuration:

#interface eth0 #static ip_address=192.168.0.10/24 #static ip6_address=fd51:42f8:caae:d92e::ff/64 #static routers=192.168.0.1 #static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1

It is possible to fall back to a static IP if DHCP fails:

define static profile

#profile static_eth0 #static ip_address=192.168.1.23/24 #static routers=192.168.1.1 #static domain_name_servers=192.168.1.1

fallback to static profile on eth0

#interface eth0

It seems it execute

dhcpcd -q -b

and then fails. I can execute this command manually, but when I try to run service it failed.

root@raspberrypi:/etc# sysctemctl restart dhcpcd.service
-bash: sysctemctl: command not found
root@raspberrypi:/etc# systemctl restart dhcpcd.service
Job for dhcpcd.service failed because the control process exited with error code.
See "systemctl status dhcpcd.service" and "journalctl -xe" for details.
root@raspberrypi:/etc# dhcpcd
dev: loaded udev
wlan0: connected to Access Point `Accept'
DUID 00:01:00:01:26:d1:12:f4:b8:27:eb:e7:9a:7d
usb0: IAID 07:f0:38:78
wlan0: IAID eb:e7:9a:7d
wlan0: soliciting an IPv6 router
usb0: soliciting an IPv6 router
wlan0: rebinding lease of 10.125.132.171
wlan0: leased 10.125.132.171 for 10800 seconds
wlan0: adding route to 10.125.128.0/20
wlan0: adding default route via 10.125.128.1
forked to background, child pid 2066

You can see the dhcpcd can run manually but when it in service it failed.

root@raspberrypi:/etc# journalctl -xe
Oct 13 01:49:43 raspberrypi systemd[1]: Starting dhcpcd on all interfaces...
-- Subject: A start job for unit dhcpcd.service has begun execution
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit dhcpcd.service has begun execution.
--
-- The job identifier is 1107.
Oct 13 01:49:43 raspberrypi dhcpcd[2082]: Not running dhcpcd because /etc/network/interfaces
Oct 13 01:49:43 raspberrypi dhcpcd[2082]: defines some interfaces that will use a
Oct 13 01:49:43 raspberrypi dhcpcd[2082]: DHCP client or static address
Oct 13 01:49:43 raspberrypi systemd[1]: dhcpcd.service: Control process exited, code=exited, status=
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- An ExecStart= process belonging to unit dhcpcd.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 6.
Oct 13 01:49:43 raspberrypi systemd[1]: dhcpcd.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- The unit dhcpcd.service has entered the 'failed' state with result 'exit-code'.
Oct 13 01:49:43 raspberrypi systemd[1]: Failed to start dhcpcd on all interfaces.
-- Subject: A start job for unit dhcpcd.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit dhcpcd.service has finished with a failure.
--
-- The job identifier is 1107 and the job result is failed.
Oct 13 01:49:46 raspberrypi dhcpcd[2084]: dhcpcd not running

and the service file is:

root@raspberrypi:/etc/systemd/system# ls
autologin@.service                      display-manager.service      rc-local.service.d
bluetooth.target.wants                  getty.target.wants           reboot.target.wants
dbus-fi.w1.wpa_supplicant1.service      getty@tty1.service.d         remote-fs.target.wants
dbus-org.bluez.service                  graphical.target.wants       sockets.target.wants
dbus-org.freedesktop.Avahi.service      halt.target.wants            sshd.service
dbus-org.freedesktop.timesync1.service  multi-user.target.wants      sysinit.target.wants
default.target                          network-online.target.wants  syslog.service
dhcpcd5.service                         poweroff.target.wants        timers.target.wants
root@raspberrypi:/etc/systemd/system# cat dhcpcd5.service
[Unit]
Description=dhcpcd on all interfaces
Wants=network.target
Before=network.target

[Service] Type=forking PIDFile=/run/dhcpcd.pid ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -b ExecStop=/sbin/dhcpcd -x

[Install] WantedBy=multi-user.target Alias=dhcpcd5.service

I think dhcpcd5 is dhcpcd service, do not know where it change name. How to fix it make dhcpcd service running correctly.

user504909
  • 103
  • 1
  • 2
  • And for the dhcpcd5.service. If you type ls -layou will see that it is a link dhcpcd5.service -> /lib/systemd/system/dhcpcd.service – Mats Karlsson Oct 13 '20 at 06:32

1 Answers1

0

The reason it "fails" is because you caused dhcpcd to disable itself by including dhcp in /etc/network/interfaces.

You can only have ONE DHCP client

The error is listed in your Question:-

Oct 08 01:12:18 raspberrypi dhcpcd[284]: Not running dhcpcd because /etc/network/interfaces
Oct 08 01:12:18 raspberrypi dhcpcd[284]: defines some interfaces that will use a
Oct 08 01:12:18 raspberrypi dhcpcd[284]: DHCP client or static address

If you delete /etc/network/interfaces (which presumably you added for some reason) it would work; indeed it should work on a fresh installation if you don't modify anything.

See How to set up networking/WiFi

Milliways
  • 59,890
  • 31
  • 101
  • 209