Zack Williams | 99adf6b | 2016-03-14 17:01:08 -0700 | [diff] [blame] | 1 | # unbound.conf (configured by Ansible) |
| 2 | |
| 3 | server: |
Zack Williams | c59b6b2 | 2016-04-11 12:49:10 -0700 | [diff] [blame] | 4 | {% if unbound_listen_on_default %} |
| 5 | interface: {{ ansible_default_ipv4.address }} |
| 6 | {% endif %} |
| 7 | {% if unbound_interfaces is defined %} |
| 8 | {% for cidr_ipv4 in unbound_interfaces %} |
Zack Williams | 99adf6b | 2016-03-14 17:01:08 -0700 | [diff] [blame] | 9 | interface: {{ cidr_ipv4 | ipaddr('address') }} |
Zack Williams | c59b6b2 | 2016-04-11 12:49:10 -0700 | [diff] [blame] | 10 | {% endfor %} |
| 11 | {% endif %} |
Zack Williams | 99adf6b | 2016-03-14 17:01:08 -0700 | [diff] [blame] | 12 | verbosity: 1 |
| 13 | port: 53 |
| 14 | do-ip4: yes |
| 15 | do-udp: yes |
| 16 | do-tcp: yes |
| 17 | |
| 18 | # allow from localhost |
| 19 | access-control: 127.0.0.0/24 allow |
| 20 | |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 21 | {% if unbound_listen_all %} |
| 22 | # allow from everywhere |
| 23 | access-control: 0.0.0.0/0 allow |
| 24 | {% endif %} |
| 25 | |
Zack Williams | c59b6b2 | 2016-04-11 12:49:10 -0700 | [diff] [blame] | 26 | {% if unbound_listen_on_default %} |
| 27 | # allow from default interfaces |
| 28 | access-control: {{ ansible_default_ipv4.address }}/{{ (ansible_default_ipv4.address ~ "/" ~ ansible_default_ipv4.netmask) | ipaddr('prefix') }} allow |
| 29 | {% endif %} |
| 30 | |
| 31 | {% if unbound_interfaces is defined %} |
Zack Williams | 99adf6b | 2016-03-14 17:01:08 -0700 | [diff] [blame] | 32 | # allow from local networks |
Zack Williams | c59b6b2 | 2016-04-11 12:49:10 -0700 | [diff] [blame] | 33 | {% for cidr_ipv4 in unbound_interfaces %} |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 34 | access-control: {{ cidr_ipv4 | ipaddr('0') }} allow |
Zack Williams | c59b6b2 | 2016-04-11 12:49:10 -0700 | [diff] [blame] | 35 | {% endfor %} |
| 36 | {% endif %} |
Zack Williams | 99adf6b | 2016-03-14 17:01:08 -0700 | [diff] [blame] | 37 | |
| 38 | {% if nsd_zones is defined %} |
| 39 | # allow unbound to query localhost, where nsd is listening |
| 40 | do-not-query-localhost: no |
| 41 | |
| 42 | # allow reverse queries for RFC1918 addresses |
| 43 | {% for zone in nsd_zones %} |
| 44 | local-zone: "{{ zone.name_reverse_unbound }}." nodefault |
| 45 | {% endfor %} |
| 46 | |
| 47 | # stub-zones zones that nsd is serving |
| 48 | {% for zone in nsd_zones %} |
| 49 | stub-zone: |
| 50 | name: "{{ zone.name }}" |
| 51 | stub-addr: {{ nsd_ip | default("127.0.0.1") }} |
| 52 | |
| 53 | stub-zone: |
| 54 | name: "{{ zone.name_reverse_unbound }}." |
| 55 | stub-addr: {{ nsd_ip | default("127.0.0.1") }} |
| 56 | |
| 57 | {% endfor %} |
| 58 | {% endif %} |
| 59 | |