Ubuntu NTP服务器:找不到适合同步的服务器

Ubuntu NTP服务器:找不到适合同步的服务器

我正在使用 NTP 将 4 个 Raspberry Pi 时钟与 Ubuntu 服务器同步(全部位于本地网络中,通过以太网连接)。所有设备均处于离线状态,因此服务器仅监听其本地时钟;真实时间并不重要。当我重新启动主机并启动 NTP 服务器时,客户端在几分钟内无法同步:命令

sudo ntpdate NTP-server-host

抛出错误:

6月18日18:42:55 ntpdate[1546]: 没有找到适合同步的服务器

NTP 服务器主机对应服务器的IP)几分钟后它就可以工作了。这仅在重新启动后才会发生。可能是什么原因?服务器正在运行并且防火墙端口已打开。

服务器上的 ntp.conf:

driftfile /var/lib/ntp/ntp.drift

# Leap seconds definition provided by tzdata
leapfile /usr/share/zoneinfo/leap-seconds.list

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

server 127.127.1.0
fudge 127.127.1.0 stratum 10

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Needed for adding pool entries
restrict source notrap nomodify noquery

客户端上的 ntp.conf:

driftfile /var/lib/ntp/ntp.drift

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable


# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
pool 0.debian.pool.ntp.org iburst
pool 1.debian.pool.ntp.org iburst
pool 2.debian.pool.ntp.org iburst
pool 3.debian.pool.ntp.org iburst

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Needed for adding pool entries
restrict source notrap nomodify noquery

# Use specified ntp server
server NTP-server-host prefer iburst

我只修改了ntp.conf文件,并没有完全理解它们。如果有更深入了解的人能够告诉我其中的错误,那就太好了。谢谢!

答案1

这是完全正常的。 NTP 需要几个周期才能稳定并开始服务时间。客户端部分也需要几个周期来接受服务器是否稳定并且能够提供时间。

你可以通过运行这个来查看你的 Ubuntu 服务器发生了什么

ntpq -pn

我还建议您从客户端的配置中删除池服务器,因为您所说的所有系统都在脱机运行。

相关内容