Traveling a lot and need to reset your MAC address? Here’s how to do it on both macOS and Linux.
🍏 macOS: Resetting MAC Address
On macOS, you’ll be using the airport
and ifconfig
utilities. Here’s a one-liner you can run in your Terminal (note: replace en0
with your actual wireless interface):
1
2
sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport en0 -z && \
sudo ifconfig en0 ether $(openssl rand -hex 6 | sed 's/../&:/g; s/:$//')
What It Does:
airport -z
: Disassociates from any wireless network.openssl rand -hex 6
: Generates 6 bytes (12 hex characters) of random data.sed
: Formats the output to match MAC address style (e.g.,02:1A:3F:BB:4D:99
).ifconfig en0 ether ...
: Sets the new MAC address.
🐧 Debian/Ubuntu Linux: Resetting MAC Address
On Debian-based systems, use the ip
command. The following script generates a valid random MAC address (starting with 02:
to indicate it’s locally administered).
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/bash
NEW_MAC=$(printf '02:%02x:%02x:%02x:%02x:%02x\n' \
$((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) \
$((RANDOM%256)) $((RANDOM%256)))
IFACE="wlan0" # Replace with your actual interface (use `ip link show`)
sudo ip link set "$IFACE" down
sudo ip link set "$IFACE" address "$NEW_MAC"
sudo ip link set "$IFACE" up
echo "MAC address for $IFACE changed to $NEW_MAC"
⚠️ Be sure to replace
wlan0
with your actual wireless interface name. Runip link show
to find it — often it’s something likewlp0s20f3
.
🧠 Final Notes
- These changes are temporary and will reset after a reboot or network reconnect.
- For permanent spoofing, consider using NetworkManager profiles or
macchanger
. - Not all Wi-Fi adapters support MAC address spoofing — test and confirm!