我试图弄清楚为什么没有任何东西可以连接到在 Ubuntu 18.04 上运行的 LAN NTP 服务。
$ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
85.195.227.162 205.46.178.169 2 u 46m 273m 1 194.116 6.535 0.000
time2.google.co .GOOG. 1 u 46m 273m 1 46.291 -4.626 0.000
$ service ntp status
● ntp.service - Network Time Service
Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-07-09 18:35:37 PDT; 18s ago
Docs: man:ntpd(8)
Process: 21985 ExecStart=/usr/lib/ntp/ntp-systemd-wrapper (code=exited, status=0/SUCCESS)
Main PID: 22005 (ntpd)
Tasks: 2 (limit: 4915)
CGroup: /system.slice/ntp.service
└─22005 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 112:117
Jul 09 18:35:37 ntpd[22002]: Command line: /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 112:117
Jul 09 18:35:37 systemd[1]: Started Network Time Service.
Jul 09 18:35:37 ntpd[22005]: proto: precision = 0.054 usec (-24)
Jul 09 18:35:37 ntpd[22005]: Listen and drop on 0 v6wildcard [::]:123
Jul 09 18:35:37 ntpd[22005]: Listen and drop on 1 v4wildcard 0.0.0.0:123
Jul 09 18:35:37 ntpd[22005]: Listen normally on 2 lo 127.0.0.1:123
Jul 09 18:35:37 ntpd[22005]: Listen normally on 3 eno1 192.168.1.79:123
Jul 09 18:35:37 ntpd[22005]: Listen normally on 4 lo [::1]:123
Jul 09 18:35:37 ntpd[22005]: Listen normally on 5 eno1 [fe80::56bf:64ff:fe9c:487e%2]:123
Jul 09 18:35:37 ntpd[22005]: Listening on routing socket on fd #22 for interface updates
$ cat /etc/ntp.conf
#server time.google.com
server pool.ntp.org minpoll 14 maxpoll 16
server time.google.com minpoll 14 maxpoll 16
server ntp.research.gov minpoll 14 maxpoll 16
当我尝试从本地设备连接时,出现无法连接的情况(我输入的是服务器的本地 IP)。
在 Windows 上,我收到“Windows 同步时发生错误”
而如果我在同一台 Windows 机器上使用 Powershell 运行它,它似乎能够连接?
> w32tm /stripchart /computer:192.168.1.79 /samples:3
Tracking 192.168.1.79 [192.168.1.79:123].
Collecting 3 samples.
The current time is 7/9/2020 6:41:13 PM.
18:41:13, d:+00.0006430s o:+00.6759665s [ | * ]
18:41:15, d:+00.0006612s o:+00.6760327s [ | * ]
18:41:17, d:+00.0006455s o:+00.6760841s [ | * ]
我在 ubuntu 服务器上确实设置了如下防火墙规则:
sudo ufw allow from any to any port 123 proto udp
编辑:更多信息,其中一个客户端(wdmycloud)报告了此错误:
sntp[1065]: sock_cb: 192.168.1.79 not in sync, skipping this server
答案1
好的,经过几天的尝试,当然,一旦我放弃并在这里发帖寻求帮助,我就会偶然找到答案。
防火墙规则需要允许出去以及
sudo ufw allow out from any to any port 123
另外,在 /etc/ntp.conf 中需要添加爆发到每个池
$ cat /etc/ntp.conf
pool us.pool.ntp.org minpoll 14 maxpoll 16 iburst
server time.google.com minpoll 14 maxpoll 16 iburst
server ntp.research.gov minpoll 14 maxpoll 16 iburst
pool ntp.ubuntu.com minpoll 14 maxpoll 16 iburst