Nakonfigurujte server NTP v systému Windows Server 2019
Pokud je počítač řadičem domény Active Directory, je funkce NTP Server automaticky povolena. Následující příklad je proto pro počítač, který potřebuje povolit funkci NTP Server v prostředí WorkGroup.
1. Spusťte PowerShell s právy správce a nakonfigurujte jej následovně:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
# confirm current setting (follows are default settings)
PS C:\Users\Administrator> Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\w32time\TimeProviders\NtpServer"
InputProvider : 0
AllowNonstandardModeCombinations : 1
EventLogFlags : 0
ChainEntryTimeout : 16
ChainMaxEntries : 128
ChainMaxHostEntries : 4
ChainDisable : 0
ChainLoggingRate : 30
RequireSecureTimeSyncRequests : 0
DllName : C:\Windows\SYSTEM32\w32time.DLL
Enabled : 0
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Serv
ices\w32time\TimeProviders\NtpServer
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Serv
ices\w32time\TimeProviders
PSChildName : NtpServer
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
# enable NTP Server feature
PS C:\Users\Administrator> Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\w32time\TimeProviders\NtpServer" -Name "Enabled" -Value 1
# set [AnnounceFlags] to 5
# number means
# 0x00 : Not a time server
# 0x01 : Always time server
# 0x02 : Automatic time server
# 0x04 : Always reliable time server
# 0x08 : Automatic reliable time server
PS C:\Users\Administrator> Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\services\W32Time\Config" -Name "AnnounceFlags" -Value 5
# restart Windows Time service
PS C:\Users\Administrator> Restart-Service w32Time
# if Windows Firewall is running, allow NTP port
PS C:\Users\Administrator> New-NetFirewallRule `
-Name "NTP Server Port" `
-DisplayName "NTP Server Port" `
-Description 'Allow NTP Server Port' `
-Profile Any `
-Direction Inbound `
-Action Allow `
-Protocol UDP `
-Program Any `
-LocalAddress Any `
-LocalPort 123
2. Hostitel serveru NTP také potřebuje synchronizovat čas s ostatními hostiteli jako klient NTP.
Nakonfigurujte klienta NTP v systému Windows Server 2019
Nastavení klienta NTP jsou ve výchozím nastavení systému Windows nakonfigurována pomocí serveru NTP [time.windows.com], takže pokud je počítač připojen k internetu, datum a čas budou synchronizovány.
Kromě toho, pokud je počítač v doméně Active Directory, nastavení klienta NTP je také nakonfigurováno následovně, takže obecně není potřeba nastavení měnit:
- Řadič domény synchronizuje čas s PDC v doméně.
- PDC v doméně synchronizují čas s PDC v nadřazené doméně (hlavní doméně) nebo s jinými řadiči domény.
- Klientské počítače synchronizují svůj čas s řadičem domény, ke kterému je klient aktuálně přihlášen.
V počítači s prostředím WorkGroup lze výchozí server NTP změnit na jiné servery následovně.
1. Spusťte PowerShell s právy správce a nakonfigurujte jej následovně:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
# confirm current synchronization NTP Server
PS C:\Users\Administrator> w32tm /query /source
time.windows.com,0x8
# change target NTP Server (replace to your timezone server)
# number means
# 0x01 : SpecialInterval
# 0x02 : UseAsFallbackOnly
# 0x04 : SymmetricActive
# 0x08 : NTP request in Client mode
PS C:\Users\Administrator> Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\w32time\Parameters" -Name "NtpServer" -Value "ntp.nict.jp,0x8"
# restart Windows Time service
PS C:\Users\Administrator> Restart-Service w32Time
# re-sync manually
PS C:\Users\Administrator> w32tm /resync
Sending resync command to local computer
The command completed successfully.
# verify status
PS C:\Users\Administrator> w32tm /query /status
Leap Indicator: 0(no warning)
Stratum: 4 (secondary reference - syncd by (S)NTP)
Precision: -23 (119.209ns per tick)
Root Delay: 0.0252246s
Root Dispersion: 0.0824040s
ReferenceId: 0x85F3EEF3 (source IP: 133.243.238.243)
Last Successful Sync Time: 9/23/2019 10:15:33 PM
Source: ntp.nict.jp,0x8
Poll Interval: 8 (256s)
2. Pokud je počítač v prostředí domény Active Directory a je kořenem doménové struktury, je cíl synchronizace obvykle nakonfigurován na [Local CMOS Clock] (Hardwarové hodiny). Poté, pokud chcete změnit nastavení z [Místní hodiny CMOS] na síťový server NTP, proveďte následující:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
# in AD Domain Environment, [Type] is set to [NT5DS]
PS C:\Users\Administrator> (Get-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\w32time\Parameters").GetValue("Type")
NT5DS
# if target is [Local CMOS Clock] but you'd like to change it, change [Type] to [NTP] first
# next, change to NTP server with the same way in [1] section
PS C:\Users\Administrator> Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\w32time\Parameters" -Name "Type" -Value "NTP"