CentOS/RHEL ntpstat 命令显示未同步

ntpstat 命令输出显示“unsynchronised”:

# ntpstat 
unsynchronised
time server re-starting

“ntpq -p”命令输出显示未选择任何 ntp 服务器:

# ntpq -p
==========================================
   remote           refid      st t when poll reach   delay   offset  jitter
===============================================
ntp-server   .INIT.          16 u    -   16    0    0.000    0.000   0.000
ntp-server   .INIT.          16 u    -   16    0    0.000    0.000   0.000

as 命令输出显示两个 ntp 服务器都被拒绝:

# ntpq> as
ind assID status conf reach auth condition last_event cnt
===========================================================
1 54459 8000 yes yes none reject
2 54460 8000 yes yes none reject

rv 命令输出显示两个 ntp 服务器都处于“unreach”状态:

# ntpq> rv 54459
assID=54459 status=8000 unreach, conf, no events,
srcadr=, srcport=123, dstadr=x.x.x.x, dstport=123, leap=11,
..........
# ntpq> rv 54460
assID=54460 status=8000 unreach, conf, no events,
srcadr=, srcport=123, dstadr=x.x.x.x, dstport=123, leap=11,
..........
on  It Road.com

解决方案

ntp 配置文件中的“restrict default ignore”阻止远程 ntp 服务器的访问。
ntp配置文件如下:

# cat /etc/ntp.conf
restrict default kod nomodify notrap nopeer noquery ignore
restrict -6 default kod nomodify notrap nopeer noquery ignore
...

“restrict default ignore”不仅会阻止所有客户端的访问,还会阻止所有远程 ntp 服务器的访问。

解决方案1

1.编辑/etc/ntp.conf,修改配置,允许所有机器无限制访问:

restrict default kod nomodify notrap nopeer noquery ignore
restrict -6 default kod nomodify notrap nopeer noquery ignore

修改成

restrict default
restrict -6 default
  1. 重启ntpd服务:
# service ntpd restart
  1. 等待几分钟,然后运行“ntpq -p”以检查它是否有效。

解决方案2

  1. 编辑 /etc/ntp.conf 并修改配置以允许来自特定 ntp 服务器的无限制访问:

restrict default kod nomodify notrap nopeer noquery ignore
restrict -6 default kod nomodify notrap nopeer noquery ignore

修改成:

restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict xxx.xxx.xxx.xxx (IP address of a specific ntp server)
  1. 重启ntpd服务:
# service ntpd restart
  1. 等待几分钟,然后运行“ntpq -p”以检查它是否有效。
日期:2020-09-17 00:14:21 来源:oir作者:oir