Skip to content

Instantly share code, notes, and snippets.

@ihatem
Created April 8, 2019 23:24
Show Gist options
  • Save ihatem/14092668d531f410b5e47d1c2d9cf1c9 to your computer and use it in GitHub Desktop.
Save ihatem/14092668d531f410b5e47d1c2d9cf1c9 to your computer and use it in GitHub Desktop.
Generate mac adress with randomized hex
#! /bin/bash
CURRENT=`ifconfig en1 | grep ether | cut -c8-24`
RANDOM=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
echo "Current MAC Adress : $CURRENT"
echo "Random MAC Adress : $(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')"
printf "Continue Y/N? "; read res
if [[($res == "Y")]]; then
sudo ifconfig en1 ether $(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
else
echo "quitting..."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment