Skip to content

Instantly share code, notes, and snippets.

@KellyLSB
Created November 26, 2012 07:08
Show Gist options
  • Save KellyLSB/4146970 to your computer and use it in GitHub Desktop.
Save KellyLSB/4146970 to your computer and use it in GitHub Desktop.
Updates a cloned Parallels Ubuntu VM network interface configuration with the proper mac address
#!/usr/bin/env sh
#
# Change the MAC Address on an Ubuntu Parallels Cloned VM
# Author: Kelly Becker (KellyLSB)
# Check for sudo access
SUDO=`sudo -n uptime 2>&1|grep "load"|wc -l`
if [ $SUDO -lt 1 ]
then
echo "You need to have sudo priveleges!"
exit
fi
NEW_MAC=`sudo lshw -C network | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'`
UDEV_RULE=/etc/udev/rules.d/70-persistent-net.rules
# Make the change
echo "Updating the udev mac address to $NEW_MAC..."
sudo sed -ie "s/\([[:xdigit:]]\{1,2\}:\)\{5\}[[:xdigit:]]\{1,2\}/$NEW_MAC/g" $UDEV_RULE
# Restarting the computer
echo "Restarting VM"
sleep 5
sudo shutdown -r now
exit
@firemonk9
Copy link

this works great. ... thank you saved me an hour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment