ISC DHCP Server on Linux: dhcpd.conf Configuration Guide - 夜莺博客

ISC DHCP Server on Linux: dhcpd.conf Configuration Guide

While home routers hide DHCP behind a web page, running a dedicated ISC DHCP server on Linux gives you precise control: multiple address pools per subnet, static reservations, custom options such as NTP and PXE boot, and failover between two servers. The entire configuration lives in /etc/dhcp/dhcpd.conf, and the workflow is always the same - install, bind to the LAN interface, declare subnets and reservations, test with dhcpd -t, and start the service. This guide walks through a production-style configuration on Ubuntu/Debian with notes for RHEL-family systems.

Install and Bind to the Right Interface

sudo apt update && sudo apt install isc-dhcp-server    # Debian/Ubuntu
sudo dnf install dhcp-server                           # RHEL/Rocky

On Debian/Ubuntu tell dhcpd which interface to listen on in /etc/default/isc-dhcp-server:

INTERFACESv4="eth1"

Basic dhcpd.conf with Subnet and Range

# /etc/dhcp/dhcpd.conf
default-lease-time 86400;      # 24 hours
max-lease-time 604800;         # 7 days
authoritative;                 # send DHCPNAK for foreign ranges
option domain-name "home.local";
option domain-name-servers 192.168.1.1, 1.1.1.1;

subnet 192.168.1.0 netmask 255.255.255.0 {
    range 192.168.1.100 192.168.1.200;
    option routers 192.168.1.1;
    option broadcast-address 192.168.1.255;
    option subnet-mask 255.255.255.0;
}

authoritative; makes the server reply with DHCPNAK when a client requests an address outside its subnets - include it or stale leases survive forever. Multiple range statements inside one subnet create separate pools.

Static Reservations with host Blocks

host printer-main {
    hardware ethernet AA:BB:CC:DD:EE:02;
    fixed-address 192.168.1.20;
}
host web-server {
    hardware ethernet AA:BB:CC:DD:EE:10;
    fixed-address 192.168.1.10;
    option host-name "web-server";
}

Validate, Start and Manage Leases

sudo dhcpd -t -cf /etc/dhcp/dhcpd.conf   # syntax check - always run this first
sudo systemctl enable --now isc-dhcp-server
sudo systemctl status isc-dhcp-server
cat /var/lib/dhcp/dhcpd.leases           # active leases
sudo dhcp-lease-list                     # human-readable view (if installed)

For high availability, two servers can share a failover peer declaration with mclt 1800; split 128;, and each pool then uses pool { failover peer "dhcp-failover"; range ...; }. Note that ISC DHCP is in maintenance mode - new deployments should evaluate its successor Kea - but dhcpd remains the default on Ubuntu and is perfectly fine for small-to-medium networks.

Related Guides on This Site

See the router side of DHCP in Cisco IOS DHCP pools and exclusions and ip helper-address DHCP relay, or secure the L2 path with DHCP snooping.

原文链接:https://ubuntu.com/server/docs/how-to/networking/install-isc-dhcp-server