DHCP Server mit automatischem DNS Zonen Update
Will man das für einen Client der sich via DHCP eine IP Adresse holt auch automatisch ein DNS Eintrag erstellt wird, der ist hier genau richtig.
Diese Anleitung nutzt den weit verbreitenden ISC DHCPd und den Bind9 DNS Server.
Wenn jemand ein kleineres Setup bevorzugt sollte sich DNSMASQ anschauen.
Installation DHCPD und Bind9
aptitude update aptitude install isc-dhcp-server bind9
Konfiguration des DNS Servers bind9
Anlegen der Zonen Dateien
/var/lib/bind/db.laub.loc
ORIGIN .
$TTL 604800     ; 1 week
example.org            IN SOA  laub-backup.laub.loc root.laub-backup.laub.loc(
                                2011012101 ; serial
                                28800      ; refresh (8 hours)
                                7200       ; retry (2 hours)
                                604800     ; expire (1 week)
                                39600      ; minimum (11 hours)
                                )
                        NS      laub-backup.laub.loc.
$ORIGIN laub.loc.
laub-backup             A       192.168.52.240
#server                  A       10.0.0.1
#desktop                 A       10.0.0.11
#laptop1                 A       10.0.0.21
#laptop2                 A       10.0.0.22
/var/lib/bind/db.192.168.52
$ORIGIN .
$TTL 604800     ; 1 week
52.168.192.in-addr.arpa         IN SOA  laub-backup.laub.loc. root.laub-backup.laub.loc. (
                                2011012101 ; serial
                                28800      ; refresh (8 hours)
                                7200       ; retry (2 hours)
                                604800     ; expire (1 week)
                                39600      ; minimum (11 hours)
                                )
                        NS      laub-backup.laub.loc.
$ORIGIN 52.168.192.in-addr.arpa.
240             PTR     laub-backup.laub.loc
#1            PTR    server.example.org.
#11            PTR    desktop.example.org.
#21            PTR    laptop1.example.org.
#22            PTR    laptop2.example.org.
Nun werden die Zonen in die Bind Konfiguration aufgenommen:
/etc/bind/named.conf.local
zone “laub.loc” {
  type master;
  file "/var/lib/bind/db.laub.loc";
  allow-update { localhost; };
};
zone “52.168.192.in-addr.arpa” {
  type master;
  file "/var/lib/bind/db.192.168.52";
  allow-update { localhost; };
};
Nun noch die Rechte auf die Dateien vergeben:
Konfiguration DHCP Server
Der DHCP Server wird mittels folgenden Konfigurationsdateien Konfiguriert:
/etc/default/isc-dhcp-server
# Defaults for dhcp initscript # sourced by /etc/init.d/dhcp # installed at /etc/default/isc-dhcp-server by the maintainer scripts # # This is a POSIX shell fragment # # On what interfaces should the DHCP server (dhcpd) serve DHCP requests? # Separate multiple interfaces with spaces, e.g. "eth0 eth1". INTERFACES="eth0"
Hier kann man festlegen auf welchem Interface der DHCPd Server seinen Dienst anbietet. Hier sollte gerade wenn man noch ein externes Interface hat wirklich nur das, oder die internen Interface angegeben werden.
/etc/dhcp/dhcpd.conf
server-name Server;
option domain-name “example.org”;
option subnet-mask 255.255.255.0;
option domain-name-servers 10.0.0.1; # der oder die DNS-Server
default-lease-time 86400; # 24 h
max-lease-time 172800;    # 48 h
authoritative;
ddns-update-style interim;
ignore client-updates;
subnet 10.0.0.0 netmask 255.255.255.0 {
      range 10.0.0.101 10.0.0.199; # DHCP-Adressen werden zwischen .101 und .199 vergeben
      option broadcast-address 10.0.0.255;
      option routers 10.0.0.200; # das Gateway ins Internet, bspw. der DSL-Router
      ddns-domainname “gast.example.org”;
      zone example.org. {
      primary 127.0.0.1;
      }
      zone 0.0.10.in-addr.arpa. {
      primary 127.0.0.1;
      }
}
