NTP时间同步失败:origin timestamp不匹配错误原因咨询
NTP时间同步错误分析与解决方案
问题现象
配置NTP时间同步时,systemctl status ntp日志中反复出现时间戳不匹配错误,导致时间同步失败:
systemctl status ntp ● ntp.service - Network Time Service Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2024-06-17 18:45:33 CST; 15h ago Docs: man:ntpd(8) Process: 3507107 ExecStart=/usr/lib/ntp/ntp-systemd-wrapper (code=exited, status=0/SUCCESS) Main PID: 3507115 (ntpd) Tasks: 2 (limit: 76806) Memory: 1.4M CGroup: /system.slice/ntp.service └─3507115 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 129:136 6月 18 10:13:22 ubuntu ntpd[3507115]: receive: Unexpected origin timestamp 0xea1b6bc2.0199208b does not match aorg 0000000000.00000000 from server@10.104.62.39 xmt 0xea1b6ae3.fc01fc59 6月 18 10:13:22 ubuntu ntpd[3507115]: receive: Unexpected origin timestamp 0xea1b6bc2.0199208b does not match aorg 0000000000.00000000 from server@10.104.62.39 xmt 0xea1b6ae3.fbfcb776 6月 18 10:13:22 ubuntu ntpd[3507115]: receive: Unexpected origin timestamp 0xea1b6bc2.0199208b does not match aorg 0000000000.00000000 from server@10.104.62.39 xmt 0xea1b6ae3.fc01fc59 6月 18 10:14:27 ubuntu ntpd[3507115]: receive: Unexpected origin timestamp 0xea1b6c03.0198af4a does not match aorg 0000000000.00000000 from server@10.104.62.39 xmt 0xea1b6b24.fc112846 6月 18 10:14:27 ubuntu ntpd[3507115]: receive: Unexpected origin timestamp 0xea1b6c03.0198af4a does not match aorg 0000000000.00000000 from server@10.104.62.39 xmt 0xea1b6b24.fc0fee8a 6月 18 10:14:27 ubuntu ntpd[3507115]: receive: Unexpected origin timestamp 0xea1b6c03.0198af4a does not match aorg 0000000000.00000000 from server@10.104.62.39 xmt 0xea1b6b24.fc112846 6月 18 10:15:33 ubuntu ntpd[3507115]: receive: Unexpected origin timestamp 0xea1b6c45.019a0a1e does not match aorg 0000000000.00000000 from server@10.104.62.39 xmt 0xea1b6b66.fc281ba7 6月 18 10:15:33 ubuntu ntpd[3507115]: receive: Unexpected origin timestamp 0xea1b6c45.019a0a1e does not match aorg 0000000000.00000000 from server@10.104.62.39 xmt 0xea1b6b66.fc234076 6月 18 10:15:33 ubuntu ntpd[3507115]: receive: Unexpected origin timestamp 0xea1b6c45.019a0a1e does not match aorg 0000000000.00000000 from server@10.104.62.39 xmt 0xea1b6b66.fc281ba7 6月 18 10:16:38 ubuntu ntpd[3507115]: receive: Unexpected origin timestamp 0xea1b6c86.0199db9f does not match aorg 0000000000.00000000 from server@10.104.62.39 xmt 0xea1b6ba7.fc48db3b
当前NTP配置文件(/etc/ntp.conf)内容:
cat /etc/ntp.conf | grep -v "#" driftfile /var/lib/ntp/ntp.drift 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 10.104.62.39 prefer server time.windows.com restrict -4 default kod notrap nomodify nopeer noquery limited restrict -6 default kod notrap nomodify nopeer noquery limited restrict 127.0.0.1 restrict ::1 restrict source notrap nomodify noquery restrict 10.26.22.0 mask 255.255.255.0 restrict 10.26.21.0 mask 255.255.255.0
错误含义解析
日志中Unexpected origin timestamp ... does not match aorg 0000000000.00000000的含义:
- NTP协议中,客户端发送请求时会记录请求的发送时间戳(xmt),服务器响应时会携带源时间戳(origin timestamp)——这个值应该等于客户端之前发送的请求时间戳。
aorg是客户端本地记录的、对应该响应的请求的源时间戳,这里显示为全0,说明客户端根本没有记录过对应请求的时间戳,或者服务器返回的响应包和客户端发出的请求不匹配。- 这种情况会导致ntpd无法验证响应的有效性,直接丢弃该响应,最终时间同步失败。
可能原因
- 目标NTP服务器(10.104.62.39)自身配置异常:比如服务器未正确同步自身时间,或者NTP服务返回的数据包格式错误。
- 网络问题:请求包丢失后,服务器延迟返回旧响应;或者网络中的防火墙、代理设备修改了NTP数据包的时间戳字段。
- 本地ntpd进程状态异常:请求记录丢失,无法匹配响应与请求。
解决步骤
- 检查NTP Peer状态
运行ntpq -p查看服务器同步状态:- 关注
10.104.62.39的reach值,正常应该是377(表示最近8次请求都成功);如果值较低或为0,说明网络连通性有问题。
- 关注
- 验证本地ntpd功能
临时注释掉配置文件中的server 10.104.62.39 prefer,重启ntpd服务:
等待几分钟后查看systemctl restart ntpntpq -p和timedatectl status,如果能同步time.windows.com,说明本地ntpd功能正常,问题出在目标服务器或网络。 - 检查目标NTP服务器状态
若能登录10.104.62.39,运行ntpq -p确认该服务器自身是否已正确同步时间;若服务器未同步,需先修复其NTP配置。 - 排查网络问题
用tcpdump抓包分析NTP请求与响应:
检查请求包的发送时间戳(xmt)和响应包的源时间戳是否一致,排查是否存在丢包、篡改或延迟过大的情况。tcpdump port 123 host 10.104.62.39 - 重置本地ntpd状态
重启本地ntpd服务,清空临时请求记录:systemctl stop ntp rm -f /var/lib/ntp/ntp.drift systemctl start ntp
内容的提问来源于stack exchange,提问作者TommyShelby
相关产品推荐
相关产品推荐

