User:Redsandbluesea/kea

From ArchWiki

kea is an open source implementation of the Dynamic Host Configuration Protocol (DHCP) server, developed and maintained by Internet Systems Consortium (ISC). It replaces dhcpd which is end-of-life.

Installation

Install the kea package.

Usage

The kea package includes three unit files, kea-dhcp4.service, kea-dhcp6.service and kea-dhcp-ddns.service which can be used to control the daemons.

By default the kea-dhcp4.service and kea-dhcp6.service do NOT start the daemon on any network interfaces for IPv4 and IPv6 respectively, the listening interface and optionally the listening subnet must first be configured.

The kea-dhcp-ddns.service can used to configure Dynamic DNS updates to a nameserver based on DHCP lease-change events.

Configuration

The default location for the kea configuration files is in /etc/kea/

Assign a static IPv4 address to the interface you want kea to listen on eth0 in this example.

# ip link set up dev eth0
# ip addr add 198.51.100.254/24 dev eth0
Tip: To have a static IP address assigned at boot, see Network configuration#Static IP address.
Tip: The following subnets are reserved for private networks and will not conflict with hosts on the internet:
  • 192.168/16 (subnet 192.168.0.0, netmask 255.255.0.0)
  • 172.16/12 (subnet 172.16.0.0, netmask 255.240.0.0)
  • 10/8 (for large networks; subnet 10.0.0.0, netmask 255.0.0.0)
See also RFC 1918.
/etc/kea/kea-dhcp4.conf
{
"Dhcp4": {
    "interfaces-config": {
        "interfaces": [ "eth0" ]
    },

    "lease-database": {
        "type": "memfile",
        "persist": true,
        "name": "/var/lib/kea/dhcp4.leases"
    },

    # Global timers specified here apply to all subnets, unless there are
    # subnet specific values defined in particular subnets.
    # Defines the length in seconds of the client lease.
    "valid-lifetime": 3600,

    "subnet4": [
        {
            "subnet": "198.51.100.0/24",
            "pools": [ { "pool": "198.51.100.1 - 198.51.100.199" } ],
            "option-data": [
                {"name": "routers", "data":"198.51.100.254"},
                {"name": "domain-name-servers", "data":"198.51.100.252, 192.51.100.253"},
                {"name": "domain-search", "data": "internal.test"} ],
            "reservations" : [
                {"hw-address": "00:53:00:11:22:33",
                "ip-address": "198.51.100.200"},
                {"hw-address": "00:53:00:44:55:66",
                "ip-address": "198.51.100.201",
                "hostname": "lemon"}
            ]
        }
    ]
}
}

interfaces Define the device that kea will use to listen of DHCP requests, to listen on all interfaces use "interfaces": ["*"]

lease-database Defines the location of the CSV file that contains the client leases.

pool Defines the range of addresses served to clients, in this case 200 addresses from .1 to .200

routers Set the router or gateway ip address by which clients reach the internet, this address must be within the same subnet as the client.

domain-name-servers Defines the DNS servers which clients will use to resolve domains names to ip addresses. These can also be public DNS servers such as Google's Public DNS 8.8.8.8 or Cloudflare's Public DNS 1.1.1.1

domain-search Defines the domain name that clients will use when the fully qualified domain name is omitted, see local domain names

reservations Using a MAC address you can assign an ip address from the subnet to the client, in the second example the hostname lemon is also set for the client.