Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Aug 2000 17:45:13 +0200 (CEST)
From:      Oliver Fromme <olli@dorifer.heim3.tu-clausthal.de>
To:        freebsd-stable@FreeBSD.ORG
Subject:   Re: Numbering of fxp devices
Message-ID:  <200008241545.RAA00742@dorifer.heim3.tu-clausthal.de>
In-Reply-To: <8o3e6n$1sss$1@atlantis.rz.tu-clausthal.de>

next in thread | previous in thread | raw e-mail | index | archive | help
In list.freebsd-stable Fred Clift <fclift@verio.net> wrote:
 > only active interface.  This actually hasn't been a terrible problem, but
 > it leads to confusion, especially with our new admins.  The less
 > differences between boxes (even though the OS may be a different rev) the
 > better.  Differences just lead to extra administrative effort and can lead
 > to problems.  So, we seek to minimize visible differences like this.  If
 > we had network interface aliases, then we could just set the alias and
 > then train our new sys-admins to always use the alias.

Just an idea...

You could check the MAC addresses upon booting (like the
code that was posted earlier in this thread) and then
assign physical interface names to "virtual" interface
names (for example "eth0", "eth1", etc.) and write this to
a configfile somewhere.  Something like this (this is just
a rough framework, and I haven't actually tested it):

    mv -f /etc/eth.conf /etc/eth.conf.old
    ifconfig -a \
    | awk '
        /^[a-z]/{
            sub(":", "");    # get rid of ":" after iface name
            iface = $1;
        }
        /ether/{
            print iface, $2;    # print iface name and MAC addr
        }' \
    | while read IFACE MAC; do
        case $MAC in
            00:11:22:33:44:55)
                VIRT=eth0
                eval ifconfig_$IFACE='"inet 10.20.30.40 netmask 0xffffff00"'
                ;;
            66:77:88:99:aa:bb)
                VIRT=eth1
                eval ifconfig_$IFACE='"inet 10.20.30.41 netmask 0xffffff00"'
                ;;
            ...
            *)
                echo "Unknown MAC address $MAC!!!" >&2 ;;
        esac
        echo $VIRT=$IFACE >> /etc/eth.conf
    done

The above snippet will create a file /etc/eth.conf that
contains lines like this:

    eth0=fxp1
    eth1=fxp5
    ...

So you can just source that file and then use commands like

   ifconfig $eth0 inet foobar ...
   tcpdump -e -l -v -i $eth1 host baz
   etc...

You can even change that snipped to use a config file that
contains information about which MAC address should be what
eth* name, so you don't have to "hardcode" that in the
script.  You could even distribute that mapping via NIS,
so you can maintain that mapping on a central server for
all machines.  Uhm, thinking about it, this would require
a working network before the interfaces are actually
configured, so forget about that NIS idea.  :-)

Oh by the way, putting such script code into /etc/rc.conf
is a rather bad idea.  That file should only contain
variable assignments, but not actual shell statements.
Having said that, I don't know a place that's much better
to put such things.  It has to be after / has been mounted
r/w, but before rc.network is executed.

Regards
   Oliver

-- 
Oliver Fromme, Leibnizstr. 18/61, 38678 Clausthal, Germany
(Info: finger userinfo:olli@dorifer.heim3.tu-clausthal.de)
Addresses will change soon!!  If in doubt:  www.fromme.com

"In jedem Stück Kohle wartet ein Diamant auf seine Geburt"
                                         (Terry Pratchett)


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200008241545.RAA00742>