Skip to content

Instantly share code, notes, and snippets.

@trasherdk
Forked from WebReflection/randommac.sh
Created June 10, 2017 17:15
Show Gist options
  • Save trasherdk/7434e36ee33e56cedf1d7396eab56ea5 to your computer and use it in GitHub Desktop.
Save trasherdk/7434e36ee33e56cedf1d7396eab56ea5 to your computer and use it in GitHub Desktop.
Getting free wifi on Linux too
#!/usr/bin/env bash
# @example
# chmod a+x randommac.sh
# ./randommac.sh wlp2s0
# @credits original macOS / osX version via @rem
# https://remysharp.com/2017/05/29/getting-free-wifi
if [ "$1" != "" ]; then
if [ "$(ip link show | grep $1)" != "" ]; then
if [ ! -f ~/mac-address.bck ]; then
echo "storing original information in ~/mac-address.bck"
ip link show > ~/mac-address.bck
fi
sudo ip link set dev $1 down
sudo ip link set dev $1 address $(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
sudo ip link set dev $1 up
else
echo "unknown interface $1"
echo "available interfaces:"
ip link show | sed 's/^\([0-9]*:\s*\w*\):.*$/\1/g; s/^\s\s*.*$//g'
exit 1
fi
else
echo "you need to specify an interface"
echo "example: $0 wlp2s0"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment