ntpd ignoring resolv.conf

From: Maks <maks_at_miller-it.net>
Date: Tue, 24 Sep 2024 06:16:16 UTC
Hi there,

I'm on FreeBSD 14.1-RELEASE-p5.

I noticed that on my computer ntpd does not synchronize the time correctly.

In /var/log/messages I get the following errors:

Sep 24 07:38:38 ufr-t14 ntpd[33259]: error resolving pool 
0.de.pool.ntp.org: Name does not resolve (8)
Sep 24 07:38:39 ufr-t14 ntpd[33259]: error resolving pool 
1.de.pool.ntp.org: Name does not resolve (8)
Sep 24 07:38:40 ufr-t14 ntpd[33259]: error resolving pool 
0.freebsd.pool.ntp.org: Name does not resolve (8)
Sep 24 07:38:41 ufr-t14 ntpd[33259]: error resolving pool 
2.freebsd.pool.ntp.org: Name does not resolve (8)

With the help of people from the FreeBSD forum 
(https://forums.freebsd.org/threads/no-name-resolution-within-ntpd.95065/) 
I found out that ntpd tries to connect to a DNS server on the loopback 
interface and not the one configured in resolv.conf.

When I restart ntpd, tcpdump shows the following:

# tcpdump -i lo0 -nl -vvv port 53
tcpdump: listening on lo0, link-type NULL (BSD loopback), snapshot 
length 262144 bytes
07:40:45.091595 IP (tos 0x0, ttl 64, id 62263, offset 0, flags [none], 
proto UDP (17), length 63, bad cksum 0 (->8974)!)
     127.0.0.1.53752 > 127.0.0.1.53: [bad udp cksum 0xfe3e -> 0xfed9!] 
63331+ A? 0.de.pool.ntp.org. (35)
07:40:45.091627 IP6 (flowlabel 0xe3ce5, hlim 64, next-header UDP (17) 
payload length: 43) ::1.62965 > ::1.53: [bad udp cksum 0x003e -> 
0xd8dd!] 63331+ A? 0.de.pool.ntp.org. (35)
07:40:45.091645 IP (tos 0x0, ttl 64, id 62264, offset 0, flags [none], 
proto UDP (17), length 63, bad cksum 0 (->8973)!)
     127.0.0.1.65074 > 127.0.0.1.53: [bad udp cksum 0xfe3e -> 0xd29f!] 
63331+ A? 0.de.pool.ntp.org. (35)
07:40:45.091662 IP6 (flowlabel 0x8f26d, hlim 64, next-header UDP (17) 
payload length: 43) ::1.61503 > ::1.53: [bad udp cksum 0x003e -> 
0xde93!] 63331+ A? 0.de.pool.ntp.org. (35)
07:40:46.092343 IP (tos 0x0, ttl 64, id 62265, offset 0, flags [none], 
proto UDP (17), length 63, bad cksum 0 (->8972)!)

There is no nameserver entry for 127.0.0.1 in my res resolv.conf:

# cat /etc/resolv.conf
# Generated by resolvconf
search rz.privat
nameserver 192.168.88.1
nameserver 132.230.200.200
nameserver 132.230.201.111

For some strange reason ntpd ignores resolv.conf and expects a DNS 
server on the loopback interface.

As a workaround I configured local_unbound in rc.conf. Now, with a DNS 
server running on the loopback interface and without configuring it in 
resolv.conf, ntpd is working correctly.

Is there a way to configure ntpd in a way that it uses the DNS servers 
configured in resolv.conf?

Thanks in advance.

Markus