Testing NTP

Okay,

NTP is configured, so I think. I can see it running on the process table. But I'm not sure how to test ntp to see if it's working.

I've read through the handbook on the topic here, but I'm still having some questions on how exactly can I test ntp.

When I log into my (8.3 64bit BSD) machine, I try the following to test:
Code:
#ntpq as 
hostname nor servname provided, or not known

I can specify the host, but I'm wondering why I have to if I have servers specified in the /etc/ntp.conf file already?

Is that the right way to test ntp?

SK
 
Thanks for the reply bud,

Here is what I got for your test:

Code:
#ntpq
hostname nor servname provided, or not known
ntpq> as
***No host open, use `host' command
ntpq>

But I also just figured it out. What I did was added the following to the /etc/hosts:
Code:
127.0.0.1 localhost

And now I get:

Code:
#ntpq
ntpq> as

ind assID status  conf reach auth condition  last_event cnt
===========================================================
  1 20456  9314   yes   yes  none   outlyer   reachable  1
  2 20457  9614   yes   yes  none  sys.peer   reachable  1
  3 20458  9414   yes   yes  none  candidat   reachable  1
  4 20459  9414   yes   yes  none  candidat   reachable  1

I'm a little fuzzy why that fixed it, I'm still researching it.
 
scryptkiddy said:
But I also just figured it out. What I did was added the following to the /etc/hosts:
127.0.0.1 localhost
That should have been there by default as far as I know (I'm not familiar with versions before 9), if it wasn't then it looks to me as if someone changed the /etc/hosts file:

Code:
# $FreeBSD: release/9.1.0/etc/hosts 109997 2003-01-28 21:29:23Z dbaker $
#
# Host Database
#
# This file should contain the addresses and aliases for local hosts that
# share this file.  Replace 'my.domain' below with the domainname of your
# machine.
#
# In the presence of the domain name service or NIS, this file may
# not be consulted at all; see /etc/nsswitch.conf for the resolution order.
#
#
::1                     localhost localhost.my.domain
127.0.0.1               localhost localhost.my.domain
It most certainly would explain something. In fact; the lack of a localhost entry might even have influenced other things on your system.
 
ShelLuser said:
That should have been there by default as far as I know (I'm not familiar with versions before 9), if it wasn't then it looks to me as if someone changed the /etc/hosts file:
It has been there as long as I can remember. So my guess is indeed that either someone changed it deliberately or it got altered accidentally by an errant port or something.
 
Thanks all. Yeah, the other guy working on the server had removed it for testing of something. He has been thoroughly smacked. :e

SK
 
Probably irrelevant (you most likely already know all this), but I've always found the following useful for checking NTP.

List the current time servers and their status (The one with the * is the one being used):

Code:
# ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*216.119.157.44  128.59.39.48     2 u  371  512  377  121.507   -1.361   7.607
+63.240.161.99   66.96.98.9       3 u  257  512  367  102.210    6.080   0.149
+173.255.197.210 38.229.71.1      3 u  294  512  377  135.298   -0.283   1.447

View the current NTP server status detail:

The important bit for me here is state=4, which shows it's answering queries. I can't remember 100% but I'm sure last time I was working with NTP, it stayed in state 3 for a while after selecting a peer (the * appearing in ntpq -pn), and wouldn't answer queries, which is why I ended up finding this command in the first place. After a short time it went to state 4 and started working fully.

Code:
# ntpq -c rv
assID=0 status=06f4 leap_none, sync_ntp, 15 events, event_peer/strat_chg,
version="ntpd 4.2.4p5-a (1)", processor="amd64",
system="FreeBSD/8.1-RELEASE", leap=00, stratum=3, precision=-19,
rootdelay=156.450, rootdispersion=143.265, peer=24718,
refid=216.119.157.44,
reftime=d5dc14b3.a59c184b  Thu, Sep 12 2013 11:23:47.646, poll=9,
clock=d5dc1a38.b25437eb  Thu, Sep 12 2013 11:47:20.696, state=4,
offset=1.861, frequency=-30.020, jitter=11.341, noise=3.476,
stability=0.002, tai=0
 
Back
Top