macchanger
Installation
Sección titulada «Installation»Debian/Ubuntu
Sección titulada «Debian/Ubuntu»sudo apt-get update
sudo apt-get install macchanger
Red Hat/CentOS/Fedora
Sección titulada «Red Hat/CentOS/Fedora»sudo yum install macchanger
# or
sudo dnf install macchanger
Arch Linux
Sección titulada «Arch Linux»sudo pacman -S macchanger
brew install macchanger
From Source
Sección titulada «From Source»git clone https://github.com/alobbs/macchanger.git
cd macchanger
./configure
make
sudo make install
Basic Commands
Sección titulada «Basic Commands»| Command | Description |
|---|---|
macchanger -h | Display help message and available options |
macchanger -v | Show version information |
macchanger -s INTERFACE | Show current MAC address of interface |
macchanger -r INTERFACE | Set random MAC address |
macchanger -m INTERFACE | Set random MAC from same vendor |
macchanger -a INTERFACE | Set random vendor MAC address |
macchanger -p INTERFACE | Reset to permanent/original MAC |
Viewing Current MAC Address
Sección titulada «Viewing Current MAC Address»# Show MAC of eth0
macchanger -s eth0
# Show MAC of wlan0
macchanger -s wlan0
# Using ifconfig
ifconfig eth0 | grep HWaddr
# Using ip command
ip link show eth0
Changing MAC to Random Address
Sección titulada «Changing MAC to Random Address»# Generate completely random MAC
sudo macchanger -r eth0
# Show the change was applied
macchanger -s eth0
# Set random MAC on WiFi interface
sudo macchanger -r wlan0
Changing MAC to Specific Address
Sección titulada «Changing MAC to Specific Address»# Set a specific MAC address
sudo macchanger -m AA:BB:CC:DD:EE:FF eth0
# Verify change
macchanger -s eth0
# Another interface example
sudo macchanger -m 00:11:22:33:44:55 wlan0
Vendor-Specific MAC Changes
Sección titulada «Vendor-Specific MAC Changes»# Generate MAC with same vendor as original
sudo macchanger -m eth0
# Generate MAC with random vendor
sudo macchanger -a eth0
# View vendor information
macchanger -s eth0 | grep Vendor
Restoring Original MAC Address
Sección titulada «Restoring Original MAC Address»# Reset to permanent/factory MAC
sudo macchanger -p eth0
# Verify original MAC restored
macchanger -s eth0
# Reset all interfaces
sudo macchanger -p eth0
sudo macchanger -p wlan0
Permanent MAC Changes
Sección titulada «Permanent MAC Changes»Using systemd-networkd
Sección titulada «Using systemd-networkd»Create /etc/systemd/network/99-macchanger.link:
[Match]
MACAddress=OLD:MAC:ADDRESS
[Link]
MACAddress=NEW:MAC:ADDRESS
NamePolicy=kernel database onboard slot path
Using NetworkManager
Sección titulada «Using NetworkManager»# Edit connection
sudo nmtui
# Or manually edit configuration
sudo nano /etc/NetworkManager/conf.d/macchanger.conf
Add to file:
[connection]
cloned-mac-address=AA:BB:CC:DD:EE:FF
Using udev Rules
Sección titulada «Using udev Rules»Create /etc/udev/rules.d/75-macchanger.rules:
ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="aa:bb:cc:dd:ee:ff", RUN+="/usr/bin/macchanger -m wlan0"
Reload rules:
sudo udevadm control --reload-rules
sudo udevadm trigger
Persistent with init Scripts
Sección titulada «Persistent with init Scripts»Create /etc/init.d/macchanger-startup:
#!/bin/bash
### BEGIN INIT INFO
# Provides: macchanger
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
sudo macchanger -r eth0
sudo macchanger -r wlan0
Make executable:
sudo chmod +x /etc/init.d/macchanger-startup
sudo update-rc.d macchanger-startup defaults
Common Use Cases
Sección titulada «Common Use Cases»WiFi Anonymity
Sección titulada «WiFi Anonymity»# Disconnect from WiFi
sudo ip link set wlan0 down
# Change MAC address
sudo macchanger -r wlan0
# Reconnect to network
sudo ip link set wlan0 up
# Verify new MAC
macchanger -s wlan0
Bypassing Captive Portals
Sección titulada «Bypassing Captive Portals»# Some captive portals use MAC filtering
# Change MAC to bypass authentication requirement
sudo macchanger -r wlan0
sudo service network-manager restart
Bypassing MAC Filtering
Sección titulada «Bypassing MAC Filtering»# If network uses MAC whitelist, spoof allowed MAC
sudo macchanger -m AA:BB:CC:DD:EE:FF eth0
# Test connectivity
ping -c 1 8.8.8.8
Network Testing and Simulation
Sección titulada «Network Testing and Simulation»# Test multiple MAC addresses simultaneously
for i in {1..5}; do
sudo macchanger -r eth0
echo "MAC $i: $(macchanger -s eth0 | grep HWaddr)"
sleep 2
done
Avoiding Network Tracking
Sección titulada «Avoiding Network Tracking»# Change MAC before connecting to untrusted networks
sudo macchanger -r wlan0
# Connect to network
nmcli device wifi connect "SSID" password "PASSWORD"
# Verify anonymity
macchanger -s wlan0
Scripting Automation
Sección titulada «Scripting Automation»Automatic MAC Change on Startup
Sección titulada «Automatic MAC Change on Startup»Create ~/.local/bin/auto-macchanger.sh:
#!/bin/bash
# Auto-change MAC for both wired and wireless interfaces
INTERFACES=("eth0" "wlan0" "enp0s3" "wlp2s0")
for interface in "${INTERFACES[@]}"; do
if ip link show "$interface" &>/dev/null; then
echo "[*] Changing MAC on $interface..."
sudo macchanger -r "$interface"
sleep 1
fi
done
echo "[+] All interfaces updated"
Make executable and run at startup:
chmod +x ~/.local/bin/auto-macchanger.sh
# Add to crontab or systemd service
Periodic MAC Rotation
Sección titulada «Periodic MAC Rotation»Create a cron job for periodic MAC changes:
# Edit crontab
crontab -e
# Add entry (change MAC every hour)
0 * * * * /usr/bin/sudo /usr/bin/macchanger -r eth0 >/dev/null 2>&1
Interface-Specific Script
Sección titulada «Interface-Specific Script»#!/bin/bash
# macchange.sh - Smart MAC changer
INTERFACE="${1:-eth0}"
ACTION="${2:-random}"
case "$ACTION" in
random)
echo "[*] Setting random MAC on $INTERFACE"
sudo macchanger -r "$INTERFACE"
;;
vendor)
echo "[*] Setting vendor MAC on $INTERFACE"
sudo macchanger -m "$INTERFACE"
;;
restore)
echo "[*] Restoring original MAC on $INTERFACE"
sudo macchanger -p "$INTERFACE"
;;
*)
echo "Usage: $0 <interface> [random|vendor|restore]"
exit 1
;;
esac
# Verify change
echo "[+] Current MAC:"
macchanger -s "$INTERFACE"
Batch Interface Changing
Sección titulada «Batch Interface Changing»#!/bin/bash
# Change MAC on multiple interfaces
for iface in $(ip link show | grep -oP '^\d+: \K[^:]+'); do
if [[ "$iface" != "lo" ]]; then
echo "[*] Changing $iface"
sudo macchanger -r "$iface" 2>/dev/null
fi
done
Checking MAC Address Information
Sección titulada «Checking MAC Address Information»# View current and permanent MAC
macchanger -s eth0
# Show vendor information
macchanger -s eth0 | grep Vendor
# List all network interfaces
ip link show
# View MAC in detailed format
cat /sys/class/net/eth0/address
Tips and Best Practices
Sección titulada «Tips and Best Practices»| Tip | Description |
|---|---|
| Run as root | macchanger requires sudo/root privileges for actual changes |
| Disable IPv6 | Some systems leak IPv6 addresses; disable or use privacy extensions |
| Use consistent vendor | Using -m maintains vendor consistency for less obvious spoofing |
| Test connectivity | Always verify network access after changing MAC |
| Reset before troubleshooting | If network issues arise, reset to original MAC with -p |
| Document original MAC | Save original MAC before changes: macchanger -s eth0 > mac_backup.txt |
| Automate responsibly | Use cron jobs cautiously on shared systems |
| Network logging | Be aware that network admins may log MAC changes |
Troubleshooting
Sección titulada «Troubleshooting»Permission Denied
Sección titulada «Permission Denied»# macchanger requires root
sudo macchanger -r eth0
# Or add user to network group (less secure)
sudo usermod -aG netdev $USER
Interface Not Found
Sección titulada «Interface Not Found»# List available interfaces
ip link show
# Common interface names
# eth0, eth1 - wired
# wlan0, wlan1, wlp2s0 - wireless
# lo - loopback (don't change!)
MAC Change Not Persisting
Sección titulada «MAC Change Not Persisting»# Check if interface is being reset by network manager
sudo systemctl restart networking
# Or use NetworkManager commands
sudo nmcli connection reload
sudo nmcli connection up <connection-name>
Cannot Change on Active Interface
Sección titulada «Cannot Change on Active Interface»# Bring interface down first
sudo ip link set eth0 down
# Change MAC
sudo macchanger -r eth0
# Bring interface up
sudo ip link set eth0 up
Related Tools
Sección titulada «Related Tools»| Tool | Purpose |
|---|---|
ifconfig | View/configure network interfaces |
ip link | Modern interface configuration |
nmcli | NetworkManager command-line tool |
iproute2 | Advanced network routing |
ethtool | Ethernet device settings |
aircrack-ng | WiFi security testing suite |