Build an NTP server on Windows


  Copyright statement: This article is an original article by the blogger, which was first published on CSDN on July 30, 2023. Please attach the original source link and this statement when reprinting. Link to this article: https://blog.csdn.net/u011046671/article/details/132007913

1. Basic environment

  Windows 10 and Windows Server and above

2. Applicable scenarios

  Network Time Protocol, English name: Network Time Protocol (NTP) is a protocol used to synchronize computer time. It allows the computer to synchronize its server clock source (such as quartz clock, GPS, etc.). It can provide High-precision time correction (the difference from the standard is less than 1 millisecond on LAN and tens of milliseconds on WAN), and can prevent vicious protocol attacks through encrypted confirmation. The purpose of NTP is to provide accurate and robust time services in a disorderly Internet environment.

  In an environment where the public network is accessible, you can connect to a public NTP server for time synchronization. In a pure intranet environment where the public network cannot be connected, an NTP server needs to be set up for time synchronization.

3. Operation steps

   1. Use the key combination Windows + Rto open the [Run] dialog box, enter regedit to open the [Registry Editor].

   2. Modify the following values ​​in the opened registry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config,找到Config目录,双击Config目录下的AnnounceFlags 把注册表项的值设定为5,点击确定按钮。

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer,双击NtpServer下的Enabled文件 把Enabled的值设定为1,点击确定按钮.

   3. Enter the following command to restart the Windows Time service.

net stop w32time
net start w32time

   4. Use the following command to test whether the NTP server is set up successfully. If there is a timely response, the configuration is successful.

w32tm /stripchart /computer:127.0.0.1

  5. Turn on the firewall and allow other computers to connect to the NTP server built on the local computer (using port 123 of the UDP protocol)

New-NetFirewallRule -DisplayName '允许UDP123端口(NTP)入站' -Description '允许UDP123端口(NTP)入站''-Profile 'Domain,Private,Public' -Direction Inbound -Action allow -Protocol UDP -LocalPort 123

  6. Other computers can synchronize time through the following commands or the graphical interface.

w32tm /stripchart /computer:NTP服务器的IP地址

4. Commonly used NTP servers

  Before using, please ping the corresponding domain name to check whether the network is reachable and the corresponding access speed, and choose the server with the fastest response.

name address
Aliyun NTP server【1】 ntp.aliyun.com
Aliyun NTP server【2】 ntp1.aliyun.com
Aliyun NTP server【3】 ntp2.aliyun.com
Tencent Cloud NTP server【1】 ntp.tencent.com
Tencent Cloud NTP server【2】 ntp1.tencent.com
Tencent Cloud NTP server【3】 ntp2.tencent.com
HUAWEI CLOUD NTP server【1】 ntp.myhuaweicloud.com
China timing cn.ntp.org.cn
China Education Network Timing edu.ntp.org.cn
National Time Service Center of Chinese Academy of Sciences ntp.ntsc.ac.cn

5. Reference materials

  1. Baidu Encyclopedia

  Copyright statement: This article is an original article by the blogger, which was first published on CSDN on July 30, 2023. Please attach the original source link and this statement when reprinting. Link to this article: https://blog.csdn.net/u011046671/article/details/132007913

おすすめ

転載: blog.csdn.net/u011046671/article/details/132007913