[ntp:questions] [CONTRIBUTION] Using ntpd in a dynamic IP environment on FreeBSD systems.

Daniel Rudy nospam at nospam.net
Wed May 11 00:17:52 UTC 2005

Some time ago, I asked a question here if it was possible to have ntpd 
automatically sense if the IP address has changed.  The answer to that was 
no, but it was on the todo list.  The work around suggested was to restart 
ntpd when the IP address changed.  So, I have developed a borne shell script 
that will handle this.  This works in FreeBSD 5.x which uses the SVR4 style 
of starting network service daemons.

# This is to restart the network time protocol daemon
  local ntpcmd
  ${ntpcmd} status > /dev/null
  case $? in
      ${ntpcmd} restart > /dev/null
      ${ntpcmd} start > /dev/null

If ntpd is running, then it's restarted.  If it is not running, then it is 
started.  This works directly with /etc/rc.conf on FreeBSD systems so any 
changes to rc.conf reguarding ntpd will take affect without modifying this 
code.  Place this code in the script called by dhcpclient or ppp.linkup and 
call ntp_restart.

Daniel Rudy

More information about the questions mailing list