dns/master: Added dnssec support

- Generation of keys
- Signing zone after each change
wip
Felix Stupp 5 years ago
parent 69026d8d27
commit df88e582a7
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -5,6 +5,10 @@ domain: "example.com"
domain_directory: "{{ dns_zones_directory }}/{{ domain }}" domain_directory: "{{ dns_zones_directory }}/{{ domain }}"
configuration_file: "{{ domain_directory }}/zone.conf" configuration_file: "{{ domain_directory }}/zone.conf"
database_file: "{{ domain_directory }}/zone.db" database_file: "{{ domain_directory }}/zone.db"
database_signed_file: "{{ database_file }}.signed"
dnssec_algorithm: "RSASHA512"
dnssec_key_length: "4096"
main_nameserver_domain: "ns1.{{ domain }}." main_nameserver_domain: "ns1.{{ domain }}."
responsible_mail_name: "admin.{{ domain }}." responsible_mail_name: "admin.{{ domain }}."

@ -0,0 +1,24 @@
---
- name: Generate key signing key for zone {{ domain }}
command: >-
dnssec-keygen
-f KSK
-3
-a {{ dnssec_algorithm | quote }}
-b {{ dnssec_key_length | quote }}
-n ZONE {{ domain | quote }}
args:
chdir: "{{ domain_directory }}"
- name: Generate zone signing key for zone {{ domain }}
command: >-
dnssec-keygen
-3
-a {{ dnssec_algorithm | quote }}
-b {{ dnssec_key_length | quote }}
-n ZONE {{ domain | quote }}
args:
chdir: "{{ domain_directory }}"
# TODO Copy public keys to localhost

@ -8,6 +8,22 @@
group: root group: root
mode: "u=rwx,g=rx" mode: "u=rwx,g=rx"
- name: Determine if keys are generated already
find:
paths: "{{ domain_directory }}"
patterns: "K{{ domain }}.+*+*"
register: keys_found
- name: Generate keys for zone {{ domain }}
include_tasks: generate_keys.yml
when: keys_found.matched < 2
- name: Find generated public keys
find:
paths: "{{ domain_directory }}"
patterns: "K{{ domain }}.+*+*.key"
register: keys_list
- name: Store database of zone {{ domain }} - name: Store database of zone {{ domain }}
template: template:
src: zone.db src: zone.db
@ -17,8 +33,22 @@
mode: "u=rw,g=r,o=r" mode: "u=rw,g=r,o=r"
validate: "named-checkzone {{ domain }} %s" validate: "named-checkzone {{ domain }} %s"
notify: reload bind9 notify: reload bind9
register: database_stored
# TODO DNSSEC # TODO test -N=UNIXTIME instead of unix time by ansible
- name: Sign zone {{ domain }}
shell: >-
dnssec-signzone
-3 $(head -c 1000 /dev/urandom | sha1sum | cut -b 1-16)
-a
-N KEEP
-o {{ domain | quote }}
-f {{ database_signed_file | quote }}
{{ database_file | quote }}
args:
chdir: "{{ domain_directory }}"
executable: "/bin/sh"
when: database_stored.changed
- name: Configure zone {{ domain }} - name: Configure zone {{ domain }}
template: template:

@ -1,6 +1,6 @@
zone "{{ domain }}" { zone "{{ domain }}" {
type master; type master;
file "{{ database_file }}"; file "{{ database_signed_file }}";
notify yes; notify yes;
allow-transfer { allow-transfer {
{% for fqdn in slaves %} {% for fqdn in slaves %}

@ -7,4 +7,8 @@ $TTL 86400
{{ ttl }} {{ ttl }}
) )
{% for key in keys_list.files %}
$INCLUDE {{ key.path }}
{% endfor %}
{{ entries }} {{ entries }}

Loading…
Cancel
Save