[ntp:questions] Re: adsl link

Jan Ceuleers janspam.ceuleers at computer.org
Thu Sep 11 19:12:17 UTC 2003


dg wrote:
> I subscribed to an adsl line whose id changes every 24 hours
> How can i prevent ntp from shutting down as all servers become unreacheable

As others said, I don't think that ntp is shutting down, it's just
becoming unsynchronised. In order to avoid this, you should define a
local clock (and fudge it to a high stratum, e.g. 10), so that your ntpd
will continue to be able to serve time to local clients at times when it
has lost synchronisation with time servers on the Internet.

Anyway, as to your dhcp lease problem. Can you detect when this has
happened? For example, can you get your dhcp client to run a script when
the address has changed?

I don't have quite the same problem as you in that my ISP does not
change the IP address during a PPP session, but the IP address can
obviously change from one session to the next.

I can therefore keep ntpd running on my RedHat 7.2 box, but when it
loses connectivity to the internet as I take the DSL line down, it needs
to fall back to the local clock as described above. Then when the DSL
line comes back up, having been assigned a different IP address, ntpd is
unable to resume its associations as you are also noticing.

What I do to address this problem is run the following script from
/etc/ppp/ip-up.local:

=== begin script
#!/bin/sh
#
# reconfigureNtpd, written by Jan Ceuleers, March 2003
#
# Usage: reconfigNtpd | ntpdc
#

###
#
# Get keyid and password from /etc/ntp/keys
#
###
set -- $(grep "^[[:digit:]]" < /etc/ntp/keys)
echo keyid $1
echo passwd $3

###
#
# Derive unconfig commands from ntpdc output
#
###
ntpdc -n -p | awk '!/==/ && !/^ / { if (substr($1,2) !~ /^127.127./)
print "unconfig " substr($1,2) }'

###
#
# Derive addserver commands from /etc/ntp.conf
#
###
awk '/^server[[:blank:]]/ { if ($2 !~ /^127.127./) print "addserver " $2
}' /etc/ntp.conf

###
#
# Derive addpeer commands from /etc/ntp.conf
#
###
awk '/^peer[[:blank:]]/ { print "addpeer " $2 }' /etc/ntp.conf

echo quit
=== end script

(You may have to remove some CRs from the above).

The script generates commands for ntpdc: first it unconfigs all current
associations other than local-ones (including refclocks), then it
re-adds the server and peer associations that are included in ntp.conf.

If you were to run the above script from your dhcp client, or however
else you detect that your IP address has changed, then I think that this
will solve your problem to a large extent.

Hope this helps.

Jan



More information about the questions mailing list