[SGVLUG] Random MAC address.

Sean O'Donnell sean at seanodonnell.com
Thu May 31 11:21:46 PDT 2007


John E. Kreznar wrote:
> Glad you solved it.  For the record, here's another approach that
> works on a Debian box that I use.  It uses the "mapping" feature
> described in interfaces(5).  Here's /etc/network/interfaces:
> 
>    auto lo
>    iface lo inet loopback
> 
>    # Closely following an example in
>    # /usr/share/doc/ifupdown/examples/network-interfaces.gz
> 
>    auto eth0 eth1
> 
>    mapping eth0 eth1
> 	   script /etc/network/get-mac-address.sh
> 	   map 00:09:5b:60:22:12 lan
> 	   map 00:00:b4:4a:37:ea internet
> 
>    iface lan inet static
> 	   address 192.168.1.4
> 	   network 192.168.0.0
> 	   netmask 255.255.0.0
> 	   broadcast 192.168.1.255
> 
> (There's no clause in there now for the "internet" nic because it's
> actually out of service on that machine, but I needed this anyway to
> select the correct nic for the lan.)
> 
> Here's the referenced script /etc/network/get-mac-address.sh:
> 
>    #!/bin/sh
> 
>    set -e
> 
>    export LANG=C
> 
>    iface="$1"
>    mac=$(/sbin/ifconfig "$iface" | sed -n -e '/^.*HWaddr \([:[:xdigit:]]*\).*/{s//\1/;y/ABCDEF/abcdef/;p;q;}')
>    which=""
> 
>    while read testmac scheme; do
> 	   if [ "$which" ]; then continue; fi
> 	   if [ "$mac" = "$(echo "$testmac" | sed -e 'y/ABCDEF/abcdef/')" ]; then which="$scheme"; fi
>    done
> 
>    if [ "$which" ]; then echo $which; exit 0; fi
>    exit 1
> 
> If you're interested, do look at that examples file mentioned in the
> comment.  It's too long to summarize here.
> 

Thanks, John.

Unfortunately, Slackware doesn't use the 'interfaces' approach or
'mapping' features.

I don't know if the udev approach I used to solve this is applicable on
the 32-bit version of Slackware 11, but I suspect that it isn't.

If udev hadn't worked for me, I would have probably written a shell
script to do it all, but udev allowed me to solve the problem in
minutes, and I was lucky enough to spend my evening with a nice female
friend instead! *thx udev!* ^5! =)

-- 
Sean O'Donnell
South Pasadena, CA

sean at seanodonnell.com
http://seanodonnell.com

PGP Public Key ID: 0xF57FB9E5
PGP Public Key Server: http://pgp.mit.edu

*The important thing is not to stop questioning. Curiosity has its own
reason for existing.*




More information about the SGVLUG mailing list