On 10/12/06, Nic James Ferrier <[EMAIL PROTECTED]> wrote:
> In my quest for the perfect network setup for a VM here is a piece of
> code that will allocate mac addresses from a pool.

I took a simpler route for pseudo-random non-varying mac address
generation.  Here you go:

echo $(hostname)${UMID} | md5sum | \
awk '{print "00:08:93:"substr($1,1,2)":"substr($1,3,2)":"substr($1,5,2)}'

This combines the umid you expect you assign to the instance with the
hostname of the host.  That way, the mac address will be the same each
time it boots, but if I have 2 instances on different hosts both named
"test", they won't clobber each other.

For non-temporary instances, my homebrew system has a field for mac
addresses.  If it is empty, the above code is used.  But for permanent
instances, I create a completely random mac ahead of time:

dd if=/dev/urandom bs=1k count=1 2>/dev/null | md5sum | \
awk '{print "00:08:93:"substr($1,1,2)":"substr($1,3,2)":"substr($1,5,2)}'

Ryan

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
User-mode-linux-user mailing list
User-mode-linux-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user

Reply via email to