Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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