Created
November 2, 2018 01:13
-
-
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`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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