Как проверить работу ntp сервера windows

Если Вам потребовалось проверить, работает ли NTP сервер по определенному адресу в ...


Debian, Linux, Ubuntu, Windows, Windows 10, Windows 7, Windows 8, Windows Server, Windows Vista, Windows XP

  • 08.06.2020
  • 22 362
  • 2
  • 23.06.2021
  • 35
  • 34
  • 1

Проверка работы NTP сервера

  • Содержание статьи
    • Windows
    • Linux
    • Комментарии к статье ( 2 шт )
    • Добавить комментарий

Если Вам потребовалось проверить, работает ли NTP сервер по определенному адресу в сети, то Вы можете легко это проверить через командную строку Windows, или терминал в Linux.

Windows

В Windows, нужно открыть командную строку и выполнить команду w32tm со специальными параметрами.

w32tm /stripchart /computer:[ИМЯ ИЛИ IP АДРЕС] /dataonly /samples:3

Например, для сервера clock.isc.org нужно написать вот так:

w32tm /stripchart /computer:clock.isc.org /dataonly /samples:3

Ответ будет содержать локальное время, и разницу со временем на указанном NTP сервере. Например:

C:UsersRecluse>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

Linux

В Linux для проверки NTP сервера можно использовать утилиту ntpdate.

ntpdate -q [ИМЯ ИЛИ IP АДРЕС]

Для проверки сервера clock.isc.org команда приобретает следующий вид:

recluse@sysadmin.ru:~$ ntpdate -q clock.isc.org

Выглядеть её выполнение будет следующим образом:

recluse@sysadmin.ru:~$ ntpdate -q clock.isc.org
server 204.93.207.11, stratum 3, offset 0.005347, delay 0.15712
server 64.62.194.188, stratum 3, offset 0.003708, delay 0.20419
server 64.62.194.189, stratum 3, offset 0.002025, delay 0.19640
7 Jun 19:59:00 ntpdate[74019]: adjust time server 204.93.207.11 offset 0.005347 sec

Содержание

Утилита 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

I tried:

w32tm /query /status

I got:

The command /query is unknown.

In a different machine, I got:

The following error occurred: The service has not been started. (0x80070426)

Then I tried:

reg QUERY [\machine]HKLMSYSTEMCurrentControlSetServicesW32Time

I got:

ERROR: The system was unable to find the specified registry key or value.

Then I tried:

net time /querysntp

I got:

This computer is not currently configured to use a specific SNTP server.

In another machine, I got the help page, saying also:

The /QUERYSNTP and /SETSNTP options have been deprecated. Please use w32tm.exe to configure the Windows Time Service.

So, basically, the service was not running. Following these instructions, I did:

w32tm /unregister
w32tm /unregister
w32tm /register
net start w32time

Finally, all the above would work. (note: if net start fails, see below) Then I just needed to set my ntp up…
I did it with:

w32tm /config /manualpeerlist:10.0.0.5 /syncfromflags:manual /reliable:yes /update

following instructions from here, but perhaps it could’ve been as easy as:

net time /setsntp:10.0.0.5

as instructed here. (10.0.0.5 being my local NTP server). If you’re not using a local NTP server, you can use the generic one:

w32tm /config /manualpeerlist:pool.ntp.org /syncfromflags:manual /reliable:yes /update

Finally, you might need to do the following, which was not necessary for me:

w32tm /config /update
w32tm /resync /rediscover

NOTE: if net start w32time fails with error 1290 (The service start failed since one or more services in the same process have an incompatible service SID type setting) then follow the steps here:

w32tm /unregister
w32tm /register
sc config w32time type= own
net start w32time

Then follow as above.


NOTE 2: if the NTP service doesn’t automatically start on reboot, it might be due to its start settings, as described here: depending on your windows, it might be set to start only when it joins a domain. You can check with:

sc qtriggerinfo w32time

If it’s configured to start when you join a domain, and you don’t have a domain set up in your machine, it will not start the service and set the time. It probably doesn’t join a domain because you don’t want it to. In any case, just change which trigger starts it. For example, to start when the machine has network (and therefore is able to access the server), do:

sc triggerinfo w32time start/networkon stop/networkoff

Правильней использовать термин «Служба времени Windows» вместо NTP, но к сожалению из-за слишком долгой работы с разными юниксами мне очень сложно перестроиться. Надеюсь опытные пользователи Microsoft или MVP не будут писать гневные комментарии. MCSA или MCSE я думаю сюда и не заглянут — они и так всё знают 😎

Win+R → cmd → Enter

Формат команды для проверки доступности NTP сервера

w32tm /stripchart /computer:доменное.имя_ИЛИ_IP.NTP.сервера /dataonly /samples:5

Проверим сервер time.windows.com

w32tm /stripchart /computer:time.windows.com /dataonly /samples:5

Я могу ошибаться, но похоже Windows Server не разрешает устанавливать несколько NTP серверов через GUI.

К счастью я нашёл отличный .bat’ник на github

@echo on & @setlocal enableextensions
@echo =========================
@echo Turn off the time service
net stop w32time
@echo ======================================================================
@echo Set the SNTP (Simple Network Time Protocol) source for the time server
w32tm /config /syncfromflags:manual /manualpeerlist:"time.cloudflare.com time.google.com time.windows.com ntp.ripe.net"
@echo =============================================
@echo ... and then turn on the time service back on
net start w32time
@echo =============================================
@echo Tell the time sync service to use the changes
w32tm /config /update
@echo =======================================================
@echo Reset the local computer's time against the time server
w32tm /resync /rediscover
@endlocal & @goto :EOF

Обычно я использую для синхронизации time.cloudflare.com time.google.com time.windows.com ntp.ripe.net или ntp.ripe.net ntp.nic.cz ntp.time.nl time.google.com.

Для наглядности я ввёл все команды из примера выше вручную

Теперь можно посмотреть список наших NTP серверов (/peers: отображение списка узлов и их состояние)

w32tm /query /peers

Посмотреть статус синхронизации с NTP (/status: отображение состояния службы времени Windows)

w32tm /query /status

Посмотреть конфигурацию NTP (/configuration: отображение конфигурации времени выполнения и места, где берется параметр).

w32tm /query /configuration

Ещё несколько полезных команд.

Выполнить синхронизацию

w32tm /resync

Показать текущий часовой пояс (time zone)

w32tm /tz

Вернуть всё в default

net stop w32time
w32tm /unregister
w32tm /register
net start w32time

EOM

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies

ntptest is a command line utility that can be used to query the current time and status from an NTP server.
The data fields of the response packet from the server as well as the fields from the request packet sent to the server
are displayed in detail, so this is very useful to see which data an NTP server sends to its clients.

This program needs to be run in a command line / terminal window (cmd.exe on Windows).

Just run the program by typing

ntptest <hostname>

where, of course, <hostname> has to be replaced by the DNS name or IP address of the NTP server to be queried.
The command

ntptest -?

shows some usage information including the command line options that can be used to define the exact behavior.

If ntptest is called with the -Z option, it sends 4 requests/sec to the server,
and the initial time offset is compensated, so you can even see how the offset develops over time:

ntptest -Z <hostname>

The output is something like:

ntptest v1.10, (c) Meinberg 2014-2018, contact: <martin.burnicki@meinberg.de>

Host <hostname>, running continuously
Initial time offset -0.000169012 will be compensated
2018-11-08 09:33:16.640653559, st 1, leap 0, offs[ms]: +0.115
2018-11-08 09:33:16.891949683, st 1, leap 0, offs[ms]: +0.131
2018-11-08 09:33:17.143102303, st 1, leap 0, offs[ms]: +0.113
2018-11-08 09:33:17.394358585, st 1, leap 0, offs[ms]: +0.126
...

If you run the program against an NTP server while the server handles a leap second,
you can observe how the server adjusts the leap bits, or if the server smears the time
to hide the leap second from its clients.

Here is an executable program for Windows. The ZIP archive has been updated
and now contains an openSSL DLL that was missing from an earlier version.
The DLL is required to support symmetric keys:

And the source code for Windows:

Source code for Linux or FreeBSD:

Public git repo of the source code:

v1.11 — 2019-09-04

v1.10 — 2018-07-31

v1.9 — 2018-04-09

v1.8 — 2018-03-09

I tried:

w32tm /query /status

I got:

The command /query is unknown.

In a different machine, I got:

The following error occurred: The service has not been started. (0x80070426)

Then I tried:

reg QUERY [\machine]HKLMSYSTEMCurrentControlSetServicesW32Time

I got:

ERROR: The system was unable to find the specified registry key or value.

Then I tried:

net time /querysntp

I got:

This computer is not currently configured to use a specific SNTP server.

In another machine, I got the help page, saying also:

The /QUERYSNTP and /SETSNTP options have been deprecated. Please use w32tm.exe to configure the Windows Time Service.

So, basically, the service was not running. Following these instructions, I did:

w32tm /unregister
w32tm /unregister
w32tm /register
net start w32time

Finally, all the above would work. (note: if net start fails, see below) Then I just needed to set my ntp up…
I did it with:

w32tm /config /manualpeerlist:10.0.0.5 /syncfromflags:manual /reliable:yes /update

following instructions from here, but perhaps it could’ve been as easy as:

net time /setsntp:10.0.0.5

as instructed here. (10.0.0.5 being my local NTP server). If you’re not using a local NTP server, you can use the generic one:

w32tm /config /manualpeerlist:pool.ntp.org /syncfromflags:manual /reliable:yes /update

Finally, you might need to do the following, which was not necessary for me:

w32tm /config /update
w32tm /resync /rediscover

NOTE: if net start w32time fails with error 1290 (The service start failed since one or more services in the same process have an incompatible service SID type setting) then follow the steps here:

w32tm /unregister
w32tm /register
sc config w32time type= own
net start w32time

Then follow as above.


NOTE 2: if the NTP service doesn’t automatically start on reboot, it might be due to its start settings, as described here: depending on your windows, it might be set to start only when it joins a domain. You can check with:

sc qtriggerinfo w32time

If it’s configured to start when you join a domain, and you don’t have a domain set up in your machine, it will not start the service and set the time. It probably doesn’t join a domain because you don’t want it to. In any case, just change which trigger starts it. For example, to start when the machine has network (and therefore is able to access the server), do:

sc triggerinfo w32time start/networkon stop/networkoff

I tried:

w32tm /query /status

I got:

The command /query is unknown.

In a different machine, I got:

The following error occurred: The service has not been started. (0x80070426)

Then I tried:

reg QUERY [\machine]HKLMSYSTEMCurrentControlSetServicesW32Time

I got:

ERROR: The system was unable to find the specified registry key or value.

Then I tried:

net time /querysntp

I got:

This computer is not currently configured to use a specific SNTP server.

In another machine, I got the help page, saying also:

The /QUERYSNTP and /SETSNTP options have been deprecated. Please use w32tm.exe to configure the Windows Time Service.

So, basically, the service was not running. Following these instructions, I did:

w32tm /unregister
w32tm /unregister
w32tm /register
net start w32time

Finally, all the above would work. (note: if net start fails, see below) Then I just needed to set my ntp up…
I did it with:

w32tm /config /manualpeerlist:10.0.0.5 /syncfromflags:manual /reliable:yes /update

following instructions from here, but perhaps it could’ve been as easy as:

net time /setsntp:10.0.0.5

as instructed here. (10.0.0.5 being my local NTP server). If you’re not using a local NTP server, you can use the generic one:

w32tm /config /manualpeerlist:pool.ntp.org /syncfromflags:manual /reliable:yes /update

Finally, you might need to do the following, which was not necessary for me:

w32tm /config /update
w32tm /resync /rediscover

NOTE: if net start w32time fails with error 1290 (The service start failed since one or more services in the same process have an incompatible service SID type setting) then follow the steps here:

w32tm /unregister
w32tm /register
sc config w32time type= own
net start w32time

Then follow as above.


NOTE 2: if the NTP service doesn’t automatically start on reboot, it might be due to its start settings, as described here: depending on your windows, it might be set to start only when it joins a domain. You can check with:

sc qtriggerinfo w32time

If it’s configured to start when you join a domain, and you don’t have a domain set up in your machine, it will not start the service and set the time. It probably doesn’t join a domain because you don’t want it to. In any case, just change which trigger starts it. For example, to start when the machine has network (and therefore is able to access the server), do:

sc triggerinfo w32time start/networkon stop/networkoff

Понравилась статья? Поделить с друзьями:
  • Как проверить работу iis windows 10
  • Как проверить работу dns сервера windows server 2019
  • Как проверить работу dns сервера windows server 2012 r2
  • Как проверить работу directx на windows 7
  • Как проверить работу com порта в windows xp