bind: merge reverse[46].zone

This commit is contained in:
Astro 2017-01-14 00:13:35 +01:00
parent 02663013a2
commit beec71f387
5 changed files with 27 additions and 48 deletions

View File

@ -7,15 +7,15 @@ bind:
serial: 2017011300
reverse-zones-inet:
- 172.20.72
- 172.20.73
- 172.20.74
- 172.20.75
- 172.20.76
- 172.20.77
- 172.20.78
- 172.20.79
- 72.20.172.in-addr.arpa
- 73.20.172.in-addr.arpa
- 74.20.172.in-addr.arpa
- 75.20.172.in-addr.arpa
- 76.20.172.in-addr.arpa
- 77.20.172.in-addr.arpa
- 78.20.172.in-addr.arpa
- 79.20.172.in-addr.arpa
reverse-zones-inet6:
- '8.5.0.2.d.3.c.2.4.0.0.3.2.d.f.ip6.arpa'
- 'c.5.0.2.d.3.c.2.4.0.0.3.2.d.f.ip6.arpa'
- 8.5.0.2.d.3.c.2.4.0.0.3.2.d.f.ip6.arpa
- c.5.0.2.d.3.c.2.4.0.0.3.2.d.f.ip6.arpa

View File

@ -38,23 +38,20 @@ bind9:
{%- endfor %}
# IPv4 reverse
{%- for subnet in pillar['bind']['reverse-zones-inet'] %}
{%- set domain = '.'.join(subnet.split('.').__reversed__()) ~ '.in-addr.arpa' %}
/etc/bind/reverse4-{{ subnet }}.zone:
{%- for domain in pillar['bind']['reverse-zones-inet'] %}
/etc/bind/{{ domain }}.zone:
file.managed:
- source: salt://bind/reverse4.zone
- source: salt://bind/reverse.zone
- template: 'jinja'
- context:
domain: {{ domain }}
subnet: {{ subnet }}
{%- endfor %}
# IPv6 reverse
{%- for domain in pillar['bind']['reverse-zones-inet6'] %}
/etc/bind/reverse6-{{ domain }}.zone:
/etc/bind/{{ domain }}.zone:
file.managed:
- source: salt://bind/reverse6.zone
- source: salt://bind/reverse.zone
- template: 'jinja'
- context:
domain: {{ domain }}

View File

@ -7,17 +7,16 @@ zone "{{ domain }}" IN {
{%- endfor %}
{%- for subnet in pillar['bind']['reverse-zones-inet'] %}
{%- set domain = '.'.join(subnet.split('.').__reversed__()) ~ '.in-addr.arpa' %}
{%- for domain in pillar['bind']['reverse-zones-inet'] %}
zone "{{ domain }}" IN {
type master;
file "/etc/bind/reverse4-{{ subnet }}.zone";
file "/etc/bind/{{ domain }}.zone";
};
{%- endfor %}
{%- for domain in pillar['bind']['reverse-zones-inet6'] %}
zone "{{ domain }}" IN {
type master;
file "/etc/bind/reverse6-{{ domain }}.zone";
file "/etc/bind/{{ domain }}.zone";
};
{%- endfor %}

View File

@ -12,6 +12,15 @@ $TTL 10M
IN NS {{ ns }}.
{%- endfor %}
{%- for net, hosts in pillar['hosts-inet'].items() %}
{%- for host, aaaa in hosts.items() %}
{%- set reverse = salt['network.reverse_ip'](aaaa) %}
{%- if reverse.endswith(domain) %}
{{ reverse.replace('.' ~ domain, '') }} IN PTR {{ host }}.{{ net }}.{{ pillar['bind']['root-domain'] }}.
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- for net, hosts in pillar['hosts-inet6'].items() %}
{%- for host, aaaa in hosts.items() %}
{%- set reverse = salt['network.reverse_ip'](aaaa) %}

View File

@ -1,26 +0,0 @@
$ORIGIN {{ domain }}.
$TTL 10M
@ IN SOA {{ pillar['bind']['master-ns'] }}. astro.spaceboyz.net. (
{{ pillar['bind']['serial'] }} ; serial
1H ; refresh
1M ; retry
2H ; expire
5M ; minimum
)
{%- for ns in pillar['bind']['public-ns'] %}
IN NS {{ ns }}.
{%- endfor %}
{%- for i in range(1, 255) %}
{%- set addr = subnet ~ '.' ~ i %}
{%- for net, hosts in pillar['hosts-inet'].items() %}
{%- for host, a in hosts.items() %}
{%- if a == addr %}
{{ i }} IN PTR {{ host }}.{{ net }}.{{ pillar['bind']['root-domain'] }}.
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- endfor %}