Setup
Intended setup:
<router>----ethernet cable ---<linux PC>
Router IP: 192.168.1.1
(DHCP relay, DHCP Server IP: 192.168.1.2)
Linux PC (hosting the server) Static IP: 192.168.1.2
OS: Debian 12 x86_64
Kea version: Kea 2-6 Debian
Router used: Keenetic (KN-1111)
Quick Summary
Summary of steps taken:
- Get the appropriate kea version for my OS and arch, using the kea docs.
- Create config.
- Enable static ip.
- Configure router.
- Run server.
Steps Taken
kea-dhcp4 config
I created a simplified config (instead of the provided default, which was very long), kea-dhcp4.conf, shown below.
# sources: https://gitlab.isc.org/isc-projects/kea/-/blob/master/doc/examples/kea4/single-subnet.json
# https://kea.readthedocs.io/en/kea-2.6.0/arm/config.html
# The whole configuration starts here.
{
# DHCPv4 specific configuration starts here.
"Dhcp4": {
"interfaces-config": {
"interfaces": [ "eno1" ],
"dhcp-socket-type": "udp"
},
"lease-database": {
"type": "memfile",
"lfc-interval": 3600
},
"valid-lifetime": 4000,
"renew-timer": 1000,
"rebind-timer": 2000,
"subnet4": [{
"pools": [ { "pool": "192.168.1.3-192.168.1.254" } ],
"subnet": "192.168.1.0/24",
"id": 1,
}],
"option-data": [
{
"name": "routers",
"data": "192.168.1.1"
},
{
"name": "domain-name-servers",
"data": "192.168.1.1"
}
],
# Now loggers are inside the DHCPv4 object.
"loggers": [{
"name": "*",
"severity": "INFO"
}]
}
# The whole configuration structure ends here.
}
Static IP
I setup static IP, by editing networks config file located at /etc/network/interfaces
by appending the # The primary network interface
section, as shown below
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eno1
iface eno1 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
and restarting my machine (sudo systemctl restart networking
did not do the trick).
(source: YT video w/ timestamp)
NOTE: Following subsequent machine startup and checking that it has static ip with the output from ip addr
I also had to manually add a dns server (192.168.1.1
) using resolvectl
for complete static ip setup.
Configure router
The router is basically configured to have DHCP relay with IP of 192.168.1.2 specified as DHCP server (as shown in diagram above).
Run server
I then would manually run the server using the following command
sudo /usr/sbin/kea-dhcp4 -p 8002 -c /etc/kea/kea-dhcp4.conf
The reason I specified 8002 port, instead of port 67 is because port 67 results in failure
2024-06-15 23:44:00.962 WARN [kea-dhcp4.dhcpsrv/22486.140139944145984] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: Failed to open socket on interface eno1, reason: Failed to bind socket 13 to 192.168.1.2/port=67
which I don't get with port 8002.
The problem
There seems to be something wrong with the config file, because if I run udhcpd (sudo udhcpd /etc/udhcpd.conf
) instead, with the following config (/etc/udhcpd.conf
) contents,
start 192.168.1.3
end 192.168.1.254
interface eno1
opt router 192.168.1.1
opt dns 192.168.1.1
opt lease 86400
my phone can easily join the network.
I want to use kea because it has options for configuring customm renew and rebind times for dhcp, which doesn't seem to be the case for udhcpd.
My question is, what do you think is wrong with my config given my setup? I don't understand why dhcp server is not working. NOTE: I came up with config mostly via copy-pasta means. I'm a network noob.