三台機器 A(可上網)、B/C(離線)。A 作為 NTP 服務器,B/C 同步 A 時間。
reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer /v Enabled /t REG_DWORD /d 1
w32tm /config /manualpeerlist:"time.windows.com 0x9" /syncfromflags:manual /reliable:yes /update
netsh advfirewall firewall add rule name="NTP" dir=in action=allow protocol=UDP localport=123
net stop w32time && net start w32time
w32tm /config /manualpeerlist:"A_IP" /syncfromflags:manual /update
net stop w32time && net start w32time
w32tm /resync /rediscover
w32tm /query /status
w32tm /query /source
w32tm /query /configuration
輸出應顯示 Source: A_IP、Stratum: 2(A 為 Stratum 1)。
# CentOS
yum install -y ntp
echo "restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap" >> /etc/ntp.conf
echo "server 127.127.1.0" >> /etc/ntp.conf # 本地時鐘作為備用
systemctl enable ntpd && systemctl start ntpd
/reliable:no 降低層級要求。w32tm /stripchart /computer:A_IP /samples:5 偏移量。