Skip to content

Instantly share code, notes, and snippets.

@DougBarry
Created August 31, 2022 17:21
Show Gist options
  • Save DougBarry/34a757cffaccd6c166b5d74e6c767962 to your computer and use it in GitHub Desktop.
Save DougBarry/34a757cffaccd6c166b5d74e6c767962 to your computer and use it in GitHub Desktop.
OpenWRT randomise access point MAC addresses
#!/bin/sh
get_random_mac () {
echo $(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\
}
for networkid in $(uci show wireless | grep wifinet | cut -d "." -f2 | uniq | grep -v -E wifi-iface)
do
uci set wireless.${networkid}.macaddr=$(get_random_mac)
done
wifi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment