Um eine eigene Domain zu erstellen, wird in diesem HOWTO als Beispiel der Domainname firma.home benutzt. Einzelne Rechner werden zu dieser Domain hinzugefügt. Es wird eine »home«-TLD benutzt, um sicherzustellen, dass niemand ausserhalb des Intranets durch diese Domain gestört wird.
Mit dem folgenden Befehl werden alle notwendigen Pakete für den DNS Server installiert:
sudo apt-get install bind9 bind9utils dnsutils
Nach der Installation wird BIND automatisch gestartet. Mit dem Befehl »dig« kann die Funktion des Servers überprüft werden:
dig www.orf.at ^- in den dnsutils enthalten
; <<>> DiG 9.10.3-P4-Raspbian <<>> www.orf.at ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48785 ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.orf.at. IN A ;; ANSWER SECTION: www.orf.at. 52453 IN A 194.232.104.149 www.orf.at. 52453 IN A 194.232.104.141 www.orf.at. 52453 IN A 194.232.104.150 www.orf.at. 52453 IN A 194.232.104.140 www.orf.at. 52453 IN A 194.232.104.3 www.orf.at. 52453 IN A 194.232.104.139 www.orf.at. 52453 IN A 194.232.104.4 www.orf.at. 52453 IN A 194.232.104.142 ;; Query time: 1 msec ;; SERVER: 192.168.20.20#53(192.168.20.20) ;; WHEN: Tue Nov 20 14:49:09 CET 2018 ;; MSG SIZE rcvd: 156
Diese oder eine ähnliche Anzeige erscheint, wenn alles funktioniert.
Zum Betrieb des Raspberry als DNS Server ist eine fixe IP-Adresse erforderlich.
Die statische IP-Adresse wird in der /etc/dhcpcd.conf eingetragen.
sudo nano /etc/dhcpcd.conf
Am Ende der Datei folgendes eintragen:
# eigenes Netzwerk interface eth0 static ip_address=192.168.20.225/24 static routers=192.168.20.20 static domain_name_servers=192.168.20.20
Es sind natürlich die zum Netzwerk gehörenden Adressen zu verwenden.
Nachdem die Datei gespeichert ist, den Raspberry neu starten …
sudo reboot
… und mit
ifconfig
die Einstellung überprüfen.
Die Konfigurationsdateien liegen im /etc/bind/ Verzeichnis. Die /etc/bind/named.conf importiert nur weitere Dateien wie /etc/bind/named.conf.options, /etc/bind/named.conf.local
und /etc/bind/named.conf.default-zones. Für die eigene Konfiguration und Zonen sollte die /etc/bind/named.conf.local verwendet werden.
Für jede Domäne werden zwei Zonen-Dateien angelegt. Eine für den Forward- und eine für den Reverse-Lookup.
Die Reihenfolge der Dateien ist prinzipiell Nebensache, daher werden sie hier in der Reihenfolge ihres Ablaufes angelegt.
sudo nano /etc/bind/named.conf
/etc/bind/named.conf // This is the primary configuration file for the BIND DNS server named. // // Please read /usr/share/doc/bind9/README.Debian.gz for information on the // structure of BIND configuration files in Debian, *BEFORE* you customize // this configuration file. // // If you are just adding zones, please do that in /etc/bind/named.conf.local include "/etc/bind/named.conf.options"; include "/etc/bind/named.conf.local"; // include "/etc/bind/named.conf.default-zones"; // include "/etc/bind/named.conf.blocked";
In der Datei /etc/bind/named.conf.local werden die Konfiguration der beiden Zonen eingetragen.
sudo nano /etc/bind/named.conf.local
etc/bind/named.conf.local
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
include "/etc/bind/zones.rfc1918";
// Forward-Lookup
zone "firma.home" {
type master;
file "/etc/bind/db.firma.home";
allow-transfer { acl_trusted_transfer; };
};
// Reverse-Lookup
zone "20.168.192.in-addr.arpa" {
type master;
file "/etc/bind/db.20.168.192";
};
In der db.firma.home werden die Forward-Lookup-Datei erstellt.
sudo nano /etc/bind/db.firma.home
/etc/bind/db.firma.home
;
; BIND data file for local loopback interface
;
; $TTL 604800
; @ IN SOA localhost. root.localhost. (
; 2 ; Serial
; 604800 ; Refresh
; 86400 ; Retry
; 2419200 ; Expire
; 604800 ) ; Negative Cache TTL
;
; @ IN NS localhost.
; @ IN A 127.0.0.1
; @ IN AAAA ::1
;
; BIND forward data file for domain firma.home
;
$TTL 604800
@ IN SOA ns1.firma.home. root.ns1.firma.home. (
2018112201 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns1.firma.home. ; nameserver 1
IN A 192.168.20.225 ; nameserver's loop-back address
ns1 IN A 192.168.20.225 ; nameserver self
firma.home IN A 192.168.20.210
www IN CNAME firma.home.
In der db.20.168.192 werden die Reverse-Lookup-Datei erstellt.
sudo nano /etc/bind/db.20.168.192
/etc/bind/db.20.168.192
;
; BIND reverse data file for local loopback interface
;
; $TTL 604800
; @ IN SOA localhost. root.localhost. (
; 1 ; Serial
; 604800 ; Refresh
; 86400 ; Retry
; 2419200 ; Expire
; 604800 ) ; Negative Cache TTL
;
; @ IN NS localhost.
; 1.0.0 IN PTR localhost.
;
; BIND reverse data file for 20.168.192.in-addr.arpa
;
$TTL 604800
@ IN SOA ns1.firma.home. root.ns1.firma.home. (
20181123 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns1.firma.home. ; nameserver
210 IN PTR www.firma.home. ; webserver 192.168.20.210
225 IN PTR ns1.firma.home. ; nameserver
231 IN PTR na1.firma.home. ; NAS Server 1 192.168.20.231
232 IN PTR na2.firma.home. ; NAS Server 2 192.168.20.232
sudo nano /etc/bind/named.conf.options
/etc/bind/named.conf.options
options {
directory "/var/cache/bind";
// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113
// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.
// öffentliche DNS-Server
forwarders {
// see: http://www.ccc.de/de/censorship/dns-howto
// Quelle: https://www.privux.de/raspberry-dns-server/
85.214.20.141; // FoeBud
204.152.184.76; // f.6to4-servers.net, ISC, USA
194.150.168.168; // dns.as250.net; Berlin/Frankfurt
213.73.91.35; // dnscache.berlin.ccc.de
// OpenDNS
208.67.222.222;
208.67.220.220;
};
//========================================================================
// If BIND logs error messages about the root key being expired,
// you will need to update your keys. See https://www.isc.org/bind-keys
//========================================================================
dnssec-validation auto;
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
};
// Der Eintrag 'acl_trusted_transfer' steuert,
// für welche IP’s ein DNS-Zonen-Transfer erlaubt ist.
acl "acl_trusted_transfer" {
none;
};
// Der Eintrag acl_trusted_clients steuert,
// von welchen IP’s aus Anfragen an den DNS-Server erlaubt sind
acl "acl_trusted_clients" {
// localhost (RFC 3330) - Loopback-Device addresses
127.0.0.0/8; // 127.0.0.0 - 127.255.255.255
// Private Network (RFC 1918) - LAN, WLAN etc.
192.168.20.0/24; // 192.168.20.0 - 192.168.20.255
// Private Network (RFC 1918) - VPN etc.
// 10.0.0.0/8; // 10.0.0.0 - 10.255.255.255
};