欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

How do I test connection to a ntp server?

程序员文章站 2022-03-02 15:30:49
...

 

How do I test connection to a ntp server?

 SOLUTION IN PROGRESS - 已更新 2015年十一月3日01:52 - 

English 

环境

  • Red Hat Enterprise Linux
  • ntp

问题

How do I test connection to a ntp server without changing ntp configuration on the client side?

决议

  • Execute the command :-

Raw

ntpq -p
OR
ntpdate -d <ntp server>

If a '*' sign is seen against the NTP server, in the output of the 'ntpq -p' command, it means that ntp client is syncing with that ntp server :-

Raw

[[email protected] ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*192.168.122.38  10.16.255.1      2 u    -   16   37    0.165   -0.035   0.018
  • Alternatively, if you'd like to see if your ntp client is capable of receiving ntp related udp traffic, you may execute the below command :-

Raw

[[email protected] ~]# nmap -sU node4 -p 123   ==> port 123 is for NTP and '-sU' is for scanning UDP ports.

Starting Nmap 5.51 ( http://nmap.org ) at 2015-10-29 02:47 IST
Nmap scan report for node4 (192.168.122.38)
Host is up (0.00018s latency).
PORT    STATE SERVICE
123/udp open  ntp
MAC Address: 52:54:00:E7:D2:96 (QEMU Virtual NIC)

Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds
  • If you want to know if at any given instance, the ntp client is able to receive ntp traffic from a ntp source, you may execute the below command :-

Raw

[[email protected] ~]# ntpdate -d node4  ==> Node 4 in this illustration is the ntp server, node1 is the ntp client.
29 Oct 02:46:02 ntpdate[7898]: ntpdate [email protected] Thu Jan 10 15:17:41 UTC 2013 (1)
Looking for host node4 and service ntp
host found : 192.168.122.38
transmit(192.168.122.38)
receive(192.168.122.38)
transmit(192.168.122.38)
receive(192.168.122.38)
..snip..
29 Oct 02:46:02 ntpdate[7898]: adjust time server 192.168.122.38 offset -0.000036 sec

Note :- There could be other ways too but this article is just a heads up for the same. One may find and use other methods as preferable.

相关标签: ntp server linux