В этой статье мы расскажем, как проверить, работает ли NTP сервер по указанному адресу в сети с помощью командной строки Windows или терминала в Linux.
Приобрести оригинальные ключи активации Windows всегда можно у нас в каталоге от 1099 ₽
Проверка NTP сервера в Windows
Для проверки работы NTP сервера в Windows, необходимо открыть командную строку и выполнить команду w32tm с нужными параметрами. Команда имеет следующий вид:
w32tm /stripchart /computer:[ИМЯ ИЛИ IP АДРЕС] /dataonly /samples:3
Например, чтобы проверить сервер clock.isc.org, нужно ввести следующую команду:
w32tm /stripchart /computer:clock.isc.org /dataonly /samples:3
Ответ будет содержать текущее локальное время и разницу со временем на указанном NTP сервере. Пример выполнения команды:
C:\Users\Recluse>w32tm /stripchart /computer:clock.isc.org /dataonly /samples:3
Отслеживание clock.isc.org [64.62.194.189:123].
Сбор образцов 3.
Текущее время - 07.06.2020 19:55:28.
19:55:28, +00.0777312s
19:55:30, +00.0786069s
19:55:32, +00.0779390s
Проверка NTP сервера в Linux
В Linux для проверки работы NTP сервера используется утилита ntpdate. Команда имеет следующий вид:
ntpdate -q [ИМЯ ИЛИ IP АДРЕС]
Для проверки сервера clock.isc.org, команда будет выглядеть так:
ntpdate -q clock.isc.org
Пример выполнения команды:
recluse@sysadmin.ru:~$ ntpdate -q clock.isc.org
После выполнения команды в терминале будет выведена информация о текущем времени и разнице между локальным временем и временем на указанном NTP сервере.
Лицензионный ключ активации Windows от
How to Check NTP Server in Windows
As a system administrator, it’s crucial to ensure that your Windows-based system is configured to use the correct NTP (Network Time Protocol) server. NTP is a protocol used to synchronize the time on devices connected to a network. In this article, we will guide you on how to check the NTP server in Windows.
Why is it important to check NTP server in Windows?
- Ensures accurate system time: A correct NTP server setting ensures that your system time is accurate, which is essential for various applications such as logging, auditing, and security.
- Avoids time synchronization issues: Incorrect NTP server settings can cause time synchronization issues, leading to problems with system performance and reliability.
- Complies with security regulations: Many security regulations, such as PCI DSS, require accurate system time to ensure compliance.
How to check NTP server in Windows
There are two ways to check the NTP server in Windows:
Method 1: Using the Command Prompt
- Open the Command Prompt: Press the Windows key + R to open the Run dialog box, type
cmd
, and press Enter. - Type the command: Type the following command and press Enter:
w32tm /query /source
- Check the output: The command will display the current NTP server source. Look for the Source field, which should indicate the NTP server address.
Example output:
Source = <ntp.pool.ntp.org>
Method 2: Using the Windows Registry
- Open the Registry Editor: Press the Windows key + R to open the Run dialog box, type
regedit
, and press Enter. - Navigate to the registry key: In the Registry Editor, navigate to the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters
- Check the NTP server setting: Look for the NtpServer value, which should contain the NTP server address.
Example registry entry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters
NtpServer = <ntp.pool.ntp.org>
How to change the NTP server in Windows
If you need to change the NTP server, you can do so by following these steps:
Method 1: Using the Command Prompt
- Open the Command Prompt: Press the Windows key + R to open the Run dialog box, type
cmd
, and press Enter. - Type the command: Type the following command and press Enter:
w32tm /config /manualpeerlist:<NTP_server_address> /syncfromflags:MANUAL
- Replace : Replace
<NTP_server_address>
with the new NTP server address.
Example command:
w32tm /config /manualpeerlist:ntp1.example.com ntp2.example.com /syncfromflags:MANUAL
Method 2: Using the Windows Registry
- Open the Registry Editor: Press the Windows key + R to open the Run dialog box, type
regedit
, and press Enter. - Navigate to the registry key: In the Registry Editor, navigate to the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters
- Update the NTP server setting: Double-click on the NtpServer value and update the value to the new NTP server address.
Example registry entry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters
NtpServer = <ntp1.example.com> <ntp2.example.com>
Conclusion
In conclusion, checking the NTP server in Windows is a crucial task to ensure accurate system time and compliance with security regulations. By following the methods outlined in this article, you can easily check and change the NTP server in Windows.
Additional Tips
- Use a reliable NTP server: Choose a reliable NTP server to ensure accurate time synchronization. You can use public NTP servers such as pool.ntp.org or time.nist.gov.
- Monitor NTP server status: Regularly monitor the NTP server status to ensure it is functioning correctly.
- Configure NTP server redundancy: Configure multiple NTP servers to ensure redundancy and minimize the risk of time synchronization issues.
NTP Server Configuration Table
NTP Server Configuration | Method 1 | Method 2 |
---|---|---|
Check NTP server source | w32tm /query /source |
Registry Editor: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters |
Change NTP server | w32tm /config /manualpeerlist:<NTP_server_address> /syncfromflags:MANUAL |
Registry Editor: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters |
By following this article, you will be able to check and change the NTP server in Windows, ensuring accurate system time and compliance with security regulations.
Your friends have asked us these questions — Check out the answers!
Sometimes we need to retrieve the date from a NTP Network Time Protocol server to record it somewhere.
The first thing is to know if the server is working and reacheable from our computer (yep, firewalls still works). Then we can check the returned date format to adapt to our needs.
The most common thing is that we have to use a NIST server or a SNPT server. And, at the moment of checking them and programming, there is subtle differences between them.
Checking a NIST server
Check a NIST server is very straightforward. These servers listens on port 13, and responds to TCP or UDP requests. We can do a simple telnet or a netcat to check it. For example, if we wanted to check if time-c.nist.gov will work for us:
windows > run > cmd
1 |
telnet time-c.nist.gov 13 |
1 |
netcat time-c.nist.gov 13 |
Checking a SNTP server
Check a SNTP is not as straightforward as check a NTP server. SNTP servers uses the UDP protocol and the 123 port. Telnet or netcat won’t work for us… But we can use w32tm. For example, if we wanted to check if ntp02.oal.ul.pt will work for us:
windows > run > cmd
1 |
w32tm /stripchart /computer:ntp02.oal.ul.pt /dataonly /samples:1 |
Enjoy!
This post is licensed under CC BY 4.0 by the author.
microsoft-windows:win-command-line-tools:w32tm-manage-windows-time-service
Содержание
Утилита w32tm — Управляем службой времени в Windows
Как настроить NTP-сервер с помощью w32tm?
Как проверить статус синхронизации с NTP-сервером с помощью w32tm?
Проверяем текущее состояние службы времени и статус последней успешной синхронизации с NTP-сервером:
w32tm /query /Status
Индикатор помех: 0(предупреждений нет) Страта: 4 (вторичная ссылка - синхронизирована с помощью (S)NTP) Точность: -6 (15.625ms за такт времени) Задержка корня: 0.0937500s Дисперсия корня: 7.9058435s Идентификатор опорного времени: 0x0AA01008 (IP-адрес источника: 10.10.1.8) Время последней успешной синхронизации: 14.07.2020 14:53:05 Источник: DC01.ad.holding.com Интервал опроса: 10 (1024s)
Как проверить доступность NTP-сервера с помощью w32tm?
Отсылается 5 запросов на UDP порт 123 NTP-сервера следующим образом:
w32tm /stripchart /computer:DC01.ad.holding.com /dataonly /samples:5
Ответ от NTP-сервера получим примерно такой:
Отслеживание DC01.ad.holding.com [10.10.1.8:123].
Сбор образцов 5.
Текущее время - 21.12.2016 10:28:13.
10:28:13, +00.1740513s
10:28:15, +00.1764264s
10:28:17, +00.1788762s
10:28:19, +00.1871543s
10:28:21, +00.1868310s
· Последнее изменение: 14.07.2020 15:09 —
Алексей Максимов
It’s easy to forget how crucial time synchronization is across a network/domain until it stops working. After you setup your Domain controller and pick a time zone, it should all just work–and it typically does. However, if you manage Windows Servers for long enough, this is probably going to be something you have to mess with.
So, here’s a scenario–definitely not one I’ve come across–you’re on one of the servers, and you notice the clock is off by three minutes. You check the other servers, their clock is off by three minutes. You identity which server (if you didn’t know already) has the PDC emulator FSMO role, then, check time zone, restart w32time service, restart the server–maybe even try manually adjusting the time by a few minutes. No dice. Looking into the NTP server seems like a good next step.
By default, a Windows machine/server is going to use time.windows.com for its NTP server. There’s a chance it’ll pick the Local CMOS Clock. There’s multiple ways to check this, and I’m going to get into that next. First, I want to go over the utility used to look into our NTP settings. W32tm is the network time services utility. To get an understanding of how it works, and how Windows thinks of time services, it’s good to read the top part of its help output. Run w32tm /?
I’m showing this specifically because these are two of the major components of Windows Time Service. It is a Windows service and the configuration is added to the registry. To start or stop Windows Time Service, the cmd command is
net stop|start w32time .
The next part is how we look at our current configuration. There’s two ways to do it: Using the w32tm /query /another_command or checking the registry. We should be checking both to make sure its configured correctly. Let’s start with w32tm.
Within this part of the utility we can do:
w32tm /query /source|configuration|peers|status|verbose
The first command I would run would be w32tm /query /source . This will tell you if you are using the BIOS clock or an NTP server. If you run
w32tm /query /peer
And you’re using the hardware clock, then you won’t get that information. It will just say:
As opposed to:
Next, I think it would be prudent to check check the status. This will show us the IP address of our NTP server, stratum, last successful sync, and the source server (naturally).
If you were looking at this, and noticed an issue with the last successful sync, it could be worth it to run
w32tm /resync
If this fixes the issue, then success! However, it could still be worth your time to change NTP servers.
Since I mentioned there are two ways to check NTP settings, let’s look at the registry now. The three main areas in the registry are:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w32time\Parameters
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config
The big one we want to check is Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters. This will show us our NTP server in the registry. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config is good to check if you’re making changes to announce flags, updating intervals or poll interval.
Now that we’ve check our general NTP settings. Let’s change our NTP server. I am going to change them to the NTP Pool Project U.S. servers. Here’s a link to their website if you want to check them out.
https://www.pool.ntp.org/zone/us
There’s also NIST servers if you want something different and more secure. They support authenticated NTP if you register with them, and their documentation even outlines how often you can poll their servers.
https://tf.nist.gov/tf-cgi/servers.cgi
Ok, I am going to add all the 4 servers into my configuration. The command would look like:
w32tm /config /update /manualpeerlist:”0.us.pool.ntp.org 1.us.pool.ntp.org 2.us.pool.ntp.org 3.us.pool.ntp.org” /syncfromflags:manual /reliable:yes
We can make sure the changes take by running:
w32tm /resync /rediscover
Now we check our NTP servers by running:
w32tm /query /source
w32tm /query /peers
And let’s check the registry for good measure.
Looks like a success to me. Hopefully this article was helpful in going over a high level overview of Windows Time Service and NTP servers. I am going to leave a cheat sheet underneath this for the commands used in this article and a few extra for troubleshooting another server.
net stop|start w32time
w32tm /query /source|configuration|peers|status|verbose
w32tm /config /manualpeerlist:”0.us.pool.ntp.org 1.us.pool.ntp.org 2.us.pool.ntp.org 3.us.pool.ntp.org” /syncfromflags:manual /reliable:yes /update
w32tm /resync /rediscover
If the w32time service disappears or other servers are not syncing to the PDC emulator:
w32tm /register
w32tm /config /syncfromflags:domhier /update (Sync from Domain Hierachy, AKA PDC emulator)