Skip to content

Instantly share code, notes, and snippets.

@max-degterev
Created November 2, 2018 01:13
Show Gist options
  • Save max-degterev/ec4a9c913f846a0ef9cf7ada1a50f1cd to your computer and use it in GitHub Desktop.
Save max-degterev/ec4a9c913f846a0ef9cf7ada1a50f1cd to your computer and use it in GitHub Desktop.
Solves the airport wifi time limit problem. Don't forget to `sudo chmod +x resetmacaddress.sh`.
#!/bin/sh
# Getting interface name
interface=en0
read -p "Interface please (default en0): " otherinterface
[ -n "$otherinterface" ] && interface=$otherinterface
# Generating new MAC adderess
newmac=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
# Resetting MAC address. Asking for permissions
echo "We need sudo access to reset network interface 🔑"
sudo ifconfig $interface ether $newmac
# Checking if changes hold
result=$(ifconfig $interface | grep ether | sed -E 's/^[[:space:]]+ether[[:space:]]//g')
# Output
if [ $newmac = $result ]
then
echo "Set MAC address on $interface to $result ✅"
exit 0
else
echo "Failed to reset MAC address on $interface ❌"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment