This guide will go over installing ISC dhcpd
and using a custom systemd
service for both v4 and v6 services (instead of the included one).
Install with APT
apt install isc-dhcp-server
Disable and Mask the included systemd
service file
systemctl stop isc-dhcp-server.service && \
systemctl disable isc-dhcp-server.service && \
systemctl mask isc-dhcp-server.service
Create a new systemd
service for dhcpd v4
bash -c "cat > /etc/systemd/system/dhcpd-v4.service"<<'EOF'
[Unit]
Description=ISC DHCPv4 Server Daemon
Documentation=man:dhcpd(8) man:dhcpd.conf(5)
Wants=network-online.target
After=network-online.target
After=time-sync.target
[Service]
Type=exec
Restart=on-failure
RestartSec=60
User=root
Group=root
ExecStart=/usr/sbin/dhcpd -4 -f -cf /etc/dhcp/dhcpd.conf --no-pid $DHCPARGS
StandardError=null
[Install]
WantedBy=multi-user.target
EOF
Reload and start the v4 dhcpd
service
systemctl daemon-reload && \
systemctl enable --now dhcpd-v4.service
Create a new systemd
service for dhcpd v4
bash -c "cat > /etc/systemd/system/dhcpd-v6.service"<<'EOF'
[Unit]
Description=ISC DHCPv6 Server Daemon
Documentation=man:dhcpd(8) man:dhcpd.conf(5)
Wants=network-online.target
After=network-online.target
After=time-sync.target
[Service]
Type=exec
Restart=on-failure
RestartSec=60
User=root
Group=root
ExecStart=/usr/sbin/dhcpd -6 -f -cf /etc/dhcp/dhcpd6.conf --no-pid $DHCPARGS
StandardError=null
[Install]
WantedBy=multi-user.target
EOF
Reload and start the v6 dhcpd
service
systemctl daemon-reload && \
systemctl enable --now dhcpd-v6.service
To use two dhcpd
servers in an Active-Active configuration.
Configuration
Add firewall rules to allow the two hosts to talk to one another. Don't forget to do the same on the other server, with the opposite IP source address.
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=172.16.5.10/32 port port=7911 protocol=tcp accept' --zone=public
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=172.16.5.10/32 port port=520 protocol=tcp accept' --zone=public
firewall-cmd --reload
Optionally, route all dhcpd
logs to a dedicated log file
bash -c "cat > /etc/rsyslog.d/50-dhcpd.conf"<<'EOF'
# Log dhcpd log messages to file
if $programname == 'dhcpd' then /var/log/dhcpd.log
EOF
Restart rsyslog
systemctl restart rsyslog.service