Windows 2022
Sponsored Link

NTP : NTP サーバーの設定2021/12/01

 
時刻同期のための NTP サーバーを設定します。
設定したいコンピューターが Active Directory ドメインコントローラーの場合は、NTP サーバーの機能は自動的に有効になっています。
よって、以下はワークグループ環境の Windows Server に NTP サーバーの機能を設定したい場合の例です。
[1] PowerShell を管理者権限で起動して設定します。
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

# 現在の設定確認 (以下は既定の設定)
PS C:\Users\Administrator> Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\w32time\TimeProviders\NtpServer" 

AllowNonstandardModeCombinations : 1
ChainDisable                     : 0
ChainEntryTimeout                : 16
ChainLoggingRate                 : 30
ChainMaxEntries                  : 128
ChainMaxHostEntries              : 4
DllName                          : C:\Windows\system32\w32time.dll
Enabled                          : 0
EventLogFlags                    : 0
InputProvider                    : 0
RequireSecureTimeSyncRequests    : 0
PSPath                           : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w32
                                   time\TimeProviders\NtpServer
PSParentPath                     : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w32
                                   time\TimeProviders
PSChildName                      : NtpServer
PSDrive                          : HKLM
PSProvider                       : Microsoft.PowerShell.Core\Registry

# NTP サーバー機能を有効にする
PS C:\Users\Administrator> Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\w32time\TimeProviders\NtpServer" -Name "Enabled" -Value 1 

# AnnounceFlags を 5 に変更
# 数値の意味
# 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 

# Windows Time サービス再起動
PS C:\Users\Administrator> Restart-Service w32Time 

# Windows Firewall 稼働中の場合は NTP ポート許可
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]
NTP サーバー自身も NTP クライアントとして、他の NTP サーバーと同期する必要があります。
NTP クライアントの設定は次項を参照ください
関連コンテンツ