run nsd on bare metal

This commit is contained in:
Pim Kunis 2023-01-07 12:02:04 +01:00
parent 9bb44e4978
commit 117d7d2cf4
11 changed files with 39 additions and 102 deletions

View file

@ -1,14 +0,0 @@
127.0.0.1 localhost
127.0.1.1 ubuntu
127.0.0.1 pizzapim.nl
127.0.0.1 git.pizzapim.nl
127.0.0.1 dav.pizzapim.nl
127.0.0.1 social.pizzapim.nl
127.0.0.1 www.pizzapim.nl
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

View file

@ -1,3 +1,4 @@
nameserver 192.168.30.1
nameserver 1.1.1.1 nameserver 1.1.1.1
nameserver 1.0.0.1 nameserver 1.0.0.1
search lan search lan

View file

@ -23,7 +23,3 @@
src: "{{ role_path }}/files/resolv.conf" src: "{{ role_path }}/files/resolv.conf"
dest: /etc/resolv.conf dest: /etc/resolv.conf
follow: true follow: true
- name: Copy hosts file
copy:
src: "{{ role_path }}/files/hosts"
dest: /etc/hosts

View file

@ -1,3 +0,0 @@
{
"ipv6": true
}

View file

@ -29,11 +29,6 @@
name: name:
- docker - docker
- docker-compose - docker-compose
- name: Enable IPv6
copy:
src: "{{ role_path }}/files/daemon.json"
dest: /etc/docker/daemon.json
register: daemon_file
- name: Start Docker - name: Start Docker
systemd: systemd:
name: docker name: docker

View file

@ -1,18 +0,0 @@
version: '3.7'
services:
nsd:
container_name: nsd
restart: always
image: ghcr.io/the-kube-way/nsd:v4.6.0
read_only: true
tmpfs:
- /tmp
- /var/db/nsd
volumes:
- /apps/nsd/conf:/etc/nsd:ro
- /apps/nsd/zones:/zones
- /apps/nsd/keys:/keys
ports:
- 53:53
- 53:53/udp

View file

@ -1,9 +1,9 @@
server: server:
ip-address: eth0 # TEMP until response from mailing list ip-address: enp3s0
server-count: 1 server-count: 1
verbosity: 1 verbosity: 1
hide-version: yes hide-version: yes
zonesdir: "/zones" zonesdir: "/etc/nsd/zones"
ip-transparent: yes ip-transparent: yes
ip-freebind: yes ip-freebind: yes

View file

@ -1,18 +1,18 @@
$ORIGIN geokunis2.nl. $ORIGIN geokunis2.nl.
$TTL 60 $TTL 60
geokunis2.nl. IN SOA ns.geokunis2.nl. niels.kunis.nl. 2023010600 1800 3600 1209600 3600 geokunis2.nl. IN SOA ns.geokunis2.nl. niels.kunis.nl. 2023010601 1800 3600 1209600 3600
NS ns.geokunis2.nl. NS ns.geokunis2.nl.
NS ns0.transip.net. NS ns0.transip.net.
NS ns1.transip.nl. NS ns1.transip.nl.
NS ns2.transip.eu. NS ns2.transip.eu.
A 82.197.212.198 A 84.245.14.149
AAAA 2a02:58:19a:f730:b62e:99ff:fe77:1bda AAAA 2a02:58:19a:f730:b62e:99ff:fe77:1bda
MX 0 . MX 0 .
TXT "v=spf1 -all" TXT "v=spf1 -all"
CAA 0 issue "letsencrypt.org" CAA 0 issue "letsencrypt.org"
jenl IN A 217.123.41.225 jenl IN A 217.123.41.225
kms IN A 82.197.212.198 kms IN A 84.245.14.149
_dmarc IN TXT "v=DMARC1; p=reject; fo=0; adkim=s; aspf=s; pct=100; rf=afrf; sp=reject" _dmarc IN TXT "v=DMARC1; p=reject; fo=0; adkim=s; aspf=s; pct=100; rf=afrf; sp=reject"
ns A 82.197.212.198 ns A 84.245.14.149
AAAA 2a02:58:19a:f730:b62e:99ff:fe77:1bda AAAA 2a02:58:19a:f730:b62e:99ff:fe77:1bda

View file

@ -1,22 +1,22 @@
$ORIGIN pizzapim.nl. $ORIGIN pizzapim.nl.
$TTL 60 $TTL 60
pizzapim.nl. IN SOA ns.pizzapim.nl. pim.kunis.nl. 2023010600 1800 3600 1209600 3600 pizzapim.nl. IN SOA ns.pizzapim.nl. pim.kunis.nl. 2023010700 1800 3600 1209600 3600
NS ns.pizzapim.nl. NS ns.pizzapim.nl.
NS ns0.transip.net. NS ns0.transip.net.
NS ns1.transip.nl. NS ns1.transip.nl.
NS ns2.transip.eu. NS ns2.transip.eu.
A 82.197.212.198 A 84.245.14.149
AAAA 2a02:58:19a:f730:b62e:99ff:fe77:1bda AAAA 2a02:58:19a:f730:b62e:99ff:fe77:1bda
TXT "v=spf1 ~all" TXT "v=spf1 ~all"
CAA 0 issue "letsencrypt.org" CAA 0 issue "letsencrypt.org"
_dmarc IN TXT "v=DMARC1; p=reject; aspf=s; adkim=s; rua=mailto:wpux1bq8@ag.eu.dmarcian.com;" _dmarc IN TXT "v=DMARC1; p=reject; aspf=s; adkim=s; rua=mailto:wpux1bq8@ag.eu.dmarcian.com;"
www IN A 82.197.212.198 www IN A 84.245.14.149
AAAA 2a02:58:19a:f730:b62e:99ff:fe77:1bda AAAA 2a02:58:19a:f730:b62e:99ff:fe77:1bda
ns IN A 82.197.212.198 ns IN A 84.245.14.149
AAAA 2a02:58:19a:f730:b62e:99ff:fe77:1bda AAAA 2a02:58:19a:f730:b62e:99ff:fe77:1bda
cloud IN CNAME www.pizzapim.nl cloud IN CNAME www.pizzapim.nl
social IN CNAME www.pizzapim.nl social IN CNAME www.pizzapim.nl

View file

@ -1,3 +0,0 @@
dependencies:
- role: common
- role: docker

View file

@ -1,86 +1,69 @@
- name: Create nsd app directory - name: Install nsd
file: apt:
path: /apps/nsd pkg:
state: directory - nsd
- name: Create nsd configuration directory - ldnsutils
file:
path: /apps/nsd/conf
state: directory
owner: 991
group: 991
- name: Copy nsd.conf - name: Copy nsd.conf
copy: copy:
src: "{{ role_path }}/files/nsd.conf" src: "{{ role_path }}/files/nsd.conf"
dest: /apps/nsd/conf/nsd.conf dest: /etc/nsd/nsd.conf
- name: Create nsd zones directory - name: Create zones directory
file: file:
path: /apps/nsd/zones path: /etc/nsd/zones
state: directory state: directory
owner: 991
group: 991
- name: Copy zone files - name: Copy zone files
copy: copy:
src: "{{ role_path }}/files/zones/" src: "{{ role_path }}/files/zones/"
dest: /apps/nsd/zones dest: /etc/nsd/zones
- name: Create nsd keys directory - name: Create keys directory
file: file:
path: /apps/nsd/keys path: /etc/nsd/keys
state: directory state: directory
owner: 991
group: 991
- name: Copy KSK private keys - name: Copy KSK private keys
template: template:
src: "{{ item }}" src: "{{ item }}"
dest: "/apps/nsd/keys/{{ item | basename }}" dest: "/etc/nsd/keys/{{ item | basename }}"
with_fileglob: with_fileglob:
- "{{ role_path }}/files/keys/*.ksk.private" - "{{ role_path }}/files/keys/*.ksk.private"
- name: Copy KSK keys - name: Copy KSK keys
copy: copy:
src: "{{ item }}" src: "{{ item }}"
dest: "/apps/nsd/keys/{{ item | basename }}" dest: "/etc/nsd/keys/{{ item | basename }}"
with_fileglob: with_fileglob:
- "{{ role_path }}/files/keys/*.ksk.key" - "{{ role_path }}/files/keys/*.ksk.key"
- name: Copy Docker Compose script
copy:
src: "{{ role_path }}/files/docker-compose.yml"
dest: /apps/nsd/docker-compose.yml
- name: Start Docker Compose
docker_compose:
project_src: /apps/nsd
pull: true
remove_orphans: true
- name: Check if ZSKs exist - name: Check if ZSKs exist
stat: stat:
path: "/apps/nsd/keys/K{{ item | basename }}.zsk.key" path: "/etc/nsd/keys/K{{ item | basename }}.zsk.key"
register: zsks_exists register: zsks_exists
with_fileglob: with_fileglob:
- "{{ role_path }}/files/zones/*" - "{{ role_path }}/files/zones/*"
- name: Create ZSK - name: Create ZSK
command: command:
cmd: "docker-compose exec -w /keys nsd ldns-keygen -a ED25519 {{ item.item | basename }}" cmd: "ldns-keygen -a ED25519 {{ item.item | basename }}"
chdir: /apps/nsd chdir: /etc/nsd/keys
register: create_zsk register: create_zsk
when: not item.stat.exists when: not item.stat.exists
with_items: "{{ zsks_exists.results }}" with_items: "{{ zsks_exists.results }}"
- name: Rename ZSK key - name: Rename ZSK key
command: command:
cmd: "docker-compose exec -w /keys nsd mv {{ item.stdout }}.key K{{ item.item.item | basename }}.zsk.key" cmd: "mv {{ item.stdout }}.key K{{ item.item.item | basename }}.zsk.key"
chdir: /apps/nsd chdir: /etc/nsd/keys
when: item.changed when: item.changed
with_items: "{{ create_zsk.results }}" with_items: "{{ create_zsk.results }}"
- name: Rename ZSK private key - name: Rename ZSK private key
command: command:
cmd: "docker-compose exec -w /keys nsd mv {{ item.stdout }}.private K{{ item.item.item | basename }}.zsk.private" cmd: "mv {{ item.stdout }}.private K{{ item.item.item | basename }}.zsk.private"
chdir: /apps/nsd chdir: /etc/nsd/keys
when: item.changed when: item.changed
with_items: "{{ create_zsk.results }}" with_items: "{{ create_zsk.results }}"
- name: Sign zones - name: Sign zones
command: command:
cmd: 'docker-compose exec -w /zones nsd ldns-signzone {{ item | basename }} /keys/K{{ item | basename }}.zsk /keys/K{{ item | basename }}.ksk' cmd: "ldns-signzone {{ item | basename }} /etc/nsd/keys/K{{ item | basename }}.zsk /etc/nsd/keys/K{{ item | basename }}.ksk"
chdir: /apps/nsd chdir: /etc/nsd/zones
with_fileglob: with_fileglob:
- "{{ role_path }}/files/zones/*" - "{{ role_path }}/files/zones/*"
- name: Restart Docker Compose - name: Restart NSD
docker_compose: systemd:
project_src: /apps/nsd name: nsd
restarted: true enabled: true
state: reloaded