I had a recent experience in which my FreeBSD system would not configure
my Ethernet card because the specification in rc.conf was for a different
type of card.  It seems like FreeBSD could easily handle the general case
(only one network interface) automagically, letting folks with fancier
systems add more specific configuration information.  So, instead of:

  ifconfig_dc0="       inet 192.168.254.193 netmask 255.255.255.0"

one could use:

  ifconfig_SGL="       inet 192.168.254.193 netmask 255.255.255.0"

and the system would automagically configure a single networking interface.
Here is a first-cut implementation of some code to do this:

=================
:
# iffy - automagical definition of interfaces
#
# Written by Rich Morin <[EMAIL PROTECTED]>, CFCL, 2002.11

# set -x                                                        # DEBUG

  ifconfig_SGL="inet 192.168.254.193 netmask 255.255.255.0"     # DEBUG

if [ "$ifconfig_SGL" ]; then
        ifns=`ifconfig -l link`
        if [ ! "$ifns" ]; then
                echo "no interfaces found"                      # DEBUG
                exit
        fi

        echo "ifns=|$ifns|"                                     # DEBUG

        cnt=
        for ifn in $ifns; do
                eval test=\$ifconfig_${ifn}
                if [ "$test" ]; then
                        echo "interface ($ifn) defined"         # DEBUG
                        exit
                fi
                cnt=".$cnt"
        done
        if [ "$cnt" != '.' ]; then
                echo "too many interfaces found"                # DEBUG
                exit
        fi
        eval ifconfig_${ifn}=\$ifconfig_SGL

             echo "VAR: ifconfig_${ifn}"                        # DEBUG
        eval echo "VAL: \$ifconfig_${ifn}"                      # DEBUG
fi
=================

It could be made a bit fancier, to be sure.  For example, it would be
nice to handle things like

  ifconfig_SGL_alias0="inet 192.168.254.199 netmask 255.255.255.255"

First, however, I'd like to know if the general idea/approach/... is
faulty.  Comments, anyone?

-r

--
email: [EMAIL PROTECTED]; phone: +1 650-873-7841
http://www.cfcl.com/rdm    - my home page, resume, etc.
http://www.cfcl.com/Meta   - The FreeBSD Browser, Meta Project, etc.
http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series
http://www.ptf.com/tdc     - Prime Time Freeware's Darwin Collection

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to