NTPd 组播设置

iXô*_*iXô 2 ntpd ntp

我需要设置一个 ntp 多播客户端。为了能够检查我的配置是否良好,我尝试设置一个 NTP 多播服务器。

我的设置:

  • Centos 7 的 2 个 VM,是最新的
  • 我在 virtualbox 中使用了 2 个虚拟机,我已经使用 promicius 模式进行了设置:允许所有

我的问题是:

  • 在服务器上,组播条目报告为层 16;层与多播相关吗?客户是否会因为层低而拒绝这个?如何为多播服务器强制降低层级?
  • 我的客户端似乎没有看到我的服务器,即使我的密钥文件是相同的并且我已经信任双方的密钥 1。

使用孤儿指令,它似乎不会降低多播地址的报告层:

ntpq -n -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*192.165.10.2    192.165.10.109   4 u   14   64  377    0.454    2.267   1.479
 224.0.1.1       .MCST.          16 u    -   64    0    0.000    0.000   0.000
Run Code Online (Sandbox Code Playgroud)

而且我的客户端似乎仍然无法在 224.0.1.1 地址上找到服务器。

我已经检查了服务器 vm、我的主机和客户端 vm,他们都看到了服务器多播消息(对于 vm:使用 tcpdump,对于主机:使用wireshark)。

在客户端,使用ntpq -n -p将返回这个:

No association ID's returned
Run Code Online (Sandbox Code Playgroud)

在客户端,我的配置文件已经注释了所有限制指令,而我只有这些(还有一些更像漂移文件等):

multicastclient 224.0.1.1
keys /etc/ntp/keys
trustedkey 1
Run Code Online (Sandbox Code Playgroud)

ntpd 客户端日志给了我这个:

systemd[1]: Starting Network Time Service...
ntpd[11076]: ntpd 4.2.6p5@1.2349-o Tue Jun 23 15:38:18 UTC 2020 (1)
systemd[1]: Started Network Time Service.
ntpd[11077]: proto: precision = 0.052 usec
ntpd[11077]: 0.0.0.0 c01d 0d kern kernel time sync enabled
ntpd[11077]: ntp_io: estimated max descriptors: 1024, initial socket boundary: 16
ntpd[11077]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
ntpd[11077]: Listen and drop on 1 v6wildcard :: UDP 123
ntpd[11077]: Listen normally on 2 lo 127.0.0.1 UDP 123
ntpd[11077]: Listen normally on 3 enp0s3 192.165.10.107 UDP 123
ntpd[11077]: Listen normally on 4 lo ::1 UDP 123
ntpd[11077]: Listen normally on 5 enp0s3 fe80::a00:27ff:fec1:cc1 UDP 123
ntpd[11077]: Listening on routing socket on fd #22 for interface updates
ntpd[11077]: Listen normally on 6 multicast 224.0.1.1 UDP 123
ntpd[11077]: Joined 224.0.1.1 socket to multicast group 224.0.1.1
ntpd[11077]: 0.0.0.0 c016 06 restart
ntpd[11077]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
ntpd[11077]: 0.0.0.0 c011 01 freq_not_set
ntpd[11077]: io_setbclient: Opened broadcast client on interface #3 enp0s3
Run Code Online (Sandbox Code Playgroud)

tel*_*coM 5

层 16 表示 NTP 服务器不相信它具有有效时间,因为它没有连接到任何配置的时间源。为了使ntpd服务器系统信任系统的本地时钟作为时间源,有两种选择:

  • 现代方法是在多播服务器上的文件中指定tos orphantos orphanwait关键字ntp.conf
# If orphaned, serve others with this stratum.
tos orphan 8
# Wait for this many seconds before starting to serve others (default is 300 s)
tos orphanwait 1
Run Code Online (Sandbox Code Playgroud)
  • 较旧的方法是告诉ntpd使用本地时钟作为组播服务器上的假时间源。此配置不应与真实 NTP 时间源一起使用,因为它可能会导致ntpd相信本地时钟而不是真实 NTP 源,除非已配置足够数量的外部源并且彼此之间足够同步以进行输出- 投票给 127.127.1.0 伪源(它总是与本地时钟完全一致,因此它往往会受到ntpd选择算法的过度青睐)。
server 127.127.1.0 iburst
fudge 127.127.1.0 stratum 8
Run Code Online (Sandbox Code Playgroud)

以 开头的 IP 地址127.127.*是特殊的ntpd:它们指的是内置于ntpd.

这两种方法都将使系统基于本地不同步的系统时钟使用第 8 层通过 NTP 提供 UTC 时间,因此任何与真实 NTP 时间源(=第 7 层或更少)有合理直接连接的系统都应该更喜欢它这个。

每当您的版本ntpd支持它时,建议使用较新的方式,因为使用它,如果/当您向系统添加实时 NTP 时间源时,您不必记住删除伪源。