Bind – Kurzanleitung

Veröffentlichung 4. Juli 2018 @ 22:38
Letzte Änderung 3. März 2024 @ 12:04

Überblick

  • Autoritativer Nameserver / Primary Nameserver
  • Reverse-Lookup durch Provider
  • Secondary Nameserver bei Provider
  • Serverstandort bei Provider
  • [Optional] Ausschließlich IPv4

Voraussetzungen

Netzwerk

  • Domain / Zone example.com
  • E-Mail Zonenadministrator hostmaster@example.com
  • (Beispiel-)Host www.example.com
  • IP-Adresse x.x.x.x
  • Mailserver mail.example.com
  • Nameserver ns.example.com
  • Ports named 53, named localhost 953
  • Secondary Nameserver ns.provider.com

Software

  • Bind 9.10.3 #named -v
  • Ubuntu Server 16.04.04 LTS #lsb_release -a

Ordner und Dateien

  • Installation /etc/bind, /var/lib/bind, /var/cache/bind
  • Konfiguration /etc/bind/named.conf.local, /etc/bind/named.conf.options, /etc/default/bind9, /var/lib/bind/db.example.com
  • Log /var/log/syslog
  • systemd /lib/systemd/system/bind9.service, /lib/systemd/system/bind9-pkcs11.service, /lib/systemd/system/bind9-resolvconf.service

Bind installieren

apt install bind9

Konfigurationsoptionen setzen

options {
  allow-transfer {
    none; #Transfer pro Zone freischalten
  };
  directory "/var/cache/bind";
  dnssec-validation auto; #DNSSEC-Validierung mit KSK (Key Signing Key) der DNS-Rootzone als Vertrauensanker
  hostname none; #Ausgabe Hostname unterdrücken
  recursion no; #als Authoritive DNS-Server arbeiten
  version none; #Ausgabe Bind-Version unterdrücken
};

Zone example.com konfigurieren

Zonendateien in /var/lib/bind statt /etc/bind wegen AppArmor:

...
# /var/lib/bind is for dynamically updated zone (and journal) files.
...
zone "example.com" {
  allow-transfer {
    any; #für Secondary Nameserver
  };
  file "/var/lib/bind/db.example.com";
  type master;
};

Forward-Lookup-Zonendatei für example.com erstellen

[Optional] SOA-Parameter des Providers ermitteln

dig example.com SOA
...
example.com. 86400 IN SOA xxx.xxx.xxx. xxx.xxx.xxx. xxxxxxxxxx 28800 1800 604800 86400
...

Zonendatei anlegen

$TTL 86400
@ SOA ns.example.com. hostmaster.example.com. (
      2018070401 ; Serial
      28800      ; Refresh
      1800       ; Retry
      604800     ; Expire
      86400 )    ; Negative Cache TTL
@ NS  ns.example.com.
@ NS  ns.provider.com.
@ A   x.x.x.x
@ MX  10 mail.example.com.
mail  A x.x.x.x
ns    A x.x.x.x
www   A x.x.x.x
*     A x.x.x.x ; Wildcard für übrige Hosts

Bind-Konfiguration testen

Syntax der Konfigurationsdateien /etc/bind/named.conf* prüfen

named-checkconf -jz

Syntax und Integrität der Zonendatei prüfen

named-checkzone example.com /var/lib/bind/db.example.com

Bind starten / neustarten und Status abfragen

systemctl start bind9
#systemctl restart bind9
journalctl --unit bind9.service
systemctl status bind9.service

DNS-Einträge abfragen

dig @ns.example.com example.com ANY #alle DNS-Records bei Nameserver ns.example.com
dig example.com ANY #alle DNS-Records
dig -x x.x.x.x #Reverse DNS (von Provider)

DNS-Server mit SuperTool testen

https://mxtoolbox.com/SuperTool.aspx?action=dns%3aexample.com&run=toolpage

[Optional] Bind-Cache testen

rndc dumpdb -cache #Cache in Datei /var/cache/bind/named_dump.db schreiben
less /var/cache/bind/named_dump.db
rndc flush #Cache löschen

[Optional] Ausschließlich IPv4 verwenden

Startoptionen ändern

...
#OPTIONS="-u bind"
OPTIONS="-4 -u bind"

Konfigurationsoptionen ergänzen

options {
  ...
  listen-on-v6 {
    none;
  };
};

Quellen

https://deepthought.isc.org/article/AA-01182/205/DNSSEC-Validation-the-Easy-Way.html
https://ftp.isc.org/isc/bind9/cur/9.10/doc/arm/
https://ftp.isc.org/isc/bind9/cur/9.10/doc/arm/man.named-checkconf.html
https://ftp.isc.org/isc/bind9/cur/9.10/doc/arm/man.named-checkzone.html
http://manpages.ubuntu.com/manpages/xenial/man1/dig.1.html
http://manpages.ubuntu.com/manpages/xenial/man8/rndc.8.html
https://mxtoolbox.com/