#!/bin/sh
## th@bogus.net
## ProTip: on OpenBSD you can just do "ifconfig lladdr random"
PATH=/sbin:/usr/bin:/bin
OS=`uname`
TMP=`hexdump -n 6 -v -e '3/1 "%02x:"' /dev/urandom`;
MAC=${TMP%?}

if [[ $1 == "" ]];
then
	echo "Usage: $0 <interface>"
	exit 1
fi

# linux
if [[ $OS == "Linux" ]];
then
	ifconfig $1 hw ether $MAC
	exit 0
fi

# mac os
if [[ $OS == "Darwin" ]];
then
	ifconfig $1 lladdr $MAC
	exit 0
fi

echo "Failed: No supported OS detected: $OS"
exit 1
