I was trying to configure NTP in my Oracle Linux 7 Server. The content of /etc/ntp.conf file was
server NTP_server_1
server NTP_server_2
server NTP_server_3
server 127.127.1.0
fudge 127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
Changed the firewall
[root@apps etc]# firewall-cmd --zone=public --add-service=ntp
success
[root@apps etc]# firewall-cmd --zone=public --permanent --add-service=ntp
success
[root@apps etc]# systemctl start ntpd
[root@apps etc]# systemctl enable ntpd
Now, when i tried to run ntpq -p, got the below error
Error Message:-
localhost: timed out, nothing received
***Request timed out
Solution:-
The error message indicates that the ntpq command can not access localhost.localdomain, it means the localhost can not access the local ntpq service.
The restrict option in /etc/ntp.conf allows you to control which machines can access your server.
added the below line in /etc/ntp.conf file.
[root@apps etc]# grep 127.0.0.1 /etc/ntp.conf
restrict 127.0.0.1
[root@apps etc]# service ntpd restart
Redirecting to /bin/systemctl restart ntpd.service
[root@apps etc]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*LOCAL(0) .LOCL. 10 l 12 64 1 0.000 0.000 0.000