首页 > Sysadmin > 正文

Linux Check DHCP Service Status: 5 Commands

2026-11-04 Sysadmin

Not fully verified: the systemctl / journalctl / networkctl commands below were tested on WSL Ubuntu 24.04; the parts touching real DHCP server operations are based on documentation review and have not been executed in production.

DHCP is both a client and a server on Linux. dhcpcd is the default DHCP client daemon on Ubuntu/Debian, responsible for requesting and renewing IP addresses[4]. Before checking status, confirm whether you manage the client or the server — the unit names differ.

—

1. systemctl status: detailed state

systemctl status is the most common state inspection command. Client and server use different unit names:

# Client (default on Ubuntu/Debian)
sudo systemctl status dhcpcd

# Server side (common on RHEL/CentOS)
sudo systemctl status dhcpd

Three lines matter in the output: whether Loaded reports an error, whether Active is active (running) or inactive, and whether Main PID exists. If it shows Unit dhcpcd.service could not be found, the package did not install a systemd unit file, only the binary. RHEL/CentOS documentation gives similar guidance for dhcpd systemctl start and status checks[5].

WSL test result: systemctl status dhcpcd returned Unit dhcpcd.service could not be found, consistent with the documentation[1].

2. systemctl is-active: quick check

If you only need to know whether the service is running, use is-active:

systemctl is-active dhcpcd
systemctl is-active dhcpd

The return value is only active, inactive, failed, or unknown — handy for scripts.

3. journalctl -u: read logs

When the unit exists, filter its logs with journalctl:

# Last 10 log lines
journalctl -u dhcpcd -n 10

# Follow new logs live
journalctl -u dhcpcd -f

If the unit does not exist, it returns -- No entries --[2]. On WSL, journalctl -u dhcpcd produces exactly this.

4. networkctl status: lease info

networkctl belongs to the systemd-networkd stack and shows an interface’s DHCP lease summary directly:

networkctl status eth0

The DHCP lease section lists client address, server address, lease time, and so on. This command depends on systemd-networkd running; on WSL, systemd-networkd was not started, so some fields show n/a[3].

5. Troubleshooting quick reference

Symptom Common cause Fix
Unit ... could not be found Unit file not installed apt install dhcpcd or the matching server package
inactive / disabled Service not enabled or started sudo systemctl enable --now dhcpcd
failed Config syntax error or conflict journalctl -u dhcpcd -n 50 to see the error
networkctl shows n/a systemd-networkd not running sudo systemctl enable --now systemd-networkd
Service running but no IP NIC / virtual NIC has no carrier ip link show eth0 to check state

Limitations

  • WSL2’s hv_netvsc NIC is unmanaged, so systemd-networkd does not take it over and networkctl status eth0 shows unmanaged, unable to fully display the DHCP lease flow.
  • Real DHCP server scenarios (startup failure, lease conflicts, subnet conflicts) need validation on a physical or virtual machine with real client requests; not covered by this WSL run.
  • Non-systemd distros (SysVinit, OpenRC) have no systemctl; use service or /etc/init.d/ commands instead.

References

Major commands in this article were tested on WSL Ubuntu (24.04) and checked against Debian-family and general distro documentation.