Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Solves the airport wifi time limit problem. Don't forget to `sudo chmod +x`.
# Getting interface name
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 ]
echo "Set MAC address on $interface to $result"
exit 0
echo "Failed to reset MAC address on $interface"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment