Change your MAC address to have free WiFi

English version of this post here (EN)
Spanish version of this post here (ES)
French version of this post here (FR)

Quick Guide: Randomizing Your MAC Address on macOS

Every network interface in your computer has a unique identifier called a MAC (Media Access Control) address. Sometimes you might want to change this address for privacy reasons or to troubleshoot network issues. Here’s how to do it quickly on macOS.

The One-Liner Solution

I created this simple function that you can add to your .zshrc or .bashrc file:

change_mac () {
  sudo ifconfig en0 down
  sleep 1
  sudo ifconfig en0 up

  new_mac="18:3e:ef:$(openssl rand -hex 3 | sed 's/\(..\)/\1:/g; s/.$//')"
  sudo ifconfig en0 ether $new_mac
}

How It Works

  1. Takes your primary network interface (en0) offline
  2. Waits a second for the change to register
  3. Brings the interface back online
  4. Generates a random MAC address with a fixed prefix
  5. Assigns the new MAC address to your interface

Why This Matters

Changing your MAC address can help:

  • Bypass MAC filtering on networks
  • Increase privacy by making your device harder to track
  • Reset connection to networks that limit connection time

Remember that your MAC address will revert to its original value after a reboot, so you’ll need to run this command again if you want to keep using a randomized address.

Extending Public WiFi Time Limits

When you’re on a public WiFi network (like at cafes, airports, or hotels), you might be limited to a specific time period—often 2 hours. These networks typically identify your device by its MAC address.

By changing your MAC address after your time expires, you can essentially “reset the clock” and get an additional 2 hours of connectivity. Just run the change_mac function, reconnect to the network, and you’ll appear as a new device to the hotspot system.

Important Note

This script requires administrator privileges (sudo). Always be careful when running commands with sudo!