[ntp:questions] Re: ntp and dynamic IP

Vincent Smeets V.Smeets at T-Online.de
Thu Jun 30 20:18:26 UTC 2005


Hallo,

I have written a more elegant script. I have attached it (sorry) to this 
message and can be saved in the directory /etc/ppp/ip-up.d

It uses a key (and password) together with the command ntpdc to change 
the configuration of the ntp daemon.

If you enter the command "ntpdc -n -p", you get in the first column the 
ip-address of the peer, and in the second column the local address. I 
have found out that after an initial startup, the local address is 
filled with the address of your interface. If the address of the 
interface is changed (after a reconnect), ntp can't send the data from 
the old socket (with the old local address).

I have seen that peers added dynamicly by ntpdc have a local address of 
0.0.0.0 which is any-address. They keep on working after that the local 
address of the interface has changed.

My script skips local clocks (127.127.?.?) and dynamicly added peers 
(0.0.0.0). Alle other peers are removed (unconfig) and added (addserver) 
again. At the end are some public available peers added, so that I 
always have at least 4 peers.


I hope it is usefull,
Vincent Smeets


Ricardo Yanez wrote:
>>my ISP disconnects me once a day, so that I won't keep a quasi-static IP
>>I don't pay for. Now, pppd reconnects swiftly, but ntp doesn't seem to
>>like this anyway. Soon after the dis-/reconnect I get this:
> 
> 
>>Feb  9 13:15:01 zwerg ntpd[4732]: sendto(192.53.103.104): Invalid argument
>>Feb  9 13:15:07 zwerg ntpd[4732]: sendto(130.149.17.21): Invalid argument
>>Feb  9 13:16:08 zwerg ntpd[4732]: sendto(195.145.119.188): Invalid argument
>>Feb  9 14:41:27 zwerg ntpd[4732]: synchronisation lost
> 
> 
>>As it will never recover, I resorted to restarting ntp every day. But
>>surely, there's a more elegant solution. Or is there?
> 
> 
> Hi,
> An elegant (I think) way of solving this is to 
> put scripts in /etc/ppp/ip-[up|down].d/ to stop 
> and start ntpd when pppd reconnects.
> 
> My /etc/ppp/ip-down.d/ntp-server simply says,
> 
> -----
> #!/bin/sh
> 
> [ -x /usr/sbin/ntpd ] || exit 0
> 
> echo "Stopping NTP server"
> /etc/init.d/ntp-server stop
> -----
> 
> and my /etc/ppp/ip-up.d/ntp-server,
> 
> -----
> #!/bin/sh
> 
> [ -x /usr/sbin/ntpd ] || exit 0
> 
> echo "Starting NTP server"
> /etc/init.d/ntp-server start
> -----
> 
> Just make sure these scrips are executable (755).
> 
> Ricardo
> 
> 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ntpd
URL: <http://lists.ntp.org/pipermail/questions/attachments/20050630/9182f79d/attachment.ksh>


More information about the questions mailing list