LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-04-2004, 02:23 PM   #1
bitpicker
Member
 
Registered: Jul 2003
Location: Germany
Distribution: Xubuntu, Ubuntu
Posts: 416
Blog Entries: 14

Rep: Reputation: 35
ntpd for an idiot


I want to synchronize my (stand-alone) computer clock to an atomic clock when I'm online. If that happened automatically when I go online it would be magic, but I could live with doing it by hand.

I know you've heard this question millions of times, I've seen it - I searched the forum, but all I found was the information to use ntpd / ntpdate (I already got that far) and read the xntp-doc. Frankly, reading that documentation is a bit like becoming a world class surgeon in order to pull a splinter out of my thumb. I tried, but I simply don't get any of it. I've tried (as root):

ntpdate time.nist.gov (and a number of further addresses found at http://www.eecis.udel.edu/~mills/ntp/servers.html)

ntpdate 204.34.198.40 (and a number of other IPs found by googling)

and all that ever gets me is 'no server suitable for synchronization found'

Now I'm sure I'm just missing something which is probably simple, but the people who wrote the documentation were SO above giving even the smallest of examples. Or if they did it seems to be well-hidden under loads of information I neither need nor understand.

So can anyone give me a rundown for idiots in simple terms about how to do it?

Robin
 
Old 02-04-2004, 02:30 PM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
You don't want to use ntp-update, you want to use ntpd, because ntpd slowly corrects your clock is it doesn't screw anything up (like cause you to have file access times that are before current time that that stuff).

Here is an example config file for ntpd:
Code:
restrict 127.0.0.1
fudge 127.127.1.0 stratum 3
server <server1>
server <server2>
server <server3>
driftfile /var/lib/ntp/ntp.drift
logfile /var/log/ntp.log
Save this as ntp.conf in /etc and run ntpd and it should read it and whenever it can contact those servers (any time you are on-line) it'll poll them to keep your clock right and calculate how much your clock drifts and what not. Also, replace the <server1>, <server2>, <server3> with servers from this list: http://www.eecis.udel.edu/~mills/ntp/clock2a.html

Last edited by jtshaw; 02-04-2004 at 02:32 PM.
 
Old 02-04-2004, 02:37 PM   #3
ranger_nemo
Senior Member
 
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
Before starting ntpd, it's a good idea to run ntpdate to set the clock to the correct time.

Better yet, you might have a file in /etc/ntp/ called step-tickers. Put a server in there, and anytime the computer starts ntpd, it will contact that server to get the correct time.
 
Old 02-04-2004, 02:41 PM   #4
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Depends on who you ask... they are getting ride of ntp-update eventually because it is a terrible idea to make your clock jump.
 
Old 02-04-2004, 03:10 PM   #5
bitpicker
Member
 
Registered: Jul 2003
Location: Germany
Distribution: Xubuntu, Ubuntu
Posts: 416

Original Poster
Blog Entries: 14

Rep: Reputation: 35
Quote:
Originally posted by jtshaw
You don't want to use ntp-update, you want to use ntpd, because ntpd slowly corrects your clock is it doesn't screw anything up (like cause you to have file access times that are before current time that that stuff).

Here is an example config file for ntpd:
Code:
restrict 127.0.0.1
fudge 127.127.1.0 stratum 3
server <server1>
server <server2>
server <server3>
driftfile /var/lib/ntp/ntp.drift
logfile /var/log/ntp.log
Save this as ntp.conf in /etc and run ntpd and it should read it and whenever it can contact those servers (any time you are on-line) it'll poll them to keep your clock right and calculate how much your clock drifts and what not. Also, replace the <server1>, <server2>, <server3> with servers from this list: http://www.eecis.udel.edu/~mills/ntp/clock2a.html
Ok, thanks for the quick reply. I'm running SuSE 9.0, and Yast2 comes with a module which sets up such servers in ntp.conf; I had tried that before, but there are some differences between my file and the sample you posted. To be precise, here's the content of my file:

-----
server 127.127.1.0
fudge 127.127.1.0 stratum 10
server ntp.globe.cz
server 203.21.37.18
server 195.13.23.5
server 209.87.233.53
server 217.127.2.161
driftfile /var/lib/ntp/drift/ntp.drift
logfile /var/log/ntp
-----

What does the 'restrict' line do, and what does the different digit after stratum mean?

I changed the system time to silly values, and as it is now there is no sign of ntpd setting the clock to anything. How can I test things?

Robin

Last edited by bitpicker; 02-04-2004 at 03:12 PM.
 
Old 02-04-2004, 03:19 PM   #6
bitpicker
Member
 
Registered: Jul 2003
Location: Germany
Distribution: Xubuntu, Ubuntu
Posts: 416

Original Poster
Blog Entries: 14

Rep: Reputation: 35
Some more: I seem to be missing an argument. Apparently ntpd tries to do something with the servers, but it doesn't work. Here's the content of the logfile:

4 Feb 20:49:50 ntpd[10369]: signal_no_reset: signal 17 had flags 4000000
4 Feb 20:52:57 xntpd[10425]: signal_no_reset: signal 17 had flags 4000000
4 Feb 20:52:59 xntpd[10425]: server returns a permission denied error
4 Feb 20:52:59 xntpd[10425]: signal_no_reset: signal 14 had flags 4000000
4 Feb 20:53:09 xntpd[10425]: ntpd exiting on signal 15
4 Feb 20:53:09 xntpd[10424]: ntpd exiting on signal 15
4 Feb 20:53:09 ntpd[10368]: ntpd exiting on signal 15
4 Feb 21:52:56 ntpd[12490]: signal_no_reset: signal 17 had flags 4000000
4 Feb 08:54:42 ntpd[12489]: sendto(81.95.96.3): Invalid argument
4 Feb 08:54:51 ntpd[12489]: sendto(203.21.37.18): Invalid argument
4 Feb 08:54:51 ntpd[12489]: sendto(209.87.233.53): Invalid argument
4 Feb 08:54:52 ntpd[12489]: sendto(217.127.2.161): Invalid argument
4 Feb 08:54:55 ntpd[12489]: sendto(195.13.23.5): Invalid argument
4 Feb 08:31:50 ntpd[12489]: time set 0.000000 s
4 Feb 08:31:50 ntpd[12489]: synchronisation lost

Any ideas?

Robin
 
Old 02-05-2004, 09:13 AM   #7
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
ntpd will run as a server so people can connect to you and get the time from you. The restrict line restricts ntpd to the local host preventing it from being bound to the external IP. I am not sure if it is really neccesary or not. The number after stratum doesn't matter, so long as you don't change it to 1 or 2.

To test to see if it is working type ntpq -p. It should output something like this:
Code:
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+ns2.anycast.cac Tick.UH.EDU      2 u  332 1024  377   35.768   -2.740   1.931
+ourconcord.net  NAVOBS1.MIT.EDU  2 u  334 1024  377   70.054   15.538   2.334
*ntp-0.gw.uiuc.e truechimer.cso.  2 u  238 1024  377   45.247   -3.063   2.024
 
Old 02-05-2004, 09:14 AM   #8
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Oh, btw, it looks like some of your servers are not letting you in, make sure you pick some off the list that say they are open to the public.
 
Old 02-05-2004, 02:50 PM   #9
bitpicker
Member
 
Registered: Jul 2003
Location: Germany
Distribution: Xubuntu, Ubuntu
Posts: 416

Original Poster
Blog Entries: 14

Rep: Reputation: 35
I have edited the list of servers to only include those which offer open access without notice and include Germany in their service area. I must have another error in my setup, as ntpq -p only gives me 'ntpq: read: Connection refused'

I bet I first have to initialize something or other... but what? And_how?

Maybe it's got something to do with the automatic start of the ntp daemon. Yast advises me not to set it to start automatically during boot, and I have obliged, as it says that the network connection must be started first; and I don't start the connection automatically during startup but only on demand.

I don't know enough about Linux daemons yet to tell whether it is actually running, just because the command gives back a result different from 'command not found'.

Robin
 
Old 02-05-2004, 03:19 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Maybe a firewall is blocking you, or the server
doesn't like you after all ...

Try
ntpdate <servername>
to establish whether you can talk to any of them.

If ntpd were running you'd get an error-message
from ntpdate to that effect.


Cheers,
Tink
 
Old 02-05-2004, 03:34 PM   #11
sethen
LQ Newbie
 
Registered: Apr 2003
Location: Switzerland of Maine
Distribution: RedHat 8.0
Posts: 21

Rep: Reputation: 15
I'm having a problem getting ntp to work... I've got the setup file as you had it, but it cant seem to connect to any server. Period..... Any ideas?
 
Old 02-06-2004, 02:08 AM   #12
bitpicker
Member
 
Registered: Jul 2003
Location: Germany
Distribution: Xubuntu, Ubuntu
Posts: 416

Original Poster
Blog Entries: 14

Rep: Reputation: 35
Funny, I haven't changed anything since yesterday, but now ntpq -p gives me a more useful output:

Code:
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 LOCAL(0)        LOCAL(0)        10 l    4   64    1    0.000    0.000   0.008
 eloise.lost-oas 0.0.0.0         16 u    -   64    0    0.000    0.000 4000.00
 fartein.ifi.uio 0.0.0.0         16 u    -   64    0    0.000    0.000 4000.00
 c-573470d5.06-2 0.0.0.0         16 u    -   64    0    0.000    0.000 4000.00
 kryten.alphazed 0.0.0.0         16 u    -   64    0    0.000    0.000 4000.00
 ntp1.belbone.be 0.0.0.0         16 u    -   64    0    0.000    0.000 4000.00
But the numbers look so much cleaner than the ones in the example posted above that I still suspect there's something wrong. So I disabled the firewall which comes with SuSE 9.0, and here's the output after that:

Code:
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*LOCAL(0)        LOCAL(0)        10 l   55   64   17    0.000    0.000   0.008
 eloise.lost-oas 0.0.0.0         16 u    -   64    0    0.000    0.000 4000.00
 fartein.ifi.uio chronos.cru.fr   2 u   42   64    1  120.836  -103.91   0.008
 c-573470d5.06-2 0.0.0.0         16 u    -   64    0    0.000    0.000 4000.00
 kryten.alphazed 0.0.0.0         16 u    -   64    0    0.000    0.000 4000.00
 ntp1.belbone.be 0.0.0.0         16 u    -   64    0    0.000    0.000 4000.00
Apparently the fartein server is now responding; is that enough? And I cannot find any setting in the firewall setup dialogue which might be responsible for the problem (like excepting a port or something). I'm not sure I should leave the firewall off entirely just for that

Is ntpd supposed to check and set the clock automatically or is there still something I have to do by hand?

Robin

Last edited by bitpicker; 02-06-2004 at 02:09 AM.
 
Old 02-06-2004, 08:53 AM   #13
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
I wouldn't leave off your firewall, but i must be blocking the port somehow. Is it an IP tables firewall?

You really want to try and find at least 3 servers that are responding to get the best results.
 
Old 02-06-2004, 03:16 PM   #14
bitpicker
Member
 
Registered: Jul 2003
Location: Germany
Distribution: Xubuntu, Ubuntu
Posts: 416

Original Poster
Blog Entries: 14

Rep: Reputation: 35
No IP tables, it mostly seems to block everything, though you can checkmark things you want your computer to act as server for. None of these are marked, as I don't operate any kind of server.

Trying it again right now (having made no changes) I get a timeout. Weird.

I don't get it. Maybe I should just set my clock by hand.

Robin
 
Old 02-06-2004, 10:01 PM   #15
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Next thing to check would be
/etc/services ...

Is ntp enabled?


Cheers,
Tink
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ntpd seitan Linux - Software 1 11-29-2004 05:30 AM
ntpd jqcaducifer Linux - General 0 08-21-2003 11:09 PM
ntpd in RH 7.3 melissad Linux - Networking 4 04-28-2003 12:34 PM
ntpd kjelle Linux - Newbie 0 03-05-2002 12:33 PM
ntpd susx Linux - Newbie 3 08-28-2001 04:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration