Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am trying to set up a machine to act as an ntp server to which the other local machines will syncronise their times to. This needs to happen regardless of whether the ntp server machine is connected to the internet, i.e: it is not important that the time is correct, just that the machines are synchronised with each other.

My configuration files are as follows:

NTP server /etc/ntp.conf

driftfile /var/lib/ntp/ntp.drift

server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 127.127.1.0
fudge 127.127.1.0 stratum 10

restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

restrict 127.0.0.1
restrict ::1

NTP client /etc/ntp.conf

driftfile /var/lib/ntp/ntp.drift

server 192.168.1.146 iburst

restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

restrict 127.0.0.1
restrict ::1

I change the time on the server I then run the ntp server with sudo /etc/init.d/ntp start And try test that the client can receive an ntp update with sudo ntpdate 192.168.1.146

This works, but only when connected to the Internet (even though the master has the time set by my command and not from an external ntp server/s).

Anything in my configuration files wrong? Any step I am missing?

share|improve this question
    
"This works, but only when connected to the Internet" <-- How do you know it's not working when not connected to the Internet??? Error messages? Diagnostic information? Logs? Anything? –  Chris S Sep 16 '13 at 15:06
    
Because when I alter the time on the master and ntpdate the slaves they say "no server suitable for synchronization found" and don't update to the altered time –  tom Sep 16 '13 at 15:59
    
Why would you manually change the time on the master once it had been synced? What are you really trying to do? –  Zoredache Sep 16 '13 at 17:36
    
Because currently all the machines are connected to the internet. So to check they can receive their time from the master i change the master's time and update make the slaves update their times. I can't seem to get the slaves to update if none of the machines are connected to the internet, and they don't update automatically, only when i call ntpdate –  tom Sep 18 '13 at 9:43

2 Answers 2

I provided a detailed answer, some time back, of how we do exactly what you're looking to do in our data centers. Not much has changed since I made that post.

Link to the post:

Using NTP to sync a group of linux servers to a common time source

share|improve this answer
1  
It's too bad that original question and answer weren't accepted. –  TheCleaner Sep 16 '13 at 15:41
    
this answer was not useful to me, it is simply a detailed description of ntp in a completely different setting –  tom Sep 18 '13 at 9:45
    
umm, not sure what you mean by completely different setting. It's different in one sense but not in the goal. The setup addresses your two goals of (1) "a machine to act as an ntp server to which the other local machines will syncronise their times to." (2) "This needs to happen regardless of whether the ntp server machine is connected to the internet". So you could omit the firewall stuff I mentioned and still glean something from this could you not? –  Kilo Sep 18 '13 at 19:39

I'll make the assumption that your time server is connected to the internet often enough that NTP can figure out what your error rate is and generate a good guess of how to discipline the kernel clock.

First off, I suggest removing the following two lines from your /etc/ntp.conf file. They cause issues in the long run and are rarely needed. As long as the NTP server managed to synchronize and start disciplining the kernel clock, it should still hand out time even if the internet is disconnected for a while.

server 127.127.1.0
fudge 127.127.1.0 stratum 10

Secondly, run "ntpq -p" on your time server to figure out whether it has synchronized to the public time servers before starting to test the clients. Manually stepping the time on the server is simply a bad idea when testing. Don't do that. Start up your time server, then let it sit and sync with the upstream time servers for 30 minutes. Your internal time server will not hand out time until it has synchronized with the public time servers (and I think the PPM has to be under 500). NTP will not serve what it considers to be "insane" time to clients and you need to allow 10-30 minutes for it to decide which of the time sources to follow.

You can then run "ntpq -p" on the clients as well, to see whether they have synchronized and how close they are to your time server.

Third, you may want to move up from (3) servers in your time server's ntp.conf file to (5) or (6). Right now, if one of your three goes insane or becomes unreachable, NTP can't tell which of the remaining two offers the better time signal.

There are a few things that control how well NTP will keep the kernel clock disciplined when no time servers are reachable. One is the PPM (see "ntpdc -c kerninfo"), which is how far off the TSC or HPET or APIC clock is from reality (based on public time servers). Another is temperature fluctuations and/or power management settings that change the frequency of the CPU. Then there is the quality of the timing crystals, which might be good if you are lucky, or really poor.

And maybe you need to consider a GPS or WWVB time source.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.