From 4b0b8adcddda60b40a712b9e064385d218d0f058 Mon Sep 17 00:00:00 2001 From: Markus Hauschild Date: Tue, 28 May 2024 17:48:42 +0200 Subject: [PATCH] kea: add ddns support --- roles/kea/handlers/main.yml | 3 ++ roles/kea/tasks/main.yml | 12 +++++- roles/kea/templates/kea/kea-dhcp-ddns.conf.j2 | 38 +++++++++++++++++++ roles/kea/templates/kea/kea-dhcp4.conf.j2 | 19 ++++++++++ 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 roles/kea/templates/kea/kea-dhcp-ddns.conf.j2 diff --git a/roles/kea/handlers/main.yml b/roles/kea/handlers/main.yml index fbd6145..7c33b95 100644 --- a/roles/kea/handlers/main.yml +++ b/roles/kea/handlers/main.yml @@ -3,5 +3,8 @@ - name: Restart kea-dhcp4-server service: name=kea-dhcp4-server state=restarted +- name: Restart kea-dhcp-ddns-server + service: name=kea-dhcp-ddns-server state=restarted + - name: Restart kea-ctrl-agent service: name=kea-ctrl-agent state=restarted diff --git a/roles/kea/tasks/main.yml b/roles/kea/tasks/main.yml index 5ce8a17..3fc21e5 100644 --- a/roles/kea/tasks/main.yml +++ b/roles/kea/tasks/main.yml @@ -14,9 +14,19 @@ # validate: kea-dhcp4 -t %s notify: Restart kea-dhcp4-server -- name: Start the kea dhcp server +- name: Start the kea dhcp4 server service: name=kea-dhcp4-server state=started enabled=yes +- name: Configure the kea dhcp-ddns server + template: + src: kea/kea-dhcp-ddns.conf.j2 + dest: /etc/kea/kea-dhcp-ddns.conf +# validate: kea-dhcp-ddns -t %s + notify: Restart kea-dhcp-ddns-server + +- name: Start the kea dhcp-ddns server + service: name=kea-dhcp-ddns-server state=started enabled=yes + - name: Configure the kea control agent template: src: kea/kea-ctrl-agent.conf.j2 diff --git a/roles/kea/templates/kea/kea-dhcp-ddns.conf.j2 b/roles/kea/templates/kea/kea-dhcp-ddns.conf.j2 new file mode 100644 index 0000000..eb5cf39 --- /dev/null +++ b/roles/kea/templates/kea/kea-dhcp-ddns.conf.j2 @@ -0,0 +1,38 @@ +{ +"DhcpDdns": { + "ip-address": "127.0.0.1", + "port": 53001, + "control-socket": { + "socket-type": "unix", + "socket-name": "/run/kea/kea-ddns-ctrl-socket" + }, + + "forward-ddns": { + "ddns-domains": [ + { + "name": "users.binary.kitchen.", + "dns-servers": [ + { "ip-address": "{{ dns_primary }}" } + ] + } + ] + }, + + "reverse-ddns": { + }, + + "loggers": [ + { + "name": "kea-dhcp4", + "output_options": [ + { + "output": "stdout", + "pattern": "%-5p %m\n" + } + ], + "severity": "INFO", + "debuglevel": 0 + } + ] +} +} diff --git a/roles/kea/templates/kea/kea-dhcp4.conf.j2 b/roles/kea/templates/kea/kea-dhcp4.conf.j2 index 47c0cb4..ab0cffd 100644 --- a/roles/kea/templates/kea/kea-dhcp4.conf.j2 +++ b/roles/kea/templates/kea/kea-dhcp4.conf.j2 @@ -10,6 +10,17 @@ "socket-name": "/run/kea/kea4-ctrl-socket" }, + "dhcp-ddns": { + "enable-updates": true, + "server-ip": "127.0.0.1", + "server-port": 53001, + "sender-ip": "", + "sender-port": 0, + "max-queue-size": 1024, + "ncr-protocol": "UDP", + "ncr-format": "JSON" + }, + "hooks-libraries": [ { "library": "/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_lease_cmds.so" @@ -254,6 +265,14 @@ } ], + "ddns-send-updates": true, + "ddns-override-client-update": true, + "ddns-override-no-update": true, + "ddns-qualifying-suffix": "users.binary.kitchen", + "ddns-generated-prefix": "dhcp", + "ddns-replace-client-name": "when-not-present", + "ddns-update-on-renew": true, + "reservations": [ { "hw-address": "b8:27:eb:18:5c:11",