Kea - ArchWiki

Jump to content

# Kea

From ArchWiki

Related articles

- Network configuration
- Network tools
- dhcpcd

Kea DHCP is the current Dynamic Host Configuration Protocol server of the Internet Systems Consortium (ISC).

Note: The older dhcpd is end of life .

## Installation

Install the kea package. For additional documentation install kea-docs.

Optional dependencies are:

- krb5 for Kerberos support
- mariadb as database backend
- postgresql as database backend
- python to use Kea Shell

## Configuration

The configuration files are located under `/etc/kea`. The content of the configuration files uses JSON structures. For special configurations that are not yet included in the following examples, please refer to the Kea documentation.

### IPv4 DHCP

To use DHCP for IPv4, the configuration file `/etc/kea/kea-dhcp4.conf` must be adapted and the service `kea-dhcp4.service` must be activated and started.

Tip: The following subnets are reserved for private networks, and will not conflict with hosts on the Internet:

- `192.168.0.0/16` – subnet `192.168.0.0`, netmask `255.255.0.0`
- `172.16.0.0/12` – subnet `172.16.0.0`, netmask `255.240.0.0`
- `10.0.0.0/8` – subnet `10.0.0.0`, netmask `255.0.0.0`

Make sure to assign a static IP address to the interface on which Kea is listen on.

#### Example single subnet configuration

Assumptions for the example:

- The net is `192.168.0.0/24`
- DNS server has the IP `192.168.0.1/24`
- Gateway has the IP `192.168.0.254/24`
- Static IP of the DHCP server network interface `eth0` is `192.168.0.253/24`
- Kea should provide IPs from `192.168.0.100/24` to `192.168.0.199/24`

A minimal configuration file `/etc/kea/kea-dhcp4.conf` could look like:

    /etc/kea/kea-dhcp4.conf

    {
        "Dhcp4": {
            "interfaces-config": {
                "interfaces": [ "eth0/192.168.0.253" ],
                "dhcp-socket-type": "raw"
            },

            "subnet4": [
                {
                    "id": 1,
                    "subnet": "192.168.0.0/24",
                    "pools": [ { "pool": "192.168.0.100 - 192.168.0.199" } ],
                    "option-data": [
                        {
                            "name": "routers",
                            "data": "192.168.0.254"
                        },
                        {
                            "name": "domain-name-servers",
                            "data": "192.168.0.1"
                        }
                    ]
                }
            ]
        }
    }

#### Example multiple subnet configuration

Assumptions for the example:

- The networks are:
  - Network 1: `192.168.0.0/24` (is a standard physical network)
  - Network 2: `192.168.1.0/24` (is a virtual VLAN network)
- DNS servers are:
  - Network 1 hosts it's own DNS server at IP: `192.168.0.1`
  - Network 2 uses upstream Google DNS: `8.8.8.8` & `8.8.4.4`
- Gateways are:
  - Network 1: `192.168.0.254/24`
  - Network 2: `192.168.1.254/24`
- Static IP of the DHCP servers are:
  - Network 1: network interface `eth0` is `192.168.0.253`
  - Network 2: network interface `eth0.100` is `192.168.1.253`
- Kea should provide IPs:
  - Network 1: from `192.168.0.100/24` to `192.168.0.199/24`
  - Network 2: from `192.168.1.2/24` to `192.168.1.252/24`
- You have a couple of static IPs defined:
  - Network 1: Has two special phones with static leases `192.168.0.10` && `192.168.0.11`
- You want to enable maximum debug logging for IPv4 in order to troubleshoot any problems with IP reservation

A more complex configuration file `/etc/kea/kea-dhcp4.conf` could look like:

    /etc/kea/kea-dhcp4.conf

    {
        "Dhcp4": {
            "interfaces-config": {
                "interfaces": [ "eth0/192.168.0.253", "eth0.100/192.168.1.253" ],
                "dhcp-socket-type": "raw"
            },
            "loggers": [
              {
                "name": "kea-dhcp4",
                "severity": "DEBUG",
                "debuglevel": 99,
                "output_options": [
                  {
                    "output": "stdout"
                  }
                ]
              }
            ],
            "subnet4": [
                {
                    "id": 1,
                    "subnet": "192.168.0.0/24",
                    "interface": "eth0",
                    "pools": [ { "pool": "192.168.0.100 - 192.168.0.199" } ],
                    "option-data": [
                        {
                            "name": "routers",
                            "data": "192.168.0.254"
                        },
                        {
                            "name": "domain-name-servers",
                            "data": "192.168.0.1"
                        }
                    ],
                    "reservations": [
                    {
                        "hostname": "phone1",
                        "hw-address": "1a:1b:1c:1d:1e:1f",
                        "ip-address": "192.168.0.10"
                    },
                    {
                        "hostname": "phone2",
                        "client-id": "01:11:22:33:44:55:66",
                        "ip-address": "192.168.0.11"
                    }
                ]
                },
                {
                    "id": 2,
                    "subnet": "192.168.1.0/24",
                    "interface": "eth0.100",
                    "pools": [ { "pool": "192.168.1.2 - 192.168.1.252" } ],
                    "option-data": [
                        {
                            "name": "routers",
                            "data": "192.168.1.254"
                        },
                        {
                            "name": "domain-name-servers",
                            "data": "8.8.8.8, 8.8.4.4"
                        }
                    ]
                }
            ]
        }
    }

Note: This example uses Google Public DNS. Replace it with a DNS resolver you trust. See Domain name resolution#Third-party DNS services.

## Usage

Kea includes four systemd unit files:

Unit file | Manual page | Description
--- | --- | ---
kea-dhcp4.service | kea-dhcp4(8) | The DHCPv4 daemon
kea-dhcp6.service | kea-dhcp6(8) | The DHCPv6 daemon
kea-dhcp-ddns.service | kea-dhcp-ddns(8) | The DNS update daemon
kea-ctrl-agent.service | keactrl(8) | Exposing a REST interface for managing Kea servers

The configuration file for DHCPv4 can be checked for errors by running the command:

    # kea-dhcp4 -t /etc/kea/kea-dhcp4.conf

If everything looks good, then you can enable/start `kea-dhcp4.service`.

Category:

- DHCP