named and ntpd start order in rc.d

RW fbsd06 at
Fri Dec 5 19:06:46 PST 2008

On Sat, 06 Dec 2008 01:11:38 +0100
cpghost <cpghost at> wrote:

> RW wrote:

> > I have a similar issue with PPP not having connected by the time
> > ntpdate runs , so I just have a script that runs between named and
> > ntpdate, and blocks waiting for access.
> >   
> Those timing / start-order issues are getting more and more
> annoying, IMHO. On my PPPoE / mpd5 connected systems,
> it's the same problem:
>  * openntpd (from ports) can't start, because named is not ready
>  * pf can't parse /etc/pf.conf because the ng0 interface is not yet
> there etc, etc, etc...
> Isn't there a generic way to delay some scripts from starting
> until a specific subset is ready (say: networking fully up,
> and named ready to reply)? Perhaps some keyword or class
> to add to a startup script would be nice to have!

I don't think there's a generic solution, but I've pasted my own
script below, I think if you set "networkwait_ping_hosts" to a
name, rather than IP addresses, it might solve both your
problems. You'll be polling on dns, and then resyncing the pf rules.

$ cat /usr/local/etc/rc.d/networkwait
# PROVIDE: networkwait
# REQUIRE: named
# BEFORE:  ntpdate

. /etc/rc.subr



   if [ "$networkwait_ping_hosts" ] ; then
      # No hosts supplied - use external nameservers
      host_list=`awk '/^ *nameserver/ {print $2}
        '< /etc/resolv.conf | grep -E -v '^127\.0+\.0+\.0*1'`
   echo -n "Waiting for network access ... "
   while true ; do
      for inet_host in $host_list ; do
         if ping -nc1  $inet_host 2>&1 > /dev/null ; then
            echo "ping to ${inet_host} succeeded."
            # Re-Sync ipfilter and pf in case
            # they had failed DNS lookups
            /etc/rc.d/ipfilter resync
            /etc/rc.d/pf resync
            exit 0
      sleep 5

load_rc_config ${name}
run_rc_command "$1"

More information about the freebsd-questions mailing list