blob: 1c2f1c3ce3ff9e597d7756edee1750ec3b811ab9 [file] [log] [blame]
Zack Williams142f2b52020-11-22 19:35:44 -07001# unbound templates/unbound.conf.j2 - {{ ansible_managed }}
2{#
3SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
4SPDX-License-Identifier: Apache-2.0
5#}
6
7# general config
8server:
9 port: 53
10 do-ip4: yes
11 do-ip6: no
12 do-udp: yes
13 do-tcp: yes
14
15 # logging
16 verbosity: 1
17
18 # RFC7816 query name minimization
19 qname-minimisation: yes
20
21 # access control
22{% if unbound_allow_all %}
23 # allow queries from everywhere
24 access-control: 0.0.0.0/0 allow
25{% else %}
26 # allow queries from localhost
27 access-control: 127.0.0.0/24 allow
Zack Williams142f2b52020-11-22 19:35:44 -070028{% if unbound_allow_ips %}
29 # listen on specific IPs
30{% for ip in unbound_allow_ips %}
Zack Williams546a7882021-06-28 12:46:07 -070031 access-control: {{ ip }} allow
Zack Williams142f2b52020-11-22 19:35:44 -070032{% endfor %}
33{% endif %}
34{% endif %}
35
36 # listening interfaces
37{% if unbound_listen_default %}
38 # listen on default IPv4 Address
39 interface: {{ ansible_default_ipv4.address }}
40
41{% endif %}
Zack Williams8296e472021-03-23 21:13:07 -070042
Zack Williams142f2b52020-11-22 19:35:44 -070043{% if unbound_listen_ips %}
44 # listen on specific IPs
45{% for ip in unbound_listen_ips %}
46 interface: {{ ip | ipaddr('address') }}
Zack Williams142f2b52020-11-22 19:35:44 -070047
Zack Williams8296e472021-03-23 21:13:07 -070048{% endfor %}
Zack Williams142f2b52020-11-22 19:35:44 -070049{% endif %}
Zack Williams8296e472021-03-23 21:13:07 -070050 # disable DNS-over-HTTP (DoH) as it breaks split horizon
51 # https://support.mozilla.org/en-US/kb/configuring-networks-disable-dns-over-https
52 # https://support.mozilla.org/en-US/kb/canary-domain-use-application-dnsnet
53 local-zone: "use-application-dns.net" always_nxdomain
54
55{% if dns_reverse_zones %}
56 # allow reverse queries for RFC1918 addresses, per dns_reverse_zones
57 {% for key, value in dns_reverse_zones.items() %}
58 local-zone: "{{ key | ipaddr('network') | unbound_revdns }}" nodefault
59 {% endfor %}
60{% endif %}
61{% if unbound_reverse_zones %}
62 # allow reverse queries for RFC1918 addresses, per unbound_reverse_zones
63 {% for urz in unbound_reverse_zones %}
64 local-zone: "{{ urz | ipaddr('network') | unbound_revdns }}" nodefault
65 {% endfor %}
66{% endif %}
67
Zack Williams142f2b52020-11-22 19:35:44 -070068# allow unbound to query localhost, where authoritative DNS might be listening
69do-not-query-localhost: no
70
Zack Williams8296e472021-03-23 21:13:07 -070071# zone definitions
72{% if dns_reverse_zones %}
73# reverse zones created by dns_reverse_zones
74{% for key, value in dns_reverse_zones.items() %}
75stub-zone:
76 name: "{{ key | ipaddr('network') | unbound_revdns }}"
77 stub-addr: {{ unbound_authoritative_server_ip }}
Zack Williams142f2b52020-11-22 19:35:44 -070078
79{% endfor %}
Zack Williams8296e472021-03-23 21:13:07 -070080{% endif %}
81{% if dns_forward_zones %}
82# forward zones created by dns_forward_zones
83{% for key, value in dns_forward_zones.items() %}
Zack Williams142f2b52020-11-22 19:35:44 -070084stub-zone:
85 name: "{{ key }}"
86 stub-addr: {{ unbound_authoritative_server_ip }}
87
Zack Williams142f2b52020-11-22 19:35:44 -070088{% endfor %}
89{% endif %}
Zack Williams8296e472021-03-23 21:13:07 -070090
Zack Williamsa1c89742020-12-14 11:01:57 -070091{% if unbound_forward_zones %}
Zack Williams8296e472021-03-23 21:13:07 -070092# Forward zones created by: unbound_forward_zones
Zack Williamsa1c89742020-12-14 11:01:57 -070093{% for fz in unbound_forward_zones %}
94forward-zone:
95 name: "{{ fz.name | default('.') }}"
96{% for fza in fz.servers %}
97 forward-addr: {{ fza }}
98{% endfor %}
99{% endfor %}
Zack Williamsa1c89742020-12-14 11:01:57 -0700100{% endif %}