Import DHCP reservations from Synology DHCP Server to OpenBSD dhcpd(8)
139 words, 1 minutes
I am migrating a bunch of services from my Synology to OpenBSD ; DHCP Server being one of them. I have configured quite a few DHCP reservations over time. And I would like a better way to migrate them to dhcpd(8) than copy & paste ; or rewrite from scratch.
Synology DSM seem to use dnsmasq as a DHCP Server. The configuration file containing static leases is located in /etc/dhcpd/dhcpd.conf.
On OpenBSD, transfer the Synology dnsmasq configuration file and create an /etc/dhcpd.conf(5) file configured for your subnet. If vi(1) is used for the edition, place the cursor where the static leases should be inserted and issue :
:r!awk -F '[=,]' '/^dhcp-host=/ { \
print "\thost " $3 " {\n\t\thardware ethernet " \
$2 ";\n\t\tfixed-address " \
$4 ";\n\t}\n" }' \
/tmp/syno-dhcpd.conf
Et voilà. Tens of reservations imported in milliseconds.