KEA DHCP DDNS Netzwerk und Serveradministration: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Zeile 1: Zeile 1:
−
=Auf unserem Nameserver=
+
= Dynamisches DNS mit Kea und BIND9 =
−
;Key erzeugen
+
 
−
*cd /etc/bind
+
Diese Anleitung beschreibt die Verknüpfung von Kea DHCPv4 mit einem BIND9 Nameserver (10.88.213.21) über den Kea-DHCP-DDNS Daemon unter Verwendung von TSIG-Keys.
−
*tsig-keygen -a HMAC-SHA256 it213.key >> /etc/bind/named.conf.local
+
 
−
;Keys zuweisen
+
== Technischer Ablauf und Theorie ==
−
*cat /etc/bind/named.conf.local  
+
 
−
//tsig-keygen -a HMAC-SHA256 it213.key
+
Das Dynamic DNS (DDNS) Update sorgt für die automatische Synchronisation zwischen DHCP-Leases und DNS-Records.
−
key "it213.key" {
+
 
−
    algorithm hmac-sha256;
+
* Der Client sendet beim DHCP-Request seinen Hostnamen (Option 12).
−
    secret "Y8zioRKf3L0lWlhZ5FReSdegcnWVD53IIqT9PPle5cU=";
+
* Kea-DHCPv4 weist eine IP zu und generiert einen Name Change Request (NCR).
−
};  
+
* Durch das qualifying-suffix wird der Hostname zum Fully Qualified Domain Name (FQDN) ergänzt (z.B. client.it213.int).
−
+
* Der Kea-DHCP-DDNS Daemon empfängt den NCR auf Port 53001, signiert ihn mit dem TSIG-Key und sendet ein Update-Paket an den BIND9-Server.
−
zone "it213.int" {
+
* BIND9 prüft die Signatur (allow-update) und aktualisiert Forward-Zone (A-Record) sowie Reverse-Zone (PTR-Record).
−
    type master;
+
 
−
    file "/var/cache/bind/it213.int";
+
== Konfiguration des Nameservers ==
−
    allow-update { key "it213.key"; };
+
 
−
};  
+
Auf dem Nameserver (ns.it213.int) wird der TSIG-Key erstellt und den Zonen zugewiesen.
−
+
 
−
zone "213.88.10.in-addr.arpa" {
+
* Key erzeugen:
−
    type master;
+
cd /etc/bind
−
    file "/var/cache/bind/213.88.10.in-addr.arpa";
+
tsig-keygen -a HMAC-SHA256 it213.key >> /etc/bind/named.conf.local
−
    allow-update { key "it213.key"; };
+
 
−
};  
+
* Zonenkonfiguration anpassen:
−
+
cat /etc/bind/named.conf.local
−
zone "213.26.172.in-addr.arpa" {
+
 
−
    type master;
+
key "it213.key" {
−
    file "/var/cache/bind/213.26.172.in-addr.arpa";
+
    algorithm hmac-sha256;
−
    allow-update { key "it213.key"; };
+
    secret "Y8zioRKf3L0lWlhZ5FReSdegcnWVD53IIqT9PPle5cU=";
−
};
+
};
−
:Name neustarten
+
 
−
*systemctl restart named
+
zone "it213.int" {
−
=Auf dem Kea Server=
+
    type master;
−
;Wenn noch nicht geschehen installation de ddns servers
+
    file "/var/cache/bind/it213.int";
−
*sudo apt update
+
    allow-update { key "it213.key"; };
−
*sudo apt install kea-dhcp-ddns-server
+
};
−
;kea-dhcp4.conf anpassen.
+
 
−
*cat kea-dhcp4.conf
+
zone "213.88.10.in-addr.arpa" {
−
<pre>
+
    type master;
 +
    file "/var/cache/bind/213.88.10.in-addr.arpa";
 +
    allow-update { key "it213.key"; };
 +
};
 +
 
 +
zone "213.26.172.in-addr.arpa" {
 +
    type master;
 +
    file "/var/cache/bind/213.26.172.in-addr.arpa";
 +
    allow-update { key "it213.key"; };
 +
};
 +
 
 +
* Dienst neu starten:
 +
systemctl restart bind9
 +
 
 +
== Konfiguration des Kea Servers ==
 +
 
 +
* Installation des DDNS-Dienstes:
 +
sudo apt update
 +
sudo apt install kea-dhcp-ddns-server
 +
 
 +
* Konfiguration DHCPv4 (/etc/kea/kea-dhcp4.conf):
 
{
 
{
 
   "Dhcp4": {
 
   "Dhcp4": {
 
     "interfaces-config": {
 
     "interfaces-config": {
 
       "interfaces": [ "enp0s3" ]
 
       "interfaces": [ "enp0s3" ]
−
    },
 
−
    "control-socket": {
 
−
      "socket-type": "unix",
 
−
      "socket-name": "/run/kea/kea4-ctrl-socket"
 
−
    },
 
−
    "lease-database": {
 
−
      "type": "memfile",
 
−
      "persist": true,
 
−
      "name": "/var/lib/kea/kea-leases4.csv"
 
 
     },
 
     },
 
     "dhcp-ddns": {
 
     "dhcp-ddns": {
Zeile 61: Zeile 72:
 
     "ddns-update-on-renew": true,
 
     "ddns-update-on-renew": true,
 
     "ddns-qualifying-suffix": "it213.int",
 
     "ddns-qualifying-suffix": "it213.int",
−
    "valid-lifetime": 7200,
 
−
    "option-data": [
 
−
      { "name": "domain-name-servers", "data": "10.88.213.21" },
 
−
      { "name": "domain-name", "data": "it213.int" },
 
−
      { "name": "domain-search", "data": "it213.int" }
 
−
    ],
 
 
     "subnet4": [
 
     "subnet4": [
 
       {
 
       {
Zeile 72: Zeile 77:
 
         "subnet": "172.26.213.0/24",
 
         "subnet": "172.26.213.0/24",
 
         "pools": [ { "pool": "172.26.213.100 - 172.26.213.200" } ],
 
         "pools": [ { "pool": "172.26.213.100 - 172.26.213.200" } ],
−
        "option-data": [ { "name": "routers", "data": "172.26.213.1" } ],
 
 
         "reservations": [
 
         "reservations": [
 
           {
 
           {
Zeile 80: Zeile 84:
 
           }
 
           }
 
         ]
 
         ]
−
      },
 
−
      {
 
−
        "id": 2,
 
−
        "subnet": "10.88.213.0/24",
 
−
        "pools": [ { "pool": "10.88.213.50 - 10.88.213.100" } ],
 
−
        "option-data": [ { "name": "routers", "data": "10.88.213.1" } ]
 
−
      },
 
−
      {
 
−
        "id": 3,
 
−
        "subnet": "10.213.1.0/24",
 
−
        "pools": [ { "pool": "10.213.1.50 - 10.213.1.100" } ],
 
−
        "option-data": [ { "name": "routers", "data": "10.213.1.1" } ]
 
 
       }
 
       }
 
     ],
 
     ],
Zeile 98: Zeile 90:
 
         "name": "kea-dhcp4",
 
         "name": "kea-dhcp4",
 
         "output_options": [ { "output": "/var/log/kea/kea-dhcp4.log" } ],
 
         "output_options": [ { "output": "/var/log/kea/kea-dhcp4.log" } ],
−
         "severity": "DEBUG",
+
         "severity": "INFO"
−
        "debuglevel": 99
 
 
       }
 
       }
 
     ]
 
     ]
 
   }
 
   }
 
}
 
}
−
<pre>
+
 
−
;kea-dhcp-ddns.conf erstellen
+
* Konfiguration DDNS-Daemon (/etc/kea/kea-dhcp-ddns.conf):
−
*cat kea-dhcp-ddns.conf
 
−
<pre>
 
 
{
 
{
 
   "DhcpDdns": {
 
   "DhcpDdns": {
 
     "ip-address": "127.0.0.1",
 
     "ip-address": "127.0.0.1",
 
     "port": 53001,
 
     "port": 53001,
−
    "control-socket": {
 
−
      "socket-type": "unix",
 
−
      "socket-name": "/run/kea/kea-ddns-ctrl-socket"
 
−
    },
 
 
     "tsig-keys": [
 
     "tsig-keys": [
 
       {
 
       {
Zeile 150: Zeile 135:
 
         "name": "kea-dhcp-ddns",
 
         "name": "kea-dhcp-ddns",
 
         "output_options": [ { "output": "/var/log/kea/kea-ddns.log" } ],
 
         "output_options": [ { "output": "/var/log/kea/kea-ddns.log" } ],
−
         "severity": "DEBUG",
+
         "severity": "INFO"
−
        "debuglevel": 99
 
 
       }
 
       }
 
     ]
 
     ]
 
   }
 
   }
 
}
 
}
−
<pre>
 
−
=Restart und Debuggen=
 
−
hier schreib noch dinge rein
 
−
start stop debugg gucken om der eintrag drin ist usw ... hinweise im betrieb debug level wiedr runter etc ...
 
  
−
bitte oben am anfang den technischen ablauf erklären ansonsten sollte so passen denken damiot man es verstreht
+
== Restart und Debugging ==
 +
 
 +
* Dienste neu starten:
 +
systemctl restart kea-dhcp4-server kea-dhcp-ddns-server
 +
 
 +
* Fehleranalyse:
 +
Bei Problemen das Logging auf "severity": "DEBUG" und "debuglevel": 99 setzen.
 +
Logs live einsehen:
 +
tail -f /var/log/kea/kea-dhcp4.log
 +
tail -f /var/log/kea/kea-ddns.log
 +
 
 +
* Überprüfung der Einträge im DNS:
 +
dig @10.88.213.21 client.it213.int
 +
dig @10.88.213.21 -x 172.26.213.99
 +
 
 +
== Wichtige Hinweise ==
 +
 
 +
* Schreibrechte: BIND benötigt Schreibrechte im Verzeichnis /var/cache/bind/ für die Journal-Dateien (.jnl).
 +
* Suffix: Ohne ddns-qualifying-suffix in der kea-dhcp4.conf schlägt der Zonen-Match im DDNS-Daemon fehl.
 +
* AppArmor: Bei Zugriffsproblemen (Unable to open file) AppArmor-Profile prüfen oder deaktivieren.

Version vom 31. März 2026, 13:35 Uhr

Dynamisches DNS mit Kea und BIND9

Diese Anleitung beschreibt die Verknüpfung von Kea DHCPv4 mit einem BIND9 Nameserver (10.88.213.21) über den Kea-DHCP-DDNS Daemon unter Verwendung von TSIG-Keys.

Technischer Ablauf und Theorie

Das Dynamic DNS (DDNS) Update sorgt für die automatische Synchronisation zwischen DHCP-Leases und DNS-Records.

  • Der Client sendet beim DHCP-Request seinen Hostnamen (Option 12).
  • Kea-DHCPv4 weist eine IP zu und generiert einen Name Change Request (NCR).
  • Durch das qualifying-suffix wird der Hostname zum Fully Qualified Domain Name (FQDN) ergänzt (z.B. client.it213.int).
  • Der Kea-DHCP-DDNS Daemon empfängt den NCR auf Port 53001, signiert ihn mit dem TSIG-Key und sendet ein Update-Paket an den BIND9-Server.
  • BIND9 prüft die Signatur (allow-update) und aktualisiert Forward-Zone (A-Record) sowie Reverse-Zone (PTR-Record).

Konfiguration des Nameservers

Auf dem Nameserver (ns.it213.int) wird der TSIG-Key erstellt und den Zonen zugewiesen.

  • Key erzeugen:

cd /etc/bind tsig-keygen -a HMAC-SHA256 it213.key >> /etc/bind/named.conf.local

  • Zonenkonfiguration anpassen:

cat /etc/bind/named.conf.local

key "it213.key" {

   algorithm hmac-sha256;
   secret "Y8zioRKf3L0lWlhZ5FReSdegcnWVD53IIqT9PPle5cU=";

};

zone "it213.int" {

   type master;
   file "/var/cache/bind/it213.int";
   allow-update { key "it213.key"; };

};

zone "213.88.10.in-addr.arpa" {

   type master;
   file "/var/cache/bind/213.88.10.in-addr.arpa";
   allow-update { key "it213.key"; };

};

zone "213.26.172.in-addr.arpa" {

   type master;
   file "/var/cache/bind/213.26.172.in-addr.arpa";
   allow-update { key "it213.key"; };

};

  • Dienst neu starten:

systemctl restart bind9

Konfiguration des Kea Servers

  • Installation des DDNS-Dienstes:

sudo apt update sudo apt install kea-dhcp-ddns-server

  • Konfiguration DHCPv4 (/etc/kea/kea-dhcp4.conf):

{

 "Dhcp4": {
   "interfaces-config": {
     "interfaces": [ "enp0s3" ]
   },
   "dhcp-ddns": {
     "enable-updates": true,
     "server-ip": "127.0.0.1",
     "server-port": 53001
   },
   "ddns-send-updates": true,
   "ddns-override-no-update": true,
   "ddns-override-client-update": true,
   "ddns-update-on-renew": true,
   "ddns-qualifying-suffix": "it213.int",
   "subnet4": [
     {
       "id": 1,
       "subnet": "172.26.213.0/24",
       "pools": [ { "pool": "172.26.213.100 - 172.26.213.200" } ],
       "reservations": [
         {
           "hw-address": "08:00:27:5d:76:5d",
           "ip-address": "172.26.213.99",
           "hostname": "client"
         }
       ]
     }
   ],
   "loggers": [
     {
       "name": "kea-dhcp4",
       "output_options": [ { "output": "/var/log/kea/kea-dhcp4.log" } ],
       "severity": "INFO"
     }
   ]
 }

}

  • Konfiguration DDNS-Daemon (/etc/kea/kea-dhcp-ddns.conf):

{

 "DhcpDdns": {
   "ip-address": "127.0.0.1",
   "port": 53001,
   "tsig-keys": [
     {
       "name": "it213.key",
       "algorithm": "HMAC-SHA256",
       "secret": "Y8zioRKf3L0lWlhZ5FReSdegcnWVD53IIqT9PPle5cU="
     }
   ],
   "forward-ddns": {
     "ddns-domains": [
       {
         "name": "it213.int.",
         "key-name": "it213.key",
         "dns-servers": [ { "ip-address": "10.88.213.21" } ]
       }
     ]
   },
   "reverse-ddns": {
     "ddns-domains": [
       {
         "name": "213.88.10.in-addr.arpa.",
         "key-name": "it213.key",
         "dns-servers": [ { "ip-address": "10.88.213.21" } ]
       },
       {
         "name": "213.26.172.in-addr.arpa.",
         "key-name": "it213.key",
         "dns-servers": [ { "ip-address": "10.88.213.21" } ]
       }
     ]
   },
   "loggers": [
     {
       "name": "kea-dhcp-ddns",
       "output_options": [ { "output": "/var/log/kea/kea-ddns.log" } ],
       "severity": "INFO"
     }
   ]
 }

}

Restart und Debugging

  • Dienste neu starten:

systemctl restart kea-dhcp4-server kea-dhcp-ddns-server

  • Fehleranalyse:

Bei Problemen das Logging auf "severity": "DEBUG" und "debuglevel": 99 setzen. Logs live einsehen: tail -f /var/log/kea/kea-dhcp4.log tail -f /var/log/kea/kea-ddns.log

  • Überprüfung der Einträge im DNS:

dig @10.88.213.21 client.it213.int dig @10.88.213.21 -x 172.26.213.99

Wichtige Hinweise

  • Schreibrechte: BIND benötigt Schreibrechte im Verzeichnis /var/cache/bind/ für die Journal-Dateien (.jnl).
  • Suffix: Ohne ddns-qualifying-suffix in der kea-dhcp4.conf schlägt der Zonen-Match im DDNS-Daemon fehl.
  • AppArmor: Bei Zugriffsproblemen (Unable to open file) AppArmor-Profile prüfen oder deaktivieren.