1
0

Compare commits

...

12 Commits

Author SHA1 Message Date
d2ad01fd37 feat: drop Debian 11 support
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-04 19:10:33 +01:00
3a364b462d feat(readme): add section about SOA-EDIT = INCEPTION-INCREMENT
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-29 13:58:32 +01:00
49e6e9ce56 fix: merge inotifywait --exclude args
All checks were successful
continuous-integration/drone/push Build is passing
inotifywait only takes the last --exclude argument
2022-12-24 19:54:23 +01:00
f27537448c fix(rebuild): the input device is not a TTY
Some checks reported errors
continuous-integration/drone/push Build was killed
2022-11-19 17:16:31 +01:00
197a87f268 fix: configure MTU for docker:dind service to 1492
All checks were successful
continuous-integration/drone/push Build is passing
https://blog.zespre.com/dind-mtu-size-matters.html
2022-09-18 15:54:43 +02:00
15e959391d fix(Dockerfile): fail build when apt-get fails
Some checks failed
continuous-integration/drone/push Build is failing
2022-09-17 15:24:14 +02:00
288045eb53 add drone-ci
All checks were successful
continuous-integration/drone/push Build is passing
2022-08-09 20:06:22 +02:00
67a4f2b02e exclude .swp files in inotifywait 2022-07-22 19:33:40 +02:00
7d6169a8a0 build/rebuild.sh: rebuild when current image has pending updates 2022-07-22 19:33:40 +02:00
aec33942bb add support for Debian Bookworm / PowerDNS 4.6 2022-06-25 13:38:00 +02:00
043c456fdf mv Dockerfile,start.sh to debian/11 2022-06-22 13:54:02 +02:00
f55687e58f add DNSSEC support 2022-06-22 13:45:34 +02:00
7 changed files with 201 additions and 22 deletions

90
.drone.yml Normal file
View File

@ -0,0 +1,90 @@
kind: pipeline
type: docker
name: build
steps:
- name: build
image: docker:dind
volumes:
- name: dockersock
path: /var/run
environment:
DOCKER_USERNAME:
from_secret: docker_username
DOCKER_PASSWORD:
from_secret: docker_password
commands:
- sleep 5 # give docker enough time to start
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- ./debian/12/build.sh
when:
branch:
- master
event:
- push
services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
path: /var/run
command:
- dockerd-entrypoint.sh
- dockerd
- --host=unix:///var/run/docker.sock
- --mtu=1492
volumes:
- name: dockersock
temp: {}
trigger:
branch:
- master
event:
- push
---
kind: pipeline
type: docker
name: rebuild
steps:
- name: rebuild
image: docker:dind
volumes:
- name: dockersock
path: /var/run
environment:
DOCKER_USERNAME:
from_secret: docker_username
DOCKER_PASSWORD:
from_secret: docker_password
commands:
- sleep 5 # give docker enough time to start
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- ./build/rebuild.sh
services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
path: /var/run
command:
- dockerd-entrypoint.sh
- dockerd
- --host=unix:///var/run/docker.sock
- --mtu=1492
volumes:
- name: dockersock
temp: {}
trigger:
event:
- cron
cron:
- rebuild

View File

@ -3,6 +3,11 @@
* Debian slim based image
* PowerDNS package from Debian
* Bind backend support only
* DNSSEC support (optional per zone)
# Supported tags and respective `Dockerfile` links
- [`4.6-bookworm`, `latest`](https://github.com/pommi/docker-powerdns/blob/master/debian/12/Dockerfile)
# Usage
@ -31,7 +36,7 @@ $ docker run -it \
-v $(pwd)/named.conf:/etc/powerdns/named.conf \
-v $(pwd)/zones/:/var/lib/powerdns/zones/ \
-p 5353:53/udp -p 5353:53 \
pommib/powerdns:4.4-bullseye
pommib/powerdns:latest
$ dig +short @127.0.0.1 -p5353 example.tld A
192.0.2.1
@ -45,7 +50,7 @@ version: "3"
services:
powerdns:
container_name: powerdns
image: pommib/powerdns:4.4-bullseye
image: pommib/powerdns:latest
ports:
- "5353:53/tcp"
- "5353:53/udp"
@ -53,3 +58,43 @@ services:
- '${PWD}/named.conf:/etc/powerdns/named.conf'
- '${PWD}/zones/:/var/lib/powerdns/zones/'
```
# DNSSEC
Securing a zone:
```
$ docker exec -it powerdns pdnsutil secure-zone example.tld
[bindbackend] Done parsing domains, 0 rejected, 1 new, 0 removed
Securing zone with default key size
Adding CSK (257) with algorithm ecdsa256
Zone example.tld secured
Adding NSEC ordering information
```
Show DNSSEC related settings for the secured zone:
```
$ docker exec -it powerdns pdnsutil show-zone example.tld
[bindbackend] Done parsing domains, 0 rejected, 1 new, 0 removed
This is a Master zone
Last SOA serial number we notified: 0 != 2022010101 (serial in the database)
Metadata items: None
Zone has NSEC semantics
keys:
ID = 1 (CSK), flags = 257, tag = 280, algo = 13, bits = 256 Active Published ( ECDSAP256SHA256 )
CSK DNSKEY = example.tld. IN DNSKEY 257 3 13 5jAoLVZFaevgJkAKQzLJDdhQKP1i+SPaCrCjhsbsOAypYSsz9l7AyJC75trKdVwUn9ICMNq6Jjta9NQc7Bnktw== ; ( ECDSAP256SHA256 )
DS = example.tld. IN DS 280 13 1 0dead339b7dacebb6750c7d4e5c9c0f4c19843a9 ; ( SHA1 digest )
DS = example.tld. IN DS 280 13 2 f340e93c42b3c2c6fa8ef76e044ad2f064c1cd7484e785bdfca0f51cd548c88d ; ( SHA256 digest )
DS = example.tld. IN DS 280 13 4 a793c7e590a7701c7b39365f99655b865d11961c355a5eb59302282cf653aec8b051ddc9e36a9df0843cad29ca50149a ; ( SHA-384 digest )
```
Set `SOA-EDIT` to `INCEPTION-INCREMENT` so that slaves get notified when a rollover has taken place:
```
$ docker exec -it powerdns pdnsutil set-meta example.tld SOA-EDIT INCEPTION-INCREMENT
[bindbackend] Done parsing domains, 0 rejected, 1 new, 0 removed
Set 'example.tld' meta SOA-EDIT = INCEPTION-INCREMENT
$ docker exec -it powerdns pdnsutil get-meta example.tld
[bindbackend] Done parsing domains, 0 rejected, 1 new, 0 removed
Metadata for 'example.tld'
SOA-EDIT = INCEPTION-INCREMENT
```

16
build/rebuild.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
set -x
updates_available () {
docker pull $1
if test "$(docker run --rm $1 /bin/sh -c 'apt -qqq update && apt -qq list --upgradable')" != ""; then
return 0
else
return 1
fi
}
if updates_available pommib/powerdns:4.6-bookworm; then
./debian/12/build.sh
fi

View File

@ -1,14 +1,15 @@
FROM debian:bullseye-slim
FROM debian:bookworm-slim
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
RUN set -eux && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
pdns-server \
pdns-backend-bind \
sqlite3 \
bind9-dnsutils \
inotify-tools \
; \
&& \
rm -rf /var/lib/apt/lists/*
ADD start.sh /

12
debian/12/build.sh vendored Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
set -ex
IMAGE=pommib/powerdns:4.6-bookworm
docker pull $IMAGE
docker pull debian:bookworm-slim
docker build --no-cache -t $IMAGE ./debian/12/
docker push $IMAGE
docker tag $IMAGE pommib/powerdns:latest
docker push pommib/powerdns:latest

30
debian/12/start.sh vendored Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
# create sqlite database for DNSSEC
if test ! -e /var/lib/powerdns/bind-dnssec-db.sqlite3; then
echo [$0] Initializing /var/lib/powerdns/bind-dnssec-db.sqlite3
/usr/bin/pdnsutil create-bind-db /var/lib/powerdns/bind-dnssec-db.sqlite3
fi
sed -i 's/^# bind-dnssec-db=/bind-dnssec-db=\/var\/lib\/powerdns\/bind-dnssec-db.sqlite3/' /etc/powerdns/pdns.d/bind.conf
# start powerdns server
/usr/sbin/pdns_server --guardian=no --daemon=no --disable-syslog --log-timestamp=no --write-pid=no &
# watch for zone changes
inotifywait -mqre modify --exclude '.*(\.git|.*\.swp)' --format '%w%f' "/var/lib/powerdns/zones/" |
while read -r path; do
zone=$(basename $path)
echo [$0] A modification was detected in $path
echo [$0] Executing \`/usr/bin/pdns_control bind-reload-now $zone\`
/usr/bin/pdns_control bind-reload-now $zone
if pdnsutil show-zone $zone 2>/dev/null | grep -q "Zone is not actively secured"; then
echo [$0] Zone is not actively secured, skipping \`pdnsutil rectify-zone $zone\`
else
echo [$0] DNSSEC secured zone. Executing \`pdnsutil rectify-zone $zone\`
/usr/bin/pdnsutil rectify-zone $zone
fi
done &
wait -n
exit $?

View File

@ -1,15 +0,0 @@
#!/bin/bash
/usr/sbin/pdns_server --guardian=no --daemon=no --disable-syslog --log-timestamp=no --write-pid=no &
inotifywait -mqre modify --exclude '\.git' --format '%w%f' "/var/lib/powerdns/zones/" |
while read -r path; do
zone=$(basename $path)
echo [$0] A modification was detected in $path
echo [$0] Executing \`/usr/bin/pdns_control bind-reload-now $zone\`
/usr/bin/pdns_control bind-reload-now $zone
done &
wait -n
exit $?