I recently setup NTP server on my environment, along with DNS. And when I configure an NTP client, I see the below behaviour:
[root@template ~]# host mydns.mydomain.ops
mydns.mydomain.ops has address 10.10.5.2
[root@template ~]# grep mydns.mydomain.ops /etc/ntp.conf
server 0.mydns.mydomain.ops iburst
[root@template ~]# systemctl status ntpd
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2021-12-20 16:38:54 IST; 10min ago
Process: 724 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 737 (ntpd)
CGroup: /system.slice/ntpd.service
└─737 /usr/sbin/ntpd -u ntp:ntp -g
[root@template ~]# ntpq -pn
10.10.5.2: timed out, nothing received
***Request timed out
[root@template ~]#
However, if I happen to replace the FQDN in my /etc/ntp.conf with the IP address (and ofcourse restart the service), it works just perfectly fine:
[root@template ~]# grep 10.10.5.2 /etc/ntp.conf
server 10.10.5.2 iburst
[root@template ~]# ntpq -pn
remote refid st t when poll reach delay offset jitter
==============================================================================
*10.10.5.2 192.46.15.60 3 u 44 64 377 0.251 11.240 4.310
I'm kind of confused how DNS resolution is failing only for NTP. Is there something else I'm overlooking? Please help ...