[ntp:questions] Re: Need ntpdc command to recreate sockets

mayer at gis.net mayer at gis.net
Mon Jan 10 13:51:04 UTC 2005

Enrique Perez-Terron wrote:
> Hello,
> I am on a DSL account that regularly disconnects me for a minute and
> then gives me a different IP address.  I have added a line to restart
> ntpd whenever the ppp0 network device comes up, but I would like to
> ntpd handle the issues internally without loosing the time
> It is not enough to instruct ntpd to recreate the peer structures, as
> keeps an UDP socket bound to the old IP address, and reuses this
> for all communications. However, the socket does not work any more,
> datagrams are set out with the old IP address as the IP-level
> originating address, and no responses ever make it back.
> I imagine it would be easy to add some code to ntpd and ntpdc or ntpq
> close the udp socket and reopen it. With an additional dup2() call
> can ensure the new socket has the same open file descriptor number as
> the old one.
> Do you think this is usefull? Are there any other solutions? Any
> I have missed?
> Maybe I can hack up a patch, but if somebody with "hacking" knowledge
> the ntpd internals could indicate what files to look at, and point at
> any relevant invariants/data structures, it would save me days of
> reading and deciphering.
> I suggest the ntpdc command could be called "recreate-sockets". I see
> point in adding an interface name or IP address argument, because I
> cannot imagine it does any harm to close and reopen all of them.
> anyone think otherwise?
> Regards,
> Enrique Perez-Terron

It's harder than you think and is on my list of things to do. We
basically need to rescan the interfaces, remove the deleted IP
addresses and add the new IP addresses. While it would be possible
to implement a scheme via ntpdc to add/delete a specific IP address,
it would not be easy either. This problem is logged as bug #51 in

I will try to get to it as soon as I have the IPv6 multicasting
issues resolved.


More information about the questions mailing list