LinuxCommandLibrary

dhcpd

Assign IP addresses to network devices

SYNOPSIS

The command's syntax typically involves specifying options and, optionally, the network interfaces it should listen on:

dhcpd [ options ] [ interface0 [... interfaceN ] ]

Examples of common options include forcing IPv4/IPv6, specifying configuration and lease files, and managing daemonization.

PARAMETERS

-4
    Force `dhcpd` to operate on IPv4 only.

-6
    Force `dhcpd` to operate on IPv6 only.

-p port
    Listen for DHCP requests on a different UDP port instead of the default (67 for IPv4, 547 for IPv6).

-d
    Enable debug mode; log messages to standard error (stderr) in addition to syslog.

-f
    Run `dhcpd` in the foreground instead of daemonizing. Useful for debugging or containerized environments.

-cf config-file
    Specify an alternate configuration file for `dhcpd` to use instead of the default `/etc/dhcp/dhcpd.conf`.

-lf lease-file
    Specify an alternate lease database file to record IP address assignments, instead of the default `/var/lib/dhcp/dhcpd.leases`.

-user user
    Drop privileges to the specified user after startup. Recommended for security.

-group group
    Drop privileges to the specified group after startup. Recommended for security.

-chroot directory
    Change the root directory (`chroot`) after startup, enhancing security by confining the daemon.

-pid-file pid-file
    Specify an alternate PID file to store the process ID of the running daemon.

[interfaces...]
    Specify one or more network interfaces on which `dhcpd` should listen for DHCP requests. If omitted, it typically listens on all available interfaces configured in `dhcpd.conf`.

DESCRIPTION

The `dhcpd` command is the ISC DHCP server daemon for Linux and Unix-like systems. It is responsible for dynamically assigning IP addresses and other network configuration parameters to clients on a network using the Dynamic Host Configuration Protocol (DHCP).

When a DHCP client boots up or connects to the network, it sends a broadcast request for an IP address. `dhcpd` listens for these requests on configured network interfaces. Upon receiving a request, it consults its primary configuration file, `dhcpd.conf`, and its lease database, `dhcpd.leases`, to determine an available IP address and other network settings (such as subnet mask, default gateway, and DNS servers). It then offers this configuration to the client. If the client accepts, `dhcpd` acknowledges the assignment and records the lease in its database.

It supports both IPv4 and IPv6 operations, making it a versatile and essential service for automated network management, reducing manual configuration efforts and preventing IP address conflicts.

CAVEATS

  • `dhcpd` requires root privileges to start and bind to privileged ports (UDP 67/547). It's best practice to drop privileges to a less privileged user/group after startup.
  • The `dhcpd.conf` configuration file can be complex; syntax errors will prevent the daemon from starting. Always validate configuration before restarting.
  • Only one instance of `dhcpd` should manage a given IP address pool to prevent conflicts and ensure consistent lease management.
  • The `dhcpd.leases` file is critical for tracking assigned IPs and must be protected from corruption and unauthorized access. Regularly back it up.
  • Proper firewall rules are essential to restrict DHCP traffic to only necessary interfaces and ensure network security.

DHCP LEASE MANAGEMENT

DHCP leases are temporary assignments of IP addresses to clients. `dhcpd` diligently tracks these leases in its `dhcpd.leases` file, recording details such as the assigned IP, MAC address of the client, lease start time, and expiration time. This allows the server to manage the IP address pool effectively, renewing leases for active clients, reassigning expired addresses, and preventing address conflicts. The lease file is crucial for the server's operation and state persistence across restarts.

THE DORA PROCESS

`dhcpd` orchestrates IP address assignment through the DORA process (Discover, Offer, Request, Acknowledge).

  • Discover: Client broadcasts to find a DHCP server.
  • Offer: `dhcpd` responds with an available IP address and configuration.
  • Request: Client formally requests the offered IP.
  • Acknowledge: `dhcpd` confirms the assignment, completing the lease process.
This sequence ensures reliable and dynamic IP allocation.

HISTORY

The Internet Systems Consortium (ISC) DHCP server, implemented by `dhcpd`, has a long and significant history in the open-source networking world. Developed by ISC, a non-profit organization dedicated to supporting the Internet infrastructure, it has been a cornerstone for dynamic IP address management since its early versions in the 1990s. Its continuous development has seen the integration of features like IPv6 support, failover capabilities, and robust lease management, establishing it as one of the most widely deployed and reliable DHCP server implementations across various Unix and Linux distributions. Its open-source nature has contributed to its widespread adoption and community support.

SEE ALSO

dhclient(8), dhcpd.conf(5), dhcpd.leases(5), systemctl(1), ip(8)

Copied to clipboard