Ubuntu

NTP 同步在 syslog 中不可見

  • December 10, 2019

我正在嘗試為我們的 LAN 設置本地 NTP 伺服器。我可以執行ntpdate server_ip手動更新時間。但是,ntp 守護程序似乎沒有將任何內容記錄到 syslog 中,因此我無法判斷是否有任何系統同步過。

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
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
logconfig =syncall +clockall
# Specify one or more NTP servers.
# 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.
server  10.0.1.201 iburst minpoll 3 maxpoll 4
restrict -4 default kod notrap nomodify nopeer
restrict -6 default kod notrap nomodify nopeer
# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.
# Local users may interrogate the ntp server more closely.
#restrict 127.0.0.1
#restrict ::1
# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust

# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255
# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
disable auth
#broadcastclient

我可能會錯過什麼?

NTP 通常在 syslog 中非常安靜/無聲。如果它出現,事情就會出錯。如果您的硬體時鍾正常工作,則不需要在啟動期間修改您的時鐘。使用正確的設置,如果需要,它可以替換 ntpdate 來設置啟動時的時鐘。

您要查看的日誌是loopstatspeerstats文件。一旦執行 NTP 應該不需要同步時鐘。它將非常輕微地調整滴答時間以保持時鐘同步。 loopstats文件提供您的本地狀態,同時peerstats顯示您相對於您正在使用的伺服器的狀態。有關這些文件的詳細資訊,請參閱NTP 故障排除指南

引用自:https://serverfault.com/questions/541841