Skip to content

Instantly share code, notes, and snippets.

@brndnmtthws
Created February 28, 2024 19:01
Show Gist options
  • Save brndnmtthws/e31ca51b9d5bb69965375b76d94b2ccd to your computer and use it in GitHub Desktop.
Save brndnmtthws/e31ca51b9d5bb69965375b76d94b2ccd to your computer and use it in GitHub Desktop.
Randomize MAC on macOS
#!/bin/sh
# run with sudo
# Change this if your interface is not en0 (check with `ifconfig`)
if="en0"
# Will disassociate WiFi
/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -z
ifconfig $if ether `openssl rand -hex 6 | sed 's/\(..\)/:\1/g; s/^.\(.\)[0-3]/\12/; s/^.\(.\)[4-7]/\16/; s/^.\(.\)[89ab]/\1a/; s/^.\(.\)[cdef]/\1e/'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment