Die Anleitung gilt nur für eine lokale Installation, also beide auth NS laufen beim Kunden und machen interne und externe Views.
Wir nutzen keine ldap anbindung hier sondern nur kea dhcp für clients. Ansonsten sind FW und Router komplett raus aus DNS, es wird nur auf die beiden NS gezeigt.
Easy
apt install bind9
bind:bind is fine on all files, make sure db/ folders have group setgid and group write!
drwxrwsr-x 2 bind bind 4096 Jul 16 01:47 db-external
drwxr-sr-x 2 bind bind 4096 Jul 16 00:06 db-external.bak
drwxrwsr-x 2 bind bind 4096 Jul 15 16:57 db-internal
Looks good! Still if you want, make sure bind cannot write zone configs, etc.
will totally mess with your group writes still as bind is not allowed to write in /etc/bind WHICH IS GOOD
/etc/apparmor.d/usr.sbin.named
# /etc/bind should be read-only for bind
# /var/lib/bind is for dynamically updated zone (and journal) files.
# /var/cache/bind is for slave/stub data, since we're not the origin of it.
# See /usr/share/doc/bind9/README.Debian.gz
# fixed zones / data here RO
/etc/bind/** r,
# dynamic zones here - see deploy, will survive reboot
/var/lib/bind/** rw,
/var/lib/bind/ rw,
# zones we handle as secondary here, may be removed on reboot
/var/cache/bind/** lrw, # l means permission to hard link here
/var/cache/bind/ rw,
deployzone.sh
#!/bin/sh
set -e
if [ "$#" -ne 2 ]; then
echo "Usage: $0 view zone"
exit 1
fi
VIEW="$1"
ZONE="$2"
SRC="/etc/bind/db-${VIEW}/${ZONE}.zone"
DST="/var/lib/bind/db-${VIEW}/${ZONE}.zone"
cd "$(dirname "$SRC")"
# 1. Checke die statische Zone und extrahiere ihre Serial (Feld 5 in der "loaded serial"-Zeile)
SRC_SERIAL=$(named-checkzone "$ZONE" "$SRC" | awk '/loaded serial/ {print $5}')
if [ -z "$SRC_SERIAL" ]; then
echo "FATAL: Zone check failed or could not extract serial from $SRC"
exit 1
fi
# 2. Frage den laufenden BIND nach der aktuellen Live-Serial
# (Wir fangen Fehler ab, falls die Zone noch gar nicht existiert, z.B. beim ersten Deployment)
RUNNING_SERIAL=$(rndc zonestatus "$ZONE" IN "$VIEW" 2>/dev/null | grep -i '^serial:' | awk '{print $2}' || true)
# 3. Vergleiche die Serials und erhöhe die statische Datei, falls nötig
if [ -n "$RUNNING_SERIAL" ]; then
if [ "$SRC_SERIAL" -le "$RUNNING_SERIAL" ]; then
NEW_SERIAL=$((RUNNING_SERIAL + 1))
echo "-> Live-Serial ($RUNNING_SERIAL) ist >= Datei-Serial ($SRC_SERIAL)."
echo "-> Erhöhe Serial in $SRC auf $NEW_SERIAL..."
# Ersetze nur das allererste Vorkommen der alten Serial in der Textdatei (das ist der SOA-Record)
sed -i "0,/\b${SRC_SERIAL}\b/s/\b${SRC_SERIAL}\b/${NEW_SERIAL}/" "$SRC"
# Sicherheits-Check: Ist die Zone nach dem Ersetzen immer noch fehlerfrei?
if ! named-checkzone "$ZONE" "$SRC" >/dev/null; then
echo "FATAL: Zone check failed after updating serial in $SRC!"
exit 1
fi
else
echo "-> Datei-Serial ($SRC_SERIAL) ist bereits größer als Live-Serial ($RUNNING_SERIAL)."
fi
else
echo "-> Keine Live-Zone gefunden (Erstes Deployment?). Serial bleibt $SRC_SERIAL."
fi
# zone might be dynamic
rndc freeze "$ZONE" IN "$VIEW"
# makes sure dest dir exists
install -d -o bind -g bind -m 2775 "/var/lib/bind/db-${VIEW}"
# installs the zone file
install -o bind -g bind -m 0640 "$SRC" "$DST"
# now bind can mess with it and your /etc/bind .zone stays clean
# kannste mit thaw weglassen
# rndc reload "$ZONE" IN "$VIEW"
rndc thaw "$ZONE" IN "$VIEW"
echo "Deployed $ZONE in view $VIEW"
Notes on journal files:
- .jnl wird bei freeze/thaw nicht gelöscht, nur die .zone in /var/lib/bind wird aktualisiert
- .jnl.signed enthält die aktuellen DS schlüssel - möglichst nicht löschen sonst werden bei dynamischer signierung neue Schlüssel erstellt, die Verteilung bis zur TLD dauert dann wieder
- .jbk ist das Journal-Backup bevor .jnl geschrieben wird
# config and source zones
chown -R root:bind /etc/bind
find /etc/bind -type d -exec chmod 0750 {} \;
find /etc/bind -type f -exec chmod 0640 {} \;
# runtime signing/journal state
chown -R bind:bind /var/lib/bind
find /var/lib/bind -type d -exec chmod 2770 {} \;
find /var/lib/bind -type f -exec chmod 0640 {} \;
photonen.krei.se
80.152.183.179 2003:a:67f:b77c:1::11 nptv6
2003:a:67f:b77c:0000:0000:0000:0001 for PTR 2003:a:67f:b77c: WAN -- use this as external when using nptv6! 2003:a:67f:b77c:1::11 is grace when using nptv6
2003:a:637:7c00: customer LAN
2003:a:637:7c01:126:11::1 would be grace 2003:a:637:7c01:126::3 would be subcentral
elektronen.krei.se
87.128.44.79 2003:a:37f:ac23::3 nptv6
2003:a:37f:ac23:0000:0000:0000:0001 for PTR
2003:a:37f:ac23: WAN - 2003:a:37f:ac23::3 is subcentral when using nptv6
2003:a:32c:2300: customer LAN
2003:a:032c:2301:126:11::1 would be grace 2003:a:032c:2301:126::3 would be subcentral
rndc zonestatus domain.tld IN view
/etc/bind/zones.d/reserve.conf
this is for ipv4 makes no real sense here, can make sense to do so for ipv6
zone "120.139.47.78.in-addr.arpa" { type master; file "/etc/bind/db/db.reverseip"; allow-transfer { 95.216.149.44; 2a01:4f9:c010:1ea8::1;}; also-notify { 95.216.149.44; 2a01:4f9:c010:1ea8::1;}; };