Generate Random MAC Addresses (Terminal One-Liner)

Sometimes you just need valid-looking MAC addresses for documentation, test data, configs, or mock environments β€” not for changing real hardware addresses or spoofing interfaces.

This method is platform-agnostic and works on macOS, FreeBSD, Linux, and most Unix-like systems with OpenSSL installed.


Generate with a one-liner in terminal

You can generate a properly formatted 48-bit MAC address using standard shell tools:

# Generate a random MAC address (locally-administered, unicast)
openssl rand -hex 6 | sed 's/$begin:math:text$\.\.$end:math:text$/\1:/g; s/.$//'