ntp.conf 对等端与服务器

ntp.conf 对等端与服务器

我正在设置一个 NTP 服务器(集群中有五个服务器之一)。我的配置文件:

restrict default kod nomodify notrap
driftfile /var/lib/ntp/drift

server tick.usno.navy.mil
server ntp.colby.edu
server tick.gatech.edu

#peer local-ntp.server.2
#peer local-ntp.server.3
#peer local-ntp.server.4
#peer local-ntp.server.5

对等点被注释掉,因为 a) 它们尚未配置,b) 我不确定是否应该使用它们。

我的想法是,我配置的每个 NTP 服务器都将同步到 USNO 源。如果我们的出站连接出现故障,它们将相互同步,其唯一目的是保持网络时间一致。每个客户端都将配置为使用所有五个本地 NTP 服务器作为server其 ntp.conf 中的指令。

最终,使用密钥身份验证会变得更加复杂,但现在我开始简单。我做对了吗?

答案1

这只是我自己的 NTP 服务器的一些示例,有很多不同的方法可以做到这一点,但这是我的:

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap noquery
restrict -6 default kod nomodify notrap noquery
# Set nopeer when not configuring a peer node.
#restrict default kod nomodify notrap nopeer noquery
#restrict -6 default kod nomodify notrap nopeer noquery
  • 没有查询:防止从 ntpd 转储状态数据
  • 诺特拉普:防止控制消息陷阱服务
  • 不修改:阻止所有尝试修改服务器的 ntpq 查询
  • :阻止所有试图建立对等关联的数据包
  • 科德:设置 Kiss-o-death 数据包以减少不需要的查询
  • -6:通知 ntpd 这是针对 IPV6 主机的限制语句(类似于:ping 与 ping6)

仅允许受信任的网络主机 + localhost

restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 127.0.0.1 #This is optional depending on your local machine's requirements

服务器与对等点之间的区别

  • ntpd 服务从另一台服务器请求时间
  • ntpd 服务与同伴交换时间

NTP服务器A

server 0.pool.ntp.org iburst 
server 1.pool.ntp.org iburst 
peer myntp.server.b

NTP服务器B

server 2.pool.ntp.org iburst 
server 3.pool.ntp.org iburst
peer myntp.server.a
  • 爆发:当服务器无法访问时,在每个轮询间隔,发送八个数据包的突发,而不是通常的一个。只要服务器无法访问,数据包之间的间隔约为 16 秒,以允许调制解调器呼叫完成。一旦服务器可达,数据包之间的间隔约为 2 秒。

对于网络上将连接到 ntp 服务器的其余服务器,您还可以使用以下prefer选项:

server 192.168.1.125 prefer # Prefer your own NTP server over others listed

多服务器/对等 ntp 网络的一个示例。注意每个 ntp 是如何做的不是有相同的servers列出。这是为了更好地使用对等同步。因此,对等同步可以匹配不同时间的结果。

1a  1b     1c  1d     1e  1f      outside
. \ / ...... \ / ...... \ / ..............
   2a ---p--- 2b ---p--- 2c        inside
  /|\        /|\        /|\
 / | \      / | \      / | \
3a 3b 3c   3e 3f 3g   3h 3i 3j

Key: 1 = stratum-1, 2 = stratum-2, 3 = stratum-3, p = peer
#Diagram + more info: http://www.ntp.org/ntpfaq/NTP-s-config-adv.htm

更多信息: http://doc.ntp.org/4.1.1/confopt.htm

希望有帮助。

答案2

我的想法是,我配置的每个 NTP 服务器都将同步到 USNO 源。

所以每个人都有一条server线。这倒是有几分道理。

如果我们的出站连接出现故障,它们将相互同步,其唯一目的是保持网络时间一致。

他们将尝试彼此同步,但行不通。所有时钟源都消失了,因此服务器最终将停止提供时间。只要停电时间不是太长,这可能就没问题。

如果您想要互联网备份(并且您甚至不想放入便宜的无线电/GPS 时钟),那么您可以回退到服务器上的本地时钟。最简单的方法是选择一台服务器并添加:

server 127.127.1.0
fudge 127.127.1.0 stratum 10

该服务器将成为后备服务器,如果所有其他时钟源消失,每个人都会跟随它。 NTP 不允许您设置一组计算机并将它们同步到一起。相反,它试图分发一些“实时”源。 CPU 时钟通常不被视为这样,因此上面的代码行使它发生。

现在,如果您将相同的东西放在所有服务器上,每个服务器都会认为其本地时钟比邻居的更好,并且它们不会一起漂移。

相关内容