Subject: Re: simple-minded configuration for rc?
To: Marshall Rose <>
From: Richard Rauch <>
List: netbsd-users
Date: 12/14/2002 12:50:34

I faced a similar problem with my laptop.  What I did was write an
rc.d/networkprobe script that uses ping to check for known combinations of
hardwired network environments.  (Actually, I only had 2 such
environments, and no DHCP normally.)  What I came up with was:

 /~~~ /etc/rc.d/networkprobe

# $$

# PROVIDE: networkprobe
# REQUIRE: network



        # This really should walk through a set of alternative config.
        # files, rather than being hard-coded in a shell function as
        # I currently do.
        echo "Probing network."
        if /sbin/ping -h ricegate -qQ -w 1 -c 1 >/dev/null; then
                # nothing to do; we are
                echo " (office)"
                /bin/hostname odysseus
                /sbin/ifconfig ne0 inet odysseus netmask >/dev/null
                /sbin/route change default prodigy-gate
                if /sbin/ping -h prometheus -qQ -w 1 -c 1 >/dev/null; then
                        echo " (home)"
                        echo " (unknown)"

        # Nothing to do, really.

load_rc_config $name
run_rc_command "$1"

 \___ /etc/rc.d/networkprobe

Where "ricegate", "odysseus" and "prodigy-gate" are in my /etc/hosts.
The "office" environment's nameservers worked from other locations, so I
kept just one resolv.conf.

The system was basically hardwired for my office as the first default
(using standard config. mechanisms) and then would *check* if that was
correct; if not, it would retarget, using the above script.

The up side is that this would automatically configure itself.  Of course,
it would only do that at boot time, and each failed ping-probe, above,
adds about 1 second.  I found it very convenient.

  ``I probably don't know what I'm talking about.''