DNS Linux - Netzwerk und Serveradministration - Skript
Installation
- apt install bind9
Stop
- systemctl stop bind9
Start
- systemctl start bind9
Restart
- systemctl restart bind9
Status
- systemctl status bind9
Hauptkonfiguration
Standardmäßig ist die Konfiguration von bind9 auf mehrere Dateien aufgeteilt:
/etc/bind/named.conf
#Diese Datei inkludiert einfach nur die anderen 3 Dateien
Algemeine Option zum Nameserver
include "/etc/bind/named.conf.options";
Hier kommen die eignen Zonen rein
include "/etc/bind/named.conf.local";
Hier die Default Zonen
include "/etc/bind/named.conf.default-zones";
/etc/bind/named.conf.options
Berechtigungen und Einschränkungen
options {
directory "/var/cache/bind";
forwarders { 192.168.hs.88; };
allow-query { 0.0.0.0/0; };
allow-recursion { 10.88.2xx.0/24; 172.16.2xx.0/24; 172.17.2xx.0/24; 127.0.0.1; };
allow-transfer {127.0.0.1; };
dnssec-validation no;
listen-on-v6 { none; };
listen-on { any; };
};
Testen
- named-checkconf
Restart
- systemctl restart bind9
Konfigurations
/etc/bind/named.conf.default-zones
#Standardzonen
zone "." {
type hint;
file "/usr/share/dns/root.hints";
};
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};
/etc/bind/named.conf.local
//Standardmässig leer
//Hier werden die sogenanten Zonen angelegt.
zone "it2xx.int" {
type master;
file "it2xx.int";
};
zone "2xx.88.10.in-addr.arpa" {
type master;
file "2xx.88.10.in-addr.arpa";
};
Konfigurationsverzeichnis
/var/cache/bind
Forward Zonen Datei ohne Secundary DNS
- Die Zonendatei enthält die Informationen zu den Adressen, und sieht folgendermaßen aus:
- vi /var/cache/bind/it2xx.int
$TTL 300 ; 5 minutes
@ IN SOA ns.it2xx.int. technik.it2xx.int. (
2025062501 ; serial
14400 ; refresh (4 hours)
3600 ; retry (1 hour)
3600000 ; expire (5 weeks 6 days 16 hours)
86400 ; minimum (1 day)
)
NS ns.it2xx.int.
MX 10 mail.it2xx.int.
ns IN A 10.88.2xx.21
sftp IN A 10.88.2xx.4
mail IN A 10.88.2xx.34
www IN A 10.88.2xx.41
proxy IN A 10.88.2xx.51
smb IN A 172.16.2xx.2
fw IN A 192.168.hs.2xx
Check
- named-checkzone it213.int /var/cache/bind/it213.int
zone it213.int/IN: loaded serial 2011090204 OK
Reverse Zonen Datei
- vi /var/cache/bind/2xx.88.10.in-addr.arpa
$TTL 300 ; 5 minutes
@ IN SOA ns.it2xx.int. technik.it2xx.int. (
2025062501 ; serial
14400 ; refresh (4 hours)
3600 ; retry (1 hour)
3600000 ; expire (5 weeks 6 days 16 hours)
86400 ; minimum (1 day)
)
IN NS ns.it2xx.int.
21 IN PTR ns.it2xx.int.
4 IN PTR sftp.it2xx.int.
34 IN PTR mail.it2xx.int.
41 IN PTR www.it2xx.int.
51 IN PTR proxy.it2xx.int.
Check
- named-checkzone 213.88.10.in-addr.arpa /var/cache/bind/213.88.10.in-addr.arpa
zone 213.88.10.in-addr.arpa/IN: loaded serial 2011090204 OK
Finaler Check
- dig @127.0.0.1 it213.int -t axfr
; <<>> DiG 9.18.33-1~deb12u2-Debian <<>> @127.0.0.1 it213.int -t axfr ; (1 server found) ;; global options: +cmd it213.int. 300 IN SOA ns.it213.int. technik.it213.int. 2025062501 14400 3600 3600000 86400 it213.int. 300 IN NS ns.it213.int. it213.int. 300 IN MX 10 mail.it213.int. fw.it213.int. 300 IN A 192.168.10.213 mail.it213.int. 300 IN A 10.88.213.34 ns.it213.int. 300 IN A 10.88.213.21 proxy.it213.int. 300 IN A 10.88.213.51 sftp.it213.int. 300 IN A 10.88.213.4 smb.it213.int. 300 IN A 172.16.213.2 www.it213.int. 300 IN A 10.88.213.41 it213.int. 300 IN SOA ns.it213.int. technik.it213.int. 2025062501 14400 3600 3600000 86400 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) (TCP) ;; WHEN: Wed Jun 25 15:54:36 CEST 2025 ;; XFR size: 11 records (messages 1, bytes 318)
- dig @127.0.0.1 213.88.10.in-addr.arpa -t axfr
; <<>> DiG 9.18.33-1~deb12u2-Debian <<>> @127.0.0.1 213.88.10.in-addr.arpa -t axfr ; (1 server found) ;; global options: +cmd 213.88.10.in-addr.arpa. 300 IN SOA ns.it213.int. technik.it213.int. 2025062501 14400 3600 3600000 86400 213.88.10.in-addr.arpa. 300 IN NS ns.it213.int. 21.213.88.10.in-addr.arpa. 300 IN PTR ns.it213.int. 34.213.88.10.in-addr.arpa. 300 IN PTR mail.it213.int. 4.213.88.10.in-addr.arpa. 300 IN PTR sftp.it213.int. 41.213.88.10.in-addr.arpa. 300 IN PTR www.it213.int. 51.213.88.10.in-addr.arpa. 300 IN PTR proxy.it213.int. 213.88.10.in-addr.arpa. 300 IN SOA ns.it213.int. technik.it213.int. 2025062501 14400 3600 3600000 86400 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) (TCP) ;; WHEN: Wed Jun 25 15:56:11 CEST 2025 ;; XFR size: 8 records (messages 1, bytes 289)
ändern der /etc/resolv.conf
nameserver 127.0.0.1 search it2xx.int
Logs
- Aktualisierte Log von named
- journalctl -fu named
- Die letzten 20 Log Zeilen vom named
- journalctl -n 20 -u named
Sind die Ports geöffnet
- ss -lntpu | grep named