From 6c20ffffc1c61f2d12b24bf91039a9646a2facb7 Mon Sep 17 00:00:00 2001
From: lilly
Date: Sun, 6 Dec 2026 02:25:09 +0100
Subject: [PATCH] add dns64 support to our unbound role
---
roles/unbound/README.md | 2 ++
roles/unbound/defaults/main.yml | 1 +
roles/unbound/templates/unbound.conf.j2 | 6 ++++++
3 files changed, 9 insertions(+)
diff --git a/roles/unbound/README.md b/roles/unbound/README.md
index 0c2ad8f..d425466 100644
--- a/roles/unbound/README.md
+++ b/roles/unbound/README.md
@@ -25,4 +25,6 @@ The following variables can be used to customize this role:
Defaults to max vCPU Count.
- `unbound_private_domain`: List of domains from witch unbound for the domain and its subdomains to allows resolving of RFC1918 addresses. (Not relevent on Debian)
Defaults to `[]`
+- `unbound_enable_dns64`: Whether dns64 module should be loaded. If defined, the `unbound_dns64_prefix` option must also be set.
+- `unbound_dns64_prefix`: The prefix in which AAAA records are synthesized when upstream only returns an A record
diff --git a/roles/unbound/defaults/main.yml b/roles/unbound/defaults/main.yml
index fa6cb24..672d975 100644
--- a/roles/unbound/defaults/main.yml
+++ b/roles/unbound/defaults/main.yml
@@ -5,3 +5,4 @@ unbound_enable_unbound_control: true
unbound_enable_dnssec: true
unbound_access_control: [ ]
unbound_private_domain: [ ]
+unbound_enable_dns64: false
diff --git a/roles/unbound/templates/unbound.conf.j2 b/roles/unbound/templates/unbound.conf.j2
index 3213f46..67e532e 100644
--- a/roles/unbound/templates/unbound.conf.j2
+++ b/roles/unbound/templates/unbound.conf.j2
@@ -1,6 +1,8 @@
# ref: https://unbound.docs.nlnetlabs.nl/en/latest/manpages/unbound.conf.html
# unbound.conf(5) man page
server:
+ module-config: "{% if unbound_enable_dns64 %}dns64 {% endif %}validator iterator"
+
{% if unbound_enable_dnssec -%}
# location of the trust anchor file that enables DNSSEC
# this file is generated by the `unbound-anchor` command
@@ -43,6 +45,10 @@ server:
private-domain: {{ i }}
{% endfor -%}
+ {% if unbound_enable_dns64 -%}
+ dns64-prefix: "{{ unbound_dns64_prefix }}"
+ {% endif -%}
+
# The number of seconds between printing statistics to the log for every thread.
statistics-interval: 0