Network

The dhcpd command

ISC DHCP server: hands out IP addresses on the network. With -t it checks the config.

Syntax

sudo dhcpd [-t] [-cf /etc/dhcp/dhcpd.conf]Try it in the terminal →

Most useful options

-tChecks the syntax of the configuration file and exits, with no network operations.
-TChecks the lease file without modifying the current one: it uses a temporary copy and deletes it afterwards.
-cf ficheroUses another configuration file instead of the default one.
-lf ficheroUses another lease file. For tests: never point a production server at a test file.
-p puertoUDP port it listens on. The default is 67; changing it is mostly useful for debugging.
-fRuns in the foreground instead of as a daemon. Useful under a debugger.
-dSends the log messages to the standard error. Implies -f.
-qDoes not print the copyright text at startup.

Copy-ready examples

$ sudo dhcpd -tvalidates the default configuration file before touching anything.
$ sudo dhcpd -t -cf /etc/dhcp/dhcpd-nuevo.confvalidates another file without changing the one the server uses.
$ sudo dhcpd -T -lf /var/lib/dhcp/dhcpd.leaseschecks the lease file. The original is not modified.
$ sudo dhcpd -f -d -cf /etc/dhcp/dhcpd.confwarning: starts the server in the foreground and keeps the terminal busy until you stop it. If the service is already running, stop it first so you do not run two servers.

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • The configuration lives in /etc/dhcp/dhcpd.conf; the range is set with range inside the subnet block.
  • -t only checks the syntax. A valid file does not guarantee that the server hands out IPs: that is tested with a real client.
  • ISC announced the end of maintenance for ISC DHCP at the end of 2022 and recommends Kea. The Debian manual does not mark it as obsolete.

Differences from similar commands

  • dhclient: is the client: it asks for an IP. dhcpd is the server that hands it out.
  • named-checkconf: validates the configuration of BIND (DNS), not DHCP. It follows the same approach as -t: check without starting the service.

Related commands

FAQ

Where is the IP range defined?

In /etc/dhcp/dhcpd.conf, inside the subnet block, with the range directive.

How do I apply changes?

Validate with sudo dhcpd -t and restart with sudo systemctl restart isc-dhcp-server.

What is -T for if I already have -t?

-t checks the configuration file; -T checks the lease file without modifying the current one.

Is ISC DHCP still a valid choice for a new server?

ISC no longer maintains it: it announced the end of maintenance at the end of 2022 and recommends Kea for new servers.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course