From 16ac6d7169054ae75e94f2c0794caddb312c51b4 Mon Sep 17 00:00:00 2001 From: "Andreas B. Mundt" Date: Sat, 10 Apr 2021 10:09:57 +0200 Subject: [PATCH] Fixes for DHCP, DDNS. --- roles/dns-dhcp-tftp/tasks/main.yml | 11 ++++++++++- roles/dns-dhcp-tftp/templates/dhcpd.conf.j2 | 8 +++++--- roles/dns-dhcp-tftp/templates/localzones.j2 | 4 ++++ roles/dns-dhcp-tftp/templates/resolv.conf.j2 | 3 +-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/roles/dns-dhcp-tftp/tasks/main.yml b/roles/dns-dhcp-tftp/tasks/main.yml index c3feb3c..521f8b6 100644 --- a/roles/dns-dhcp-tftp/tasks/main.yml +++ b/roles/dns-dhcp-tftp/tasks/main.yml @@ -46,6 +46,16 @@ - localzones notify: restart bind +- name: link zone files to writeable directory for DDNS + file: + src: "/etc/bind/{{ item }}" + dest: "/var/lib/bind/{{ item }}" + state: link + loop: + - db.intern + - db.192.168.0 + notify: restart bind + - name: enable local bind config lineinfile: path: /etc/bind/named.conf.local @@ -62,7 +72,6 @@ blockinfile: dest: /etc/dhcp/dhclient.conf block: | - supersede domain-name "{{ ansible_domain }}"; supersede domain-search "{{ ansible_domain }}"; supersede domain-name-servers 127.0.0.1; insertbefore: "#send dhcp-client-identifier.*" diff --git a/roles/dns-dhcp-tftp/templates/dhcpd.conf.j2 b/roles/dns-dhcp-tftp/templates/dhcpd.conf.j2 index 95209ae..b548beb 100644 --- a/roles/dns-dhcp-tftp/templates/dhcpd.conf.j2 +++ b/roles/dns-dhcp-tftp/templates/dhcpd.conf.j2 @@ -15,17 +15,19 @@ max-lease-time 7200; # behavior of the version 2 packages ('none', since DHCP v2 didn't # have support for DDNS.) #ddns-update-style none; -use-host-decl-names on; + +use-host-decl-names on; +ddns-update-style standard; include "/etc/dhcp/rndc.key"; zone intern. { - primary dns; + primary 127.0.0.1; key rndc-key; } zone 0.168.192.in-addr.arpa. { - primary dns; + primary 127.0.0.1; key rndc-key; } diff --git a/roles/dns-dhcp-tftp/templates/localzones.j2 b/roles/dns-dhcp-tftp/templates/localzones.j2 index cb2a9a0..b0d958c 100644 --- a/roles/dns-dhcp-tftp/templates/localzones.j2 +++ b/roles/dns-dhcp-tftp/templates/localzones.j2 @@ -1,8 +1,11 @@ +include "/etc/bind/rndc.key"; + zone "0.168.192.in-addr.arpa" { type master; notify no; file "/etc/bind/db.192.168.0"; journal "/var/lib/bind/db.192.168.0.jnl"; + allow-update { key rndc-key; }; }; zone "intern" { @@ -10,4 +13,5 @@ zone "intern" { notify no; file "/etc/bind/db.intern"; journal "/var/lib/bind/db.intern.jnl"; + allow-update { key rndc-key; }; }; diff --git a/roles/dns-dhcp-tftp/templates/resolv.conf.j2 b/roles/dns-dhcp-tftp/templates/resolv.conf.j2 index 56bda43..7118830 100644 --- a/roles/dns-dhcp-tftp/templates/resolv.conf.j2 +++ b/roles/dns-dhcp-tftp/templates/resolv.conf.j2 @@ -1,3 +1,2 @@ -domain {{ ansible_domain }} -search {{ ansible_domain }}. +search {{ ansible_domain }} nameserver 127.0.0.1