| # unbound templates/unbound.conf.j2 - {{ ansible_managed }} |
| {# |
| SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org> |
| SPDX-License-Identifier: Apache-2.0 |
| #} |
| |
| # general config |
| server: |
| port: 53 |
| do-ip4: yes |
| do-ip6: no |
| do-udp: yes |
| do-tcp: yes |
| |
| # logging |
| verbosity: 1 |
| |
| # RFC7816 query name minimization |
| qname-minimisation: yes |
| |
| # access control |
| {% if unbound_allow_all %} |
| # allow queries from everywhere |
| access-control: 0.0.0.0/0 allow |
| {% else %} |
| # allow queries from localhost |
| access-control: 127.0.0.0/24 allow |
| {% if unbound_allow_zone_ips and dns_zones %} |
| # allow from networks defined in zones |
| {% for key, value in dns_zones.items() %} |
| access-control: {{ value.ip_range }} allow |
| {% endfor %} |
| {% endif %} |
| {% if unbound_allow_ips %} |
| # listen on specific IPs |
| {% for ip in unbound_allow_ips %} |
| interface: {{ ip }} allow |
| {% endfor %} |
| {% endif %} |
| {% endif %} |
| |
| # listening interfaces |
| {% if unbound_listen_default %} |
| # listen on default IPv4 Address |
| interface: {{ ansible_default_ipv4.address }} |
| |
| {% endif %} |
| {% if unbound_listen_zone_ips and dns_zones %} |
| {% for key, value in dns_zones.items() %} |
| {% set if_ip = value.ip_range | ipaddr('next_usable') | ipaddr('address') %} |
| {% if if_ip in ansible_all_ipv4_addresses %} |
| # listen on IPs defined by dns_zones: {{ key }} |
| interface: {{ if_ip }} |
| {% endif %} |
| {% endfor %} |
| |
| {% endif %} |
| {% if unbound_listen_ips %} |
| # listen on specific IPs |
| {% for ip in unbound_listen_ips %} |
| interface: {{ ip | ipaddr('address') }} |
| {% endfor %} |
| |
| {% endif %} |
| # allow unbound to query localhost, where authoritative DNS might be listening |
| do-not-query-localhost: no |
| |
| # disable DNS-over-HTTP (DoH) as it breaks split horizon |
| # https://support.mozilla.org/en-US/kb/configuring-networks-disable-dns-over-https |
| # https://support.mozilla.org/en-US/kb/canary-domain-use-application-dnsnet |
| local-zone: "use-application-dns.net" always_nxdomain |
| |
| {% if dns_zones %} |
| # allow reverse queries for RFC1918 addresses |
| {% for key, value in dns_zones.items() %} |
| local-zone: "{{ value.ip_range | unbound_revdns }}" nodefault |
| |
| {% endfor %} |
| |
| # stub-zones zones that authoritative DNS is serving |
| {% for key, value in dns_zones.items() %} |
| stub-zone: |
| name: "{{ key }}" |
| stub-addr: {{ unbound_authoritative_server_ip }} |
| |
| stub-zone: |
| name: "{{ value.ip_range | unbound_revdns }}" |
| stub-addr: {{ unbound_authoritative_server_ip }} |
| |
| {% endfor %} |
| {% endif %} |
| {% if unbound_forward_zones %} |
| {% for fz in unbound_forward_zones %} |
| forward-zone: |
| name: "{{ fz.name | default('.') }}" |
| {% for fza in fz.servers %} |
| forward-addr: {{ fza }} |
| {% endfor %} |
| {% endfor %} |
| |
| {% endif %} |