我遇到了一个指定池指令的 ntp.conf 文件:
# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
pool 0.ubuntu.pool.ntp.org
pool 1.ubuntu.pool.ntp.org
pool 2.ubuntu.pool.ntp.org
pool 3.ubuntu.pool.ntp.org
Run Code Online (Sandbox Code Playgroud)
然而,它在同一个文件中也有服务器指令,我更熟悉。
阅读有关池的信息,我发现它是用来代替服务器的。您应该使用其中一种。
但是,如果 ntp.conf 两者都有会发生什么?一组是否优先于另一组,还是将全部使用?
这是在 Ubuntu 14.04 上,ntpd 是版本 4.2.6p5。
Wof*_*tor 10
mboehn 给出了答案。澄清更多:参见他提到的文件。尤其是最后几行:
池方案使用一个或多个池命令进行配置,其中 DNS 名称指示要从中抽取的池。pool 命令可以多次使用;检测并丢弃重复的服务器。原则上,可以使用包含单行 pool pool.ntp.org 的配置文件。NTP Pool Project提供了有关将 pool 与 server 命令一起使用的说明,这不是最理想的,但适用于 pool 命令之前的旧版本 ntpd。使用最近的 ntpd,考虑将示例中的多个服务器命令替换为单个 pool 命令
我的配置是:
# Specify one or more NTP servers.
pool 0.pool.ntp.org iburst
pool 1.pool.ntp.org iburst
pool 2.pool.ntp.org iburst
pool 3.pool.ntp.org iburst
# Provide your current local time as a default should you temporarly lose Internet connectivity
server 127.127.1.0
fudge 127.127.1.0 stratum 10
Run Code Online (Sandbox Code Playgroud)
当我检查时,我现在有多个 ntp 服务器靠近我的地理位置(荷兰)
$ ntpq -4np
remote refid st t when poll reach delay offset jitter
==============================================================================
0.pool.ntp.org .POOL. 16 p - 64 0 0.000 0.000 0.000
1.pool.ntp.org .POOL. 16 p - 64 0 0.000 0.000 0.000
2.pool.ntp.org .POOL. 16 p - 64 0 0.000 0.000 0.000
3.pool.ntp.org .POOL. 16 p - 64 0 0.000 0.000 0.000
127.127.1.0 .LOCL. 10 l - 64 0 0.000 0.000 0.000
-85.255.214.66 193.190.230.66 2 u 5 64 177 6.937 1.588 1.645
-5.39.184.5 91.148.192.49 3 u 64 64 77 8.907 1.197 1.635
-91.198.87.229 193.79.237.14 2 u 5 64 177 8.447 -0.042 0.894
+37.34.57.151 193.79.237.14 2 u 1 64 177 7.463 0.168 0.297
*91.198.87.118 192.87.110.2 2 u 2 64 177 8.593 0.070 0.384
+88.159.1.197 80.94.65.10 2 u 2 64 177 10.497 0.454 0.213
+213.154.236.182 213.136.0.252 2 u 67 64 77 8.793 0.455 2.391
#178.21.23.127 91.121.157.10 3 u 66 64 77 9.129 -0.911 1.541
#213.109.127.195 193.79.237.14 2 u 66 64 77 11.766 -7.330 1.501
+213.154.229.24 80.50.231.226 2 u 4 64 177 8.496 0.121 0.538
-217.77.132.1 213.136.0.252 2 u 2 64 177 7.026 -0.782 1.253
#87.253.148.92 195.13.1.153 3 u 4 64 177 7.338 -3.859 0.964
-94.228.220.14 193.67.79.202 2 u - 64 177 8.347 2.797 1.019
Run Code Online (Sandbox Code Playgroud)
据我在来源中看到的,ntpd
大致以相同的方式处理池的成员和单个服务器:它将它们添加到对等点列表中。
所有这些对等点都被 使用ntpd
。
池机制的神奇之处在于循环 DNS:由于ntpd
通过 DNS 解析池名称,来自 DNS 查询的响应是单个节点,每次请求解析时可能会有所不同。