Skip to content

Instantly share code, notes, and snippets.

@egemenyildiz
Created January 26, 2017 15:02
Show Gist options
  • Save egemenyildiz/d3199f4616f0bb127fde6ed0542012fb to your computer and use it in GitHub Desktop.
Save egemenyildiz/d3199f4616f0bb127fde6ed0542012fb to your computer and use it in GitHub Desktop.
bash function to spoof hw/MAC address of active/current interface
spomac() {
IFACE=$(ip route get 8.8.8.8 | awk '{print $5}' | head -1)
MAC=$(printf '%02x' $((0x$(od /dev/urandom -N1 -t x1 -An | cut -c 2-) & 0xFE | 0x02)); od /dev/urandom -N5 -t x1 -An | sed 's/ /:/g')
ifconfig $IFACE down;
ifconfig $IFACE hw ether $MAC;
ifconfig $IFACE up;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment