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

I have a few Linux devices (without TOY chips, so they completely rely on ntp) which may boot without access to Internet (the link to the switch is up). The ntp service will start but obviously no peers will be contacted. I then end up with an ntp service which is running but not synchronizing with any peers (ntpq -p gives an .INIT. status)

The problem is that this does change when connection to Internet is established.

If the connection is available at boot time then everything works fine. Idem if I manually issue a service ntp restart (ntp connects to the peers and time is correctly synchronized).

Shouldn't ntp try to reconnect at regular intervals?

  • if yes: is this something I am expected to configure (I did not see anything in the config)
  • if not: what would be a good way to handle the service restart, or service start delay (I could assume that connectivity to Internet will be back n minutes after bootup)

Note: It looks like from the docs that the maximum pool time (which I understand is the max time ntp will try to connect to peers before giving up?) is 1024 seconds = 17 minutes, which is way more than the time needed to establish Internet access (about 2 to 5 minutes, worst case)

share|improve this question
add comment

2 Answers

up vote 12 down vote accepted

You might have been bitten by an edge case for ntpd:

IIRC ntpd versions < 4.2.4p3 removed any servers from it's synchronization list that couldn't be reached at some point. This is of course quite bad in this case, as ntpd might very well 'exhaust' the list of its peers before gaining internet connectivity.

One could/can set the dynamic option for these servers in ntp.conf to work around this issue.

With newer versions, this shouldn't be necessary anymore (also, the dynamic option was retired at some point, which caused minor gripes for some people with ntp's complaining all of a sudden).

So, you can either upgrade your ntpd, or set the option.

As a third option, you can create a proper dependency in your init system; making ntpd to rely on an established internet connection (not just network). The upshot would be that you can reuse this with other services as well.

share|improve this answer
    
dynamic did the trick, thanks! –  WoJ Dec 7 '13 at 21:24
add comment

Debian OpenNTPD packaging automatically restarts it if an interface comes up. This is common.

Also, you will (usually) need to sync one-shot before starting xntpd anyway, so I suggest this is the way to go.

share|improve this answer
    
The interface is up. It is Internet which is not reachable. –  WoJ Dec 6 '13 at 17:32
    
I also never needed to sync one shot. This is clearly a possible case but a service restart cleans the status up. –  WoJ Dec 6 '13 at 17:36
add comment

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.