我在CentOS 7机器(虚拟机器)上配置了NTP服务器,并配置了客户端的ntp.conf文件(也是虚拟的并运行CentOS 7)。当我在客户机上使用"systemctl (re)start ntpd“显式启动/重新启动ntpd服务时,NTP同步工作得很好。但是,当我试图通过更改服务器上的时间来测试“自动”同步时,客户端既不会收到“通知”,也不会更新他们的时钟(时钟在ntpd上一次重新启动时保持同步)。我甚至试图从客户端的ntp.conf文件中更改轮询频率,但似乎没有什么效果。我真的很感谢你的帮助。
PS:以下是来自服务器和一个客户端的ntp.conf文件:
# 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
server 127.127.1.0
fudge 127.127.1.0 stratum 1
#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# 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
server 192.168.1.38 #This is the ip address of the server
#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发布于 2016-03-05 12:13:03
我认为您还必须取消对服务器上的restrict行的注释,以使ntp在该网络中可用。然后重新启动ntpd。
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap在客户端,还可以将iburst添加到服务器配置行,这将加快初始时钟同步并重新启动ntpd。
server 192.168.1.38 iburst使用ntpq -p,您可以列出服务器以及是否建立了连接。
发布于 2016-03-05 21:23:04
关于您的配置的几个注意事项:
我使用的一个一般规则是:
您将使用隔离网络(因此无法联系到池服务器)。你可能得依赖硬件时钟了。但是尝试将ntp服务器从VM中取出。
对于客户端,在VM中,我总是在ntp.conf中作为第一行:
tinker panic 0这样,当有一个大的时间偏移时,NTP就不会恐慌。
发布于 2016-03-05 09:19:46
在(Re)启动期间,您可能没有与ntpd同步,但是通过使用ntpdate (您可以检查/etc/sysconfig/ntpdate是否存在)。
此外,他的客户可能对自己的时钟有一些信任,不会做出任何突然的跳跃。ntpd,如果在主时钟中遇到突然的变化(也就是那些对你来说很明显的变化),就会假设主时钟有故障,并继续自己的时间。
由于你没有解释你为什么要这么做,所以如果你不必这样做的话,除了不要和ntp玩以外,很难给出建议。
您还应该反复检查chronyd和/或systemd的时间同步不干扰您的实验。
https://unix.stackexchange.com/questions/267771
复制相似问题