当 ntpd.conf 中有本地 ntpd 服务器引用时,如何更新我的机器时间

当 ntpd.conf 中有本地 ntpd 服务器引用时,如何更新我的机器时间

我的 FreeIPA 服务器的日期时间偏移了大约 10 分钟,导致登录失败。该ntpd服务正常运行。我检查了配置,发现 freeIPA 已添加本地服务器来同步我的ntpd.conf文件中的时间。

ntpd.conf这是FreeIPA添加的内容:

### Added by IPA Installer ###
server 127.127.1.0 iburst
fudge 127.127.1.0 stratum 10

我也有标准的 centos 池。

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

但是,ntpd 服务不会使用公共 ntp 池,也不会纠正漂移,因为它查看本地 ntpd 服务器。

当我尝试强制ntpd更新其时间时,从 FreeIPA 添加的这些行得到了以下结果:

service ntpd stop
ntpd -gq
ntpd: time slew +0.000000s
service ntpd start

删除 FreeIPA 添加的行ntpd.conf可使更新正常工作:

 service ntpd stop
 ntpd -gq
 ntpd: time set -543.065651s
 service ntpd start

我的问题是:

  1. 如何让 ntpd 正确使用外部 ntpd 时钟?
  2. 看来 FreeIPA 也对我的客户端做了这些更改(它将 ntp 服务器指向我的 ipa 服务器,然后还设置了一个本地 ntpd 服务器)。这也导致所有客户端都无法正确更新,我该如何正确修复这个问题?
  3. 本地服务器的这些新增配置能直接删除吗?这似乎只是过去几年遗留下来的?https://www.redhat.com/archives/freeipa-users/2013-February/msg00260.html

完整配置:

# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).

driftfile /var/lib/ntp/drift

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery

# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

#broadcast 192.168.1.255 autokey        # broadcast server
#broadcastclient                        # broadcast client
#broadcast 224.0.1.1 autokey            # multicast server
#multicastclient 224.0.1.1              # multicast client
#manycastserver 239.255.254.254         # manycast server
#manycastclient 239.255.254.254 autokey # manycast client

# Enable public key cryptography.
#crypto

includefile /etc/ntp/crypto/pw

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8

# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats

# Disable the monitoring facility to prevent amplification attacks using ntpdc
# monlist command when default restrict does not include the noquery flag. See
# CVE-2013-5211 for more details.
# Note: Monitoring will not be disabled with the limited restriction flag.
disable monitor

### Added by IPA Installer ###

### Added by IPA Installer ###

### Added by IPA Installer ###
server 127.127.1.0 iburst
fudge 127.127.1.0 stratum 10

答案1

由于 10 的含糊其辞,它确实不应该选择本地时钟。

您可以尝试prefer使用其中一个服务器池的选项来尝试强制它选择互联网时间源:

server 0.centos.pool.ntp.org iburst prefer

进行更改并重新启动服务后,当您运行ntpq -pn查询服务状态时,您应该会在首选池旁边看到一个星号(*)。

相关内容