2

Is there any option ntpq for the ntp server connectivity test like the ntpdate -d command?

ntpdate -d ntpserverip

This command shows the suitable ntp server for synchronization. What the equivalent for the ntpq command?

ntpdate -d ntpserverip adjust time server ntpserverip offset 0.101886 sec --> for success response

ntpdate -d ntpserverip no server suitable for synchronization found --> for fail response

This ntpserverip is not in the ntp.conf. I want to test different a NTP server which is not in the ntp.conf.

Glorfindel
  • 4,089
  • 8
  • 24
  • 37
arifisik
  • 302
  • 3
  • 15

2 Answers2

1

If you’re missing the deprecated ntpdate, sntp is a better substitute than ntpq.

By default, sntpntpserverip will query the time without setting the clock (like options -q and -d of ntpdate did), using a random port (like options -u and -d of ntpdate did).

Optionally, include:

  • -4 or -6 to force IPv4 or IPv6 DNS resolution.
  • -d for debugging mode (may be repeated to increase level).
  • -r if you need to use NTP port 123 (if ntpd isn’t already using it).
  • -akeyid if you need MAC authentication.

See also:

Picotin
  • 64
  • 5
0

Can you just use ntpdate -q ntpserverip?

Otherwise ntpq host ntpserverip might be what you want. It sets the host to query. http://doc.ntp.org/4.1.0/ntpq.htm

EDIT for ESXi

This give a good walkthrough of NTP in the web interface: https://blog.ukotic.net/2014/09/11/configuring-and-testing-ntp-on-esxi/

When you set it, you can add multiple NTP servers to the list and use the ntpq to query it then. There's a VMware KB article mentioned in that link that pertains to several versions of ESXi.

notsodev
  • 103
  • 5
  • hi Bryan, there is no ntpdate package in the esxi host therefore I don't use ntpdate. I think this ntpq host ntpserverip not the same ntpdate -d command . I can't running the command. This command prints the name or service not known output. – arifisik Mar 19 '20 at 04:50
  • Could you add in the ESXi version to the question? I removed the Linux tag to the question and added ESXi. ESXi is a "Unix like OS" and more of a stripped down version. If you put a Linux VM on the same vNIC as as the ESXi host's management you can use ntpdate from there. Alternatively you just set the desired NTP in the DCUI or web interface and look and post the results to `tail /var/log/messages | grep ntpd` as well – notsodev Mar 19 '20 at 12:42
  • hi, brain there is no different ntpq package between esxi and linux. All of them use the same options. I think misunderstood my question. ntpdate -d anyntpserverip command shows us connection success and offset between anyntpserverip and ntp client which I run ntpdate command. I want to same result with ntpq command. ntpq -p localhost or ntpserverip show us peers at the server which run ntpq command on the server – arifisik Mar 20 '20 at 17:18