[SGVLUG] Random MAC address.

John E. Kreznar jek at ininx.com
Wed May 30 02:03:55 PDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Sean O'Donnell" <sean at seanodonnell.com> writes:

> /etc/udev/rules.d/network-devices.rules ...

> I did notice that inside that file, my nic cards were all already
> listed, but commented-out. ...

> Removing the comments and rebooting, all seems to work.

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.

- -- 
 John E. Kreznar jek at ininx.com 9F1148454619A5F08550 705961A47CC541AFEF13
  It may never be known how much Bill Gates set the world back.  Today
  there are millions of people who would be as fluent in a computer
  programming language as they are in their natural language but for the
  fact that they were deceived by Bill Gates into believing that
  programming is best left to professionals.  Mediaeval illiterates may
  have had an excuse for needing scribes, but today it's simply
  pathetic.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8+ <http://mailcrypt.sourceforge.net/>

iD8DBQFGXT3sYaR8xUGv7xMRAvZqAJ9wPLtJjmcfzA8rpM/NC/BXE13kBQCfQn2M
M3a4Ggtw6htVwIDRL7lvCxQ=
=j+57
-----END PGP SIGNATURE-----



More information about the SGVLUG mailing list