allow-query weiter unten im Kapitel „Bind absichern“ und natürlich unter man named.conf
Vorraussetzung: bind als caching only nameserver
„systemd-resolved is not intended to be used on DNS servers. If you’re running a DNS server, you’ll need to disable systemd-resolved before setting up BIND or Unbound instead“
Paket caching-nameserver deinstallieren
/etc/named.conf : CentOS
/etc/bind/named.conf.options : Debian (ab 12)
options {
…
// In der Praxis ist DNSSEC eine gute Sache ... aber im Intranet zum Lernen erst mal aus:
dnssec-validation no;
…
}
named-checkconf rndc reconfig
Eine mit DNSSEC signierte Zone abfragen:
Ein validierender Nameserver sollte bei einer signierten Zone liefern:
dig www.posteo.de @1.1.1.1
flags: … ad
Unser Nameserver sollte das ad-Flag nicht setzen.
/var/named/linuxhotel.de : ( CentOS )/var/lib/named/linuxhotel.de : ( SuSE )/var/cache/bind/linuxhotel.de : ( Debian )$ORIGIN . ; hilft Tippfehler (fehlender . am Ende) zu vermeiden
$TTL 2m ; time to live: 2 Minuten, default wäre 2 Tage
linuxhotel.de. SOA notebook20.linuxhotel.de. root.notebook20.linuxhotel.de. (
1 ; Seriennummer
1h20m ; refresh / 1 Stunde 20 Minuten
1d12h ; retry / 1,5 Tage
1w ; expire / 1 Woche
60s ; negative ttl / 60 Sekunden
)
; Nameserver:
linuxhotel.de. NS notebook20.linuxhotel.de.
; kanonische IP-Adressen:
notebook22.linuxhotel.de. A 192.168.1.222
notebook05.linuxhotel.de. A 192.168.1.205
notebook20.linuxhotel.de. A 192.168.1.220
notebook06.linuxhotel.de. A 192.168.1.206
notebook09.linuxhotel.de. A 192.168.1.209
notebook22.linuxhotel.de. AAAA 2a0f:6480:1:600::222
notebook05.linuxhotel.de. AAAA 2a0f:6480:1:600::205
notebook20.linuxhotel.de. AAAA 2a0f:6480:1:600::220
notebook06.linuxhotel.de. AAAA 2a0f:6480:1:600::206
notebook09.linuxhotel.de. AAAA 2a0f:6480:1:600::209
; Aliase:
peter.linuxhotel.de. CNAME notebook09.linuxhotel.de.
lothar.linuxhotel.de. 60 CNAME notebook05.linuxhotel.de.
heribert.linuxhotel.de. 30 CNAME notebook06.linuxhotel.de.
bjoern.linuxhotel.de. CNAME notebook20.linuxhotel.de.
admin.linuxhotel.de. CNAME notebook22.linuxhotel.de.
named-checkzone -D linuxhotel.de. /var/named/linuxhotel.de
named-checkzone -D linuxhotel.de. /var/lib/named/linuxhotel.de
named-checkzone -D linuxhotel.de. /var/cache/bind/linuxhotel.de
/etc/named.conf : ( SuSE )/etc/named.conf : ( CentOS )/etc/bind/named.conf.local : ( Debian )zone "linuxhotel.de" {
type primary;
file "linuxhotel.de";
};
Konfigdatei und eingetragene Zonen überprüfen:
named-checkconf -z
rndc reconfig
Debian
journalctl -eu named.service
host peter.linuxhotel.de ::1 dig peter.linuxhotel.de @::1 any
Das Format der Zonendatei 3) läßt es auch zu, diese Datei kürzer zu schreiben:
$TTL 2h
@ SOA notebook20.linuxhotel.de. root.notebook20.linuxhotel.de. 1999022301 1d 2h 5w 2d
; Nameserver:
NS notebook20.linuxhotel.de.
; kanonische IP-Adressen:
notebook22 A 192.168.1.222
AAAA 2a0f:6480:1:600::222
notebook05 A 192.168.1.205
AAAA 2a0f:6480:1:600::205
notebook20 A 192.168.1.220
AAAA 2a0f:6480:1:600::220
notebook06 A 192.168.1.206
AAAA 2a0f:6480:1:600::206
notebook09 A 192.168.1.209
AAAA 2a0f:6480:1:600::209
; Aliase:
peter CNAME notebook09
lothar CNAME notebook05
heribert 60 CNAME notebook06
bjoern 30 CNAME notebook20
admin CNAME notebook22
Hier habe ich die Zeitangaben im SOA entsprechend der Empfehlungen des Ripe 4) gewählt.
Bei jeder Änderung der Zonendatei sollte die Seriennummer hochgezählt werden.
named-checkzone -D linuxhotel.de. /var/named/linuxhotel.de
named-checkzone -D linuxhotel.de. /var/lib/named/linuxhotel.de
named-checkzone -D linuxhotel.de. /var/cache/bind/linuxhotel.de
rndc reload linuxhotel.de
/var/named/1.168.192.in-addr.arpa: ( CentOS )/var/lib/named/1.168.192.in-addr.arpa: ( SuSE 10.0 )/var/cache/bind/1.168.192.in-addr.arpa: ( Debian 3.1 )$TTL 2h
@ SOA notebook20.linuxhotel.de. root.notebook20.linuxhotel.de. 1999022301 1d 2h 5w 2d
; Nameserver:
NS notebook20.linuxhotel.de.
; kanonische IP-Adressen
205.1.168.192.in-addr.arpa. IN PTR notebook05.linuxhotel.de.
220.1.168.192.in-addr.arpa. IN PTR notebook20.linuxhotel.de.
206.1.168.192.in-addr.arpa. IN PTR notebook06.linuxhotel.de.
209.1.168.192.in-addr.arpa. IN PTR notebook09.linuxhotel.de.
222.1.168.192.in-addr.arpa. IN PTR notebook22.linuxhotel.de.
named-checkzone -D 1.168.192.in-addr.arpa. /var/named/1.168.192.in-addr.arpa
named-checkzone -D 1.168.192.in-addr.arpa. /var/lib/named/1.168.192.in-addr.arpa
named-checkzone -D 1.168.192.in-addr.arpa. /var/cache/bind/1.168.192.in-addr.arpa
/etc/named.conf : ( SuSE 10.2 )/etc/named.conf : ( CentOS )/etc/bind/named.conf.local : ( Debian 3.1 )zone "1.168.192.in-addr.arpa" {
type primary;
file "1.168.192.in-addr.arpa";
};
named-checkconf -z
rndc reconfig
host 192.168.1.222 ::1 dig -x 192.168.1.222 @::1
Paket:
ipv6calcipv6calc --out revnibbles.arpa --in ipv6addr 2a0f:6480:1:600::222
→ 2.2.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.6.0.1.0.0.0.0.8.4.6.f.0.a.2.ip6.arpa.
/var/named/0.0.6.0.1.0.0.0.0.8.4.6.f.0.a.2.ip6.arpa: ( CentOS )/var/lib/named/0.0.6.0.1.0.0.0.0.8.4.6.f.0.a.2.ip6.arpa: ( SuSE )/var/cache/bind/0.0.6.0.1.0.0.0.0.8.4.6.f.0.a.2.ip6.arpa: ( Debian )$TTL 2h
@ SOA notebook20.linuxhotel.de. root.notebook20.linuxhotel.de. 1999022301 1d 2h 5w 2d
; Nameserver:
NS notebook20.linuxhotel.de.
; kanonische IP-Adressen
2.0.5.0.0.0.0.0.0.0.0.0.0.0.0.0. IN PTR notebook05.linuxhotel.de.
2.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0. IN PTR notebook20.linuxhotel.de.
2.0.6.0.0.0.0.0.0.0.0.0.0.0.0.0. IN PTR notebook06.linuxhotel.de.
2.0.9.0.0.0.0.0.0.0.0.0.0.0.0.0. IN PTR notebook09.linuxhotel.de.
2.2.2.0.0.0.0.0.0.0.0.0.0.0.0.0. IN PTR notebook22.linuxhotel.de.
named-checkzone -D 0.0.6.0.1.0.0.0.0.8.4.6.f.0.a.2.ip6.arpa. /var/named/0.0.6.0.1.0.0.0.0.8.4.6.f.0.a.2.ip6.arpa
named-checkzone -D 0.0.6.0.1.0.0.0.0.8.4.6.f.0.a.2.ip6.arpa. /var/lib/named/0.0.6.0.1.0.0.0.0.8.4.6.f.0.a.2.ip6.arpa
named-checkzone -D 0.0.6.0.1.0.0.0.0.8.4.6.f.0.a.2.ip6.arpa. /var/cache/bind/0.0.6.0.1.0.0.0.0.8.4.6.f.0.a.2.ip6.arpa
/etc/named.conf : ( SuSE )/etc/named.conf : ( CentOS )/etc/bind/named.conf.local : ( Debian )zone "0.0.6.0.1.0.0.0.0.8.4.6.f.0.a.2.ip6.arpa" {
type primary;
file "0.0.6.0.1.0.0.0.0.8.4.6.f.0.a.2.ip6.arpa";
};
named-checkconf -z
rndc reconfig
host 2a0f:6480:1:600::222 ::1 dig -x 2a0f:6480:1:600::222 @::1
/etc/named.conf : ( SuSE, CentOS )/etc/bind/named.conf.local : ( Debian )
mit allow-update:
acl "nsupdate" {
127.0.0.1;
};
zone "linuxhotel.de" {
type primary;
allow-update { "nsupdate"; };
file "linuxhotel.de";
};
zone "1.168.192.in-addr.arpa" {
type primary;
allow-update { "nsupdate"; };
file "1.168.192.in-addr.arpa";
};
oder mit update-policy local:
zone "linuxhotel.de" {
type primary;
update-policy local;
file "linuxhotel.de";
};
named-checkconf
Debian:
chown bind /var/cache/bind/linuxhotel.de
für allow-update:
nsupdate <<EOT server localhost update add notebook23.linuxhotel.de 43200 IN A 192.168.1.223 update add 223.1.168.192.in-addr.arpa 43200 IN PTR notebook23.linuxhotel.de EOT
für update-policy local:
nsupdate -l <<EOT update add notebook23.linuxhotel.de 43200 IN A 192.168.1.223 update add 223.1.168.192.in-addr.arpa 43200 IN PTR notebook23.linuxhotel.de EOT
rndc freeze linuxhotel.de vim linuxhotel.de rndc reload linuxhotel.de rndc thaw linuxhotel.de
Hilfreich ist vielleicht:
~/.bashrc :
function zvi { cd /var/cache/bind rndc freeze $1 vim $1 rndc reload $1 rndc thaw $1 cd - }
Mittlerweile (Version) sind auch die Begriffe primary und secondary als Ersatz für master und slave möglich
masters { ...; }; => primaries { ...; };
type master; => type primary;
type slave; => type secondary;
Erst müssen die Secondary-Nameserver in der Zonendatei des Primarys eingetragen werden:
linuxhotel.de. IN NS notebook04.linuxhotel.de.
Bei SuSE muß noch der Eintrag
notify yes;
in der Datei /etc/named.conf eingetragen werden, oder die Zeile ganz entfernt oder auskommentiert werden.
named-checkzone -i local -D linuxhotel.de /var/lib/named/linuxhotel.de rndc reload linuxhotel.de tail /var/log/messages dig @::1 linuxhotel.de NS
named-checkzone -i local -D linuxhotel.de /var/cache/bind/linuxhotel.de rndc reload linuxhotel.de journalctl -eu bind9 dig @::1 linuxhotel.de NS
Vorraussetzung: Primary funktioniert
dig @<IP-des-Primary> linuxhotel.de AXFR
Ausgabe muss mindestens 2 NS Records enthalten:
/etc/named.conf : ( CentOS 5.3 )
zone "linuxhotel.de" {
type secondary;
file "secondary/linuxhotel.de";
masters { 192.168.1.220; };
};
zone "1.168.192.in-addr.arpa" {
type secondary;
file "secondary/1.168.192.in-addr.arpa";
masters { 192.168.1.220; };
};
/etc/named.conf : ( SuSE 10.0 )/etc/bind/named.conf.local : ( Debian )zone "linuxhotel.de" {
type secondary;
file "secondary/linuxhotel.de";
primaries { 192.168.1.220; };
};
zone "1.168.192.in-addr.arpa" {
type secondary;
file "secondary/1.168.192.in-addr.arpa";
primaries { 192.168.1.220; };
};
Zonendateien im Binärformat kann man mit:
named-checkzone -D -f raw linuxhotel.de secondary/linuxhotel.de
oder
named-compilezone -f raw -F text -o - example.org. /var/cache/bind/secondary/example.org
anzeigen. Wenn man die Zonenfiles lieber im Textformat statt im Binärformat haben will, kann man in die Zone eintragen:
zone "…" {
…
masterfile-format text;
…
Debian:
mkdir /var/cache/bind/secondary chown bind /var/cache/bind/secondary
named-checkconf -z
rndc reconfig
journalctl -eu bind9
ls /var/cache/bind/secondary/{linuxhotel.de,1.168.192.in-addr.arpa}
dig @::1 linuxhotel.de AXFR
named-checkconf -z
rcnamed restart
tail /var/log/messages
ls /var/lib/named/secondary/{linuxhotel.de,1.168.192.in-addr.arpa}
dig @::1 linuxhotel.de AXFR
dig @141.1.1.1 linuxhotel.de +nssearch
/etc/named.conf.local : ( Debian ab 5.0 )/etc/named.conf : ( CentOS ab 5 )zone "linuxhotel.de" IN {
type primary;
file "linuxhotel.de";
forwarders { };
};
Fallstrick: Unbedingt an forwarders denken! Und alle dnssec Optionen ausschalten
/var/named : ( CentOS 5 )
sub05.linuxhotel.de. IN NS ns1.sub05.linuxhotel.de. ns1.sub05.linuxhotel.de. IN A 192.168.150.110
Fallstrick: Seit bind 9.9 werden die empty zones automatisch „aufgefüllt“. Dadurch werden aber PTR-RR für nicht eigene Netze nicht mehr geforwarded
/etc/named.conf.options : ( Debian 8 )
disable-empty-zone "168.192.in-addr.arpa";
Das muss auch auf jedem Delegaten konfiguriert werden
named-checkzone -i local -D linuxhotel.de /var/named/linuxhotel.de
Wie oben, unter „eigene Zonen in bind verwalten“
#!/bin/bash NAMESERVER=$(hostname -f) SUBNET=192.168.1 cat <<HEAD \$TTL 2h @ IN SOA $NAMESERVER. root.$NAMESERVER. ( $(date '+%Y%m%d')01 ; Seriennummer 3h ; refresh 1h ; retry 1w ; expire 1h ; negative ttl ) IN NS $NAMESERVER. HEAD for ip in $(seq 1 254) do getent hosts $SUBNET.$ip | ( read ip name && echo -e "$name.\tIN\tA\t$ip" | expand -t '34 37 43 ' ) done
allow-query weiter unten im Kapitel „Bind absichern“ und natürlich unter man named.conf
service named reloadDebian
service bind9 reload
example.com. 3600 SOA dns.example.com. hostmaster.example.com. (
1999022301 ; serial YYYYMMDDnn
86400 ; refresh ( 24 hours)
7200 ; retry ( 2 hours)
3600000 ; expire (1000 hours)
172800 ) ; minimum ( 2 days)