LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-24-2010, 07:17 AM   #1
dhavalshah9898
LQ Newbie
 
Registered: Mar 2010
Posts: 11

Rep: Reputation: 0
help with NTP


Hi All,

i am sending my first questing on such forum.
i am using broadcom router .
when some one set time server name in time settings field
in router what kind of settings we have to do so that
system get time(sync with that) from that particular server.
i have already get very good answer from this forum so i know
i get very good answer which help me a lot.
your help is appreciated.
 
Old 03-24-2010, 07:59 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,478

Rep: Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020
If you have a time server on your network -- a machine that is synchronized with a time source such as a GPS clock, radio clock, or external time source such as a national time service -- all you need to do is set the address of that server in the /etc/ntp.conf file.

For example, if your time server's address is 192.168.1.10, the entry in your /etc/ntp.conf file would look something like this
Code:
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10
server  192.168.1.10
The reason for the "local clock" line and the "stratum 10" line is so NTP can sync locally if the external time server is not available for some reason.

You may want to add a couple of external pool servers to the entry; they of the form
Code:
server   0.cc.pool.ntp.org
server   1.cc.pool.ntp.org
where "cc" is the two-character country code for where you are in the world (in my case the entries are 0.us.pool.ntp.org); you want two or three of these electrically close to you to pick up the slack if your internal time server becomes unavailable.

The router you're using does not need any special settings as long as your local server can "see" the time server, you're good to go. If you have set up your LAN to require some sort of port access or the like, you may need to open that port on the router, but that would probably be unusual.

And, finally, if the time server has a "name" it also has an address -- you need to know the address to make the entry in /etc/ntp.conf. The example I've used above, 192.168.1.10, is a reserved for private network address (the 192.168.x.x) and you will need to use your LAN address.

If you make any changes to /etc/ntp.conf, you will need to stop and restart the NTP daemon. Also, if your local clock is not close to the correct time, NTP will not sync so you may need to stop the NTP daemon and use the ntpdate utility to set your local clock before starting the NTP daemon; e.g.,
Code:
ntpdate address_of_time_server
Hope this helps some.
 
Old 03-25-2010, 12:32 AM   #3
dhavalshah9898
LQ Newbie
 
Registered: Mar 2010
Posts: 11

Original Poster
Rep: Reputation: 0
thanks a lot for your quick reply
this helps me a lot but i want to know what is a use of "fudge".
now as i understand from your reply
when someone add time_server_name in time setting field of router page(web page)
then
i have to add

server time_server_name

instead of

server 192.168.1.10

in ntp.conf file

and then ntpd stop
am i right.
your help is appreciated.
 
Old 03-25-2010, 07:45 AM   #4
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,478

Rep: Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020
Maybe, maybe not: if your system "knows" time_server_name by name; i.e., you can open a terminal window and ping time_server_name (obviously using the name of the server, not "time_server_name"), then, yes, you can use the name. It might be better, if the time server is using fixed IP addressing; i.e., the address of the server never changes, then if you use the actual address then the name doesn't have to be resolved. That means that your system does not have to contact a DNS server to get the address from the name (if you ping the server by name, the display will show you the address, for example)
Code:
prompt: ping -c 6 0.us.pool.ntp.org
PING 0.us.pool.ntp.org (66.36.239.104) 56(84) bytes of data.
64 bytes from 66.36.239.104: icmp_seq=1 ttl=49 time=213 ms
64 bytes from 66.36.239.104: icmp_seq=2 ttl=49 time=194 ms
64 bytes from 66.36.239.104: icmp_seq=3 ttl=49 time=252 ms
64 bytes from 66.36.239.104: icmp_seq=4 ttl=49 time=184 ms
64 bytes from 66.36.239.104: icmp_seq=5 ttl=49 time=252 ms
64 bytes from 66.36.239.104: icmp_seq=6 ttl=49 time=185 ms

--- 0.us.pool.ntp.org ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5003ms
rtt min/avg/max/mdev = 184.999/214.121/252.983/29.109 ms
The important thing is that your system can quickly and easily find the time server and you can use either the time server's name or the actual address (if it's fixed IP).

In the example I gave you, using a couple of pool servers in addition to your time server, I don't know their addresses and one of the truly nice things NTP does when you give it three or so time servers (the pool servers in this case) is that it will determine the best time server to use and switch from one to another if for some reason the initial choice drops out or becomes slower than one of the others. When you have an actual time server on your LAN, it's most likely going to be the closest electrically (that is the ping time is the shortest) and NTP will synchronize with it all the time. The idea of having external pool servers available is that if you LAN time server goes away for some reason (system maintenance, the LAN goes down, the phase of the moon, whatever) there are one or two external servers to back it up just in case.

So, you can make your entry either way -- name or address. If you can ping the name, that'll work (and might be better if the server is not using fixed IP addressing). LAN time servers typically do not use DHCP addressing but, if yours does, then you want to use the server name because the address may change periodically.

And, once you've made your entries, stop NTPD then start NTPD. After about five minutes you can see if you're sync'd up by executing ntpq like this
Code:
prompt ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 LOCAL(0)        .LOCL.          10 l   58   64  177    0.000    0.000   0.001
+ntp1.Rescomp.Be 169.229.128.214  3 u    3   64  377  226.953   -6.159   3.536
*mirror          204.9.54.119     2 u   59   64  177  170.957   -5.269   7.542
+ns1.your-site.c 10.1.11.62       3 u   62   64  177  191.950   -3.331   7.818
Recall that I use three pool time servers (and this particular machine is on a dial-up line right now so the values are a little larger than they would otherwise be); the important thing is the plus signs and asterisk at the left end of the lines -- those tell you that you're in sync with the time server and that there are additional candidates for switching if the time server goes away.

Hope this helps some.
 
Old 03-26-2010, 12:30 AM   #5
dhavalshah9898
LQ Newbie
 
Registered: Mar 2010
Posts: 11

Original Poster
Rep: Reputation: 0
thanks a lot.
this is very good reply for me.
now i want to know what is difference between ntpdate and ntpd?
can it possible to do the whole task of NTP by using only ntpdate
if i don't want to use ntpd.
because i have to change my linux system time whenever someone change time server name in router time setting (web page) page.
and also i have to execute cronjob of this time synchronization 1 time in a day.
i expect same more knowledgeable answer from you.
i am actually learning from your answer day to day.

Last edited by dhavalshah9898; 03-26-2010 at 12:31 AM.
 
Old 03-26-2010, 07:39 AM   #6
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,478

Rep: Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020
The ntpdate utility is a one-time set-the-clock-from-a-time-server. The daemon, ntpd, keeps the system clock synchronized with with a time reference (national time servers, GPS clocks and the like -- they're all referenced is to the so-called atomic clocks maintained around the world).

The clocks in computer systems are notorious for drifting, gaining and losing time. You'd think, what with wristwatches being as accurate and cheap as they are, that it wouldn't be too much trouble to keep accurate time in a computer but that just isn't the case (for a lot of reasons that I'll leave to you to discover). Essentially, your system clock will drift and it needs to be adjusted periodically to get it back in sync with the reference standard. That's what the NTP daemon does (and that's a Good Thing: networks and things work a little better if they're all on the same time).

It is unlikely that your network time server is going to change addresses; when a LAN time server is set up, the whole idea of doing so is to provide a time reference for all the computers attached to the LAN to keep them all in sync. You just don't fiddle with it once it's in place. And, when the time server system is rebooted or whatever it will only be out of service for a short period -- the beauty of NTP is that sort of thing is taken into account. If your network connection goes away or your LAN time server goes away, NTP will simply fall back to LOCAL (the internal clock) if the network drops off or to one of the pool servers you add to /etc/ntp.conf. When your LAN time server comes back, NTP automagically switches back to it and syncs your system. It's invisible, it's automatic and it requires no action on your part -- this is also a Good Thing.

Of course you can, if you choose, not use the daemon at all. You could set up a cron job to execute ntpdate once every X hours and that would keep your system clock pretty much on time. But you need to figure out how to set up the cron job, test it, check every so often to make sure that it's running and all that; why bother? You have a time server available, you can access pool servers to back that up and you don't have to fiddle with anything. The NTP daemon uses an insignificant amount of resources (you'd be hard-pressed to notice it), it works so you don't have to.

Hope this helps some.
 
Old 03-30-2010, 01:18 AM   #7
dhavalshah9898
LQ Newbie
 
Registered: Mar 2010
Posts: 11

Original Poster
Rep: Reputation: 0
thanks a lot this helps me a lot.
 
  


Reply

Tags
ntp


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
ntp drift file in /etc/ntp instead of /var/lib/ntp - suggestion for a patch in Slack niels.horn Slackware 16 05-07-2009 08:35 PM
help with NTP stevenhasty Slackware 6 02-16-2005 12:04 PM
NTP cannot work with timeserver, NTP-d can jerryvapps Linux - Networking 0 08-04-2004 03:04 PM
NTP cannot use server, NTP -d can jerryvapps Linux - Newbie 0 07-28-2004 03:22 PM
Help with ntp triley Linux - General 1 01-30-2004 12:47 PM


All times are GMT -5. The time now is 10:57 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration