How to configure DHCP server on enp1s0f0 on Ubuntu 26.04

On Ubuntu 26.04, use Kea DHCP (kea-dhcp4-server) to run a DHCP server on enp1s0f0. Kea is the standard DHCP daemon and replaces the deprecated isc-dhcp-server.

1. Assign a Static IP to enp1s0f0

The interface must have a static IP address before a DHCP server can run on it. Edit your Netplan configuration file (e.g. /etc/netplan/01-netcfg.yaml):

/etc/netplan/01-netcfg.yaml
network:
  version: 2
  ethernets:
    enp1s0f0:
      dhcp4: false
      addresses:
        - 192.168.1.1/24

Apply the changes:

example.sh
sudo netplan apply

Verification: Run ip addr show enp1s0f0 and verify that inet 192.168.1.1/24 is assigned to the interface.

2. Install Kea DHCP Server

Install the IPv4 Kea DHCP server package:

example.sh
sudo apt update
sudo apt install kea-dhcp4-server -y

Verification: Run systemctl status kea-dhcp4-server to confirm the service was installed.

3. Configure Kea for enp1s0f0

Edit /etc/kea/kea-dhcp4.conf (e.g. using sudo nano /etc/kea/kea-dhcp4.conf) and update the configuration to bind to enp1s0f0 and serve your target subnet:

/etc/kea/kea-dhcp4.conf
{
  "Dhcp4": {
    "interfaces-config": {
      "interfaces": [ "enp1s0f0" ]
    },
    "lease-database": {
      "type": "memfile",
      "lfc-interval": 3600
    },
    "valid-lifetime": 4000,
    "max-valid-lifetime": 7200,
    "subnet4": [
      {
        "id": 1,
        "subnet": "192.168.1.0/24",
        "pools": [ { "pool": "192.168.1.100 - 192.168.1.200" } ],
        "option-data": [
          {
            "name": "routers",
            "data": "192.168.1.1"
          },
          {
            "name": "domain-name-servers",
            "data": "1.1.1.1, 8.8.8.8"
          }
        ]
      }
    ]
  }
}

Verification: Run kea-dhcp4 -t /etc/kea/kea-dhcp4.conf to check the file syntax for errors.

4. Start and Enable the DHCP Service

Restart the Kea daemon to apply the configuration and enable it to start automatically on boot:

example.sh
sudo systemctl restart kea-dhcp4-server
sudo systemctl enable kea-dhcp4-server

Verification: Run sudo ss -ulpn | grep :67 to verify the daemon is listening on UDP port 67.

5. Configure Firewall Rules

If UFW is active, allow incoming DHCP requests on UDP port 67:

example.sh
sudo ufw allow 67/udp

Verification: Run sudo ufw status and verify that 67/udp is listed as allowed.

How to Show DHCP Leases

With the default memfile lease backend, Kea stores all active leases in the CSV file /var/lib/kea/kea-leases4.csv.

View the raw leases file:

example.sh
sudo cat /var/lib/kea/kea-leases4.csv

Or view the leases formatted as a table:

example.sh
sudo column -s, -t /var/lib/kea/kea-leases4.csv

Verification: Compare the expire timestamp column against the current system time (date +%s) to determine which leases are currently active.

References


Check out similar posts by category: Linux Ubuntu Networking