[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
ntp_restart()
{
local ntpcmd
ntpcmd="/etc/rc.d/ntpd"
${ntpcmd} status > /dev/null
case $? in
0)
${ntpcmd} restart > /dev/null
;;
1)
${ntpcmd} start > /dev/null
;;
*)
;;
esac
}
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.
Later.
--
Daniel Rudy
More information about the questions
mailing list