I want to set up a small network, where a central DHCP server leases IPv4 addresses to the clients. The clients already have their hostnames set and should advertise those to the central DNS server, so both the server and all clients can find each other with that hostname. The DNS server will resolve LAN addresses of the domain "my.domain" and point towards an external DNS server for all other domains (internet).
In my current setup, I have two boxes: 10.0.100.1
is the server (Ubuntu 22.04), where DHCP and DNS are hosted. 10.0.100.2
is configured as a client (Fedora 35) (DHCP sends this fixed IP during my test phase).
This is the client (10.0.100.2
) configuration:
$ cat /etc/hostname
clienthost
$ cat /etc/systemd/network/20-wired.network
[Match]
Name=enp0s31f6
[Network]
LinkLocalAddressing=ipv4
DHCP=ipv4
SendHostname=true
[DHCPv4]
UseDomains=true
$ resolvectl
Global
Protocols: LLMNR=resolve -mDNS -DNSoverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Link 2 (enp0s31f6)
Current Scopes: DNS LLMNR/IPv4
Protocols: +DefaultRoute +LLMNR -mDNS -DNSoverTLS DNSSEC=no/unsupported
Current DNS Server: 10.0.100.1
DNS Servers: 10.0.100.1
DNS Domain: my.domain
The IP 10.0.100.2
is correctly assigned. The client can ping the server (10.0.100.1
) with its IP, hostname or FQDN. I can also see in tcpdump that the hostname is sent to the DHCP server (option 81 Client FQDN). So far so good.
The DHCP server config is supposed to be changed once the initial setup is working, towards handing out IPs from a range. So in the future I won't have fixed-assigned IP addresses for the clients. I will skip showing the rndc key files here. They are identical and placed in the configured locations. The server is configured as follows:
$ cat /etc/hostname
serverhost
$ cat /etc/systemd/network/20-wired.network
[Match]
Name=enp0s31f6
[Network]
LinkLocalAddressing=ipv4
Address=10.0.100.1/16
Gateway=10.0.1.1
DNS=10.0.100.1
[DHCPv4]
UseDomains=my.domain
$ cat /etc/default/isc-dhcp-server
INTERFACESv4="enp0s31f6"
$ cat /etc/dhcp/dhcpd.conf
include "/etc/dhcp/ddns-keys/my-domain.key";
default-lease-time 7200;
max-lease-time 28800;
ddns-updates on;
ddns-update-style standard;
ddns-domainname "my.domain.";
allow-unknown-clients;
authoritative;
zone my.domain. {
primary 10.0.100.1;
key ddns-mydomain;
}
zone 10.0.in-addr.arpa. {
primary 10.0.100.1;
key ddns-mydomain;
}
# only serve the single client box specifically during test phase
subnet 10.0.0.0 netmask 255.255.0.0 {}
host testhost {
hardware ethernet 00:00:00:00:00:00;
fixed-address 10.0.100.2;
option subnet-mask 255.255.0.0;
option routers 10.0.1.1;
option domain-name-servers 10.0.100.1;
option domain-name "my.domain";
filename "pxelinux.0";
}
$ cat /etc/bind/named.conf
include "/etc/bind/keys/my.domain.key";
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";
$ cat /etc/bind/named.conf.options
acl "internal" {
127.0.0.1;
10.0.0.0/16;
};
options {
directory "/var/cache/bind";
recursion yes;
allow-recursion { internal; };
listen-on { 10.0.100.1; };
allow-transfer { none; };
allow-query { internal; };
allow-query-cache { internal; };
forwarders {
1.1.1.1;
};
listen-on-v6 { any; };
};
$ cat /etc/bind/named.conf.local
zone "my.domain" {
type master;
file "/etc/bind/zones/db.my.domain";
update-policy { grant ddns-mydomain name my.domain ANY; };
allow-transfer { none; };
};
zone "0.10.in-addr.arpa" {
type master;
file "/etc/bind/zones/db.0.10";
update-policy { grant ddns-mydomain name my.domain ANY; };
allow-transfer { none; };
};
$ cat /etc/bind/zones/db.my.domain
$TTL 86400
@ IN SOA serverhost.my.domain. admin.my.domain. (
3 ; Serial
28800 ; Refresh
3600 ; Retry
28800 ; Expire
43200 ) ; Negative Cache TTL
;
; name servers - NS records
IN NS serverhost.my.domain.
; A records
serverhost.my.domain. IN A 10.0.100.1
$ cat /etc/bind/zones/db.10.0
$TTL 86400
@ IN SOA serverhost.my.domain. admin.my.domain. (
3 ; Serial
28800 ; Refresh
3600 ; Retry
28800 ; Expire
43200 ) ; Negative Cache TTL
;
; name servers - NS records
IN NS serverhost.my.domain.
; PTR records
100.1 IN PTR serverhost.my.domain. ; 10.0.100.1
I think that should be all relevant configuration. Please let me know if you need something else.
The issue here is that, being on 10.0.100.1 (serverhost)
I can only ping clienthost
via its IP 10.0.100.2
but neither by its hostname nor FQDN. Unfortunately, I don't have a good idea where to start debugging to see if the client hostname is sent to the DNS server and registered or not.
Maybe a potentially unrelated side note: Running the command dhcp-list-lease
on server-host
returns an empty list. The logs show an DHCPACK for 10.0.100.2
but it never shows up in this particular output (which would have been interesting, because there is a "hostname" column).
Edit: It looks like the key might be important after all. Originally I manually created a key with rndc-confgen -a -b 512
, then copied that file to /etc/dhcp/rndc-keys/
. Currently, I generated a new key with ddns-confgen -a -b 512
and placed the key both in /etc/bind/keys/my.domain.key
and in /etc/dhcp/ddns-keys/my.domain.key
(and updated the include statements in the respective configuration files). I still have the rndc key under /etc/bind/rndc.key
which is also picked up by bind9 as the logs show.
Edit2:
Manually running nsupdate
looks like the following:
$ nsupdate -D -k /etc/bind/keys/my.domain.key
> update add clienthost.my.domain 7200 A 10.0.100.2
> send
[...]
Reply from update query:
;; ->>HEADER<<- opcode: UPDATE, status: REFUSED, id: 39064
;; flags: qr; ZONE: 1, PREREQ: 0, UPDATE: 0, ADDITIONAL: 1
;; ZONE SECTION:
;my.domain. IN SOA
;; TSIG PSEUDOSECTION:
ddns-mydomain. 0 ANY TSIG hmac-sha256. 1652972427 300 32 4e/XXXXXXXXXXXXXXXXXXXXXXXX/bmg= 39064 NOERROR 0
And during the manual update the logs show
client @0x7f61d8004cb8 10.0.100.1#39791/key ddns-mydomain: updating zone 'my.domain/IN': update failed: rejected by secure update (REFUSED)