A safe, production‑style MAC address manager for Linux
macchanger_pro is a professional, security‑focused Python utility that lets you view, change, randomize, back up, and restore MAC addresses on Linux systems — safely, predictably, and transparently.
This project is built for learning, privacy testing, wireless security labs, and authorized system administration. It follows modern Linux networking practices and avoids fragile or unsafe shortcuts.
┌──(BlackHAT㉿HP-SAGAR)-[/mnt/h/GitHub Clone/MAC-Address_Changer_Script]
└─$ chmod +x macchanger_pro.py
┌──(BlackHAT㉿HP-SAGAR)-[/mnt/h/GitHub Clone/MAC-Address_Changer_Script]
└─$ sudo python3 macchanger_pro.py --list
Interfaces and MACs:
eth0: 00:17:5d:39:2b:3b
┌──(BlackHAT㉿HP-SAGAR)-[/mnt/h/GitHub Clone/MAC-Address_Changer_Script]
└─$ sudo python3 macchanger_pro.py --interface eth0 --show
eth0 current MAC: 00:17:5d:39:2b:3b
┌──(BlackHAT㉿HP-SAGAR)-[/mnt/h/GitHub Clone/MAC-Address_Changer_Script]
└─$ sudo python3 macchanger_pro.py -i eth0 --set aa:bb:cc:dd:ee:ff
Apply MAC aa:bb:cc:dd:ee:ff to interface eth0? [y/N]: y
2026-01-28 13:18:34,425 [INFO] Setting MAC for eth0 -> aa:bb:cc:dd:ee:ff
MAC successfully changed for eth0. New MAC: aa:bb:cc:dd:ee:ff
2026-01-28 13:18:34,444 [INFO] Operation completed.
┌──(BlackHAT㉿HP-SAGAR)-[/mnt/h/GitHub Clone/MAC-Address_Changer_Script]
└─$ sudo python3 macchanger_pro.py --interface eth0 --show
eth0 current MAC: aa:bb:cc:dd:ee:ff
┌──(BlackHAT㉿HP-SAGAR)-[/mnt/h/GitHub Clone/MAC-Address_Changer_Script]
└─$ sudo python3 macchanger_pro.py -i eth0 --random
Apply MAC 8a:12:2e:76:8a:36 to interface eth0? [y/N]: y
2026-01-28 13:19:00,269 [INFO] Setting MAC for eth0 -> 8a:12:2e:76:8a:36
MAC successfully changed for eth0. New MAC: 8a:12:2e:76:8a:36
2026-01-28 13:19:00,289 [INFO] Operation completed.
┌──(BlackHAT㉿HP-SAGAR)-[/mnt/h/GitHub Clone/MAC-Address_Changer_Script]
└─$ sudo python3 macchanger_pro.py --interface eth0 --show
eth0 current MAC: 8a:12:2e:76:8a:36
┌──(BlackHAT㉿HP-SAGAR)-[/mnt/h/GitHub Clone/MAC-Address_Changer_Script]
└─$ sudo python3 macchanger_pro.py -i eth0 --restore
Restore original MAC for eth0? [y/N]: y
2026-01-28 13:19:17,765 [INFO] Restoring MAC for eth0 -> 00:17:5d:39:2b:3b
Restored original MAC for eth0. Current: 00:17:5d:39:2b:3b
┌──(BlackHAT㉿HP-SAGAR)-[/mnt/h/GitHub Clone/MAC-Address_Changer_Script]
└─$ sudo python3 macchanger_pro.py --interface eth0 --show
eth0 current MAC: 00:17:5d:39:2b:3b
┌──(BlackHAT㉿HP-SAGAR)-[/mnt/h/GitHub Clone/MAC-Address_Changer_Script]
└─$ sudo python3 macchanger_pro.py -i eth0 -r -y
2026-01-28 13:19:46,170 [INFO] Setting MAC for eth0 -> 8a:7e:11:78:6c:a4
MAC successfully changed for eth0. New MAC: 8a:7e:11:78:6c:a4
2026-01-28 13:19:46,187 [INFO] Operation completed.
┌──(BlackHAT㉿HP-SAGAR)-[/mnt/h/GitHub Clone/MAC-Address_Changer_Script]
└─$ sudo python3 macchanger_pro.py -i eth0
Selected interface: eth0 (current MAC: 8a:7e:11:78:6c:a4)
Enter new MAC (or 'random' to generate, 'restore' to restore original): --show
2026-01-28 13:21:04,283 [ERROR] Invalid MAC format: --show
┌──(BlackHAT㉿HP-SAGAR)-[/mnt/h/GitHub Clone/MAC-Address_Changer_Script]
└─$ sudo python3 macchanger_pro.py -i eth0
Selected interface: eth0 (current MAC: 8a:7e:11:78:6c:a4)
Enter new MAC (or 'random' to generate, 'restore' to restore original): restore
2026-01-28 13:21:21,594 [INFO] Restoring MAC for eth0 -> 00:17:5d:39:2b:3b
Restored original MAC for eth0. Current: 00:17:5d:39:2b:3b
┌──(BlackHAT㉿HP-SAGAR)-[/mnt/h/GitHub Clone/MAC-Address_Changer_Script]
└─$ cat /var/lib/macchanger/eth0.orig
cat: /var/lib/macchanger/eth0.orig: Permission denied
┌──(BlackHAT㉿HP-SAGAR)-[/mnt/h/GitHub Clone/MAC-Address_Changer_Script]
└─$ sudo cat /var/lib/macchanger/eth0.orig
00:17:5d:39:2b:3b
Many MAC‑changing scripts online are:
- hardcoded to
wlan0 - dependent on deprecated tools only
- unsafe (no backup, no validation)
- unclear about what they actually do
macchanger_pro fixes all of that.
It behaves like a real system utility, not a throwaway script.
- ✅ Dynamic interface detection (no hardcoding)
- ✅ Uses modern
ip(iproute2) commands - ✅ Automatic backup of original MAC addresses
- ✅ Safe restore mechanism
- ✅ Locally‑administered & unicast random MAC generator
- ✅ Strict MAC address validation
- ✅ CLI + interactive fallback
- ✅ Root‑only enforcement
- ✅ Clear logging and error handling
- ✅ Designed for learning & authorized testing
- Inspect MAC addresses of your network interfaces
- Change an interface MAC to a specific value
- Generate and apply a standards‑correct random MAC
- Restore the original factory MAC
- Learn how professional Linux networking tools are built
- Use it safely in cybersecurity labs & coursework
- Linux (tested on Kali/Ubuntu/Debian‑based systems)
- Root privileges (
sudo)
- Python 3.8+
ipcommand (fromiproute2) — typically installed by default
Optional fallback (legacy systems only):
ifconfig
Clone the repository:
git clone https://github.com/SagarBiswas-MultiHAT/MAC-Changer.git
cd macchanger_proMake the script executable (optional but convenient):
chmod +x macchanger_pro.pyThe main script is macchanger_pro.py. You can run it directly with
python3.
sudo python3 macchanger_pro.py --listExample output:
Interfaces and MACs:
wlan0: 00:11:22:33:44:55
eth0: 3c:52:82:aa:bb:cc
sudo python3 macchanger_pro.py --interface eth0 --showsudo python3 macchanger_pro.py -i eth0 --set aa:bb:cc:dd:ee:ff✔ Format is strictly validated ✔ Original MAC is backed up automatically
sudo python3 macchanger_pro.py -i eth0 --randomThe generated MAC is:
- Locally‑administered
- Unicast
- Standards‑compliant
This avoids vendor conflicts and network issues.
sudo python3 macchanger_pro.py -i eth0 --restore✔ Restores the backed‑up hardware MAC ✔ No guessing or hardcoding
sudo python3 macchanger_pro.py -i eth0 -r -yPerfect for:
- scripts
- labs
- CI environments
If you run the tool without --set, --random, or --restore, it will guide you:
sudo python3 macchanger_pro.py -i eth0You’ll be prompted to enter a MAC, type random, or type restore.
Original MAC addresses are saved once, on first change.
Location:
/var/lib/macchanger/<interface>.orig
Example:
/var/lib/macchanger/eth0.orig
Security:
- Owner:
root - File permissions:
600 - Directory permissions:
700
This ensures:
- ✔ Safety
- ✔ Reversibility
- ✔ No accidental overwrites
This tool does not generate unsafe MACs.
It enforces:
- Locally‑Administered Address (LAA) bit set
- Unicast bit set correctly
This is the same standard used by:
- NetworkManager
- Professional pentesting tools
- Privacy‑focused systems
- Network managers (NetworkManager, systemd‑networkd) may override MAC changes
- If the MAC reverts:
- disconnect/reconnect the interface
- or temporarily stop the network manager
- MAC changes are temporary by design
- Persistence across reboots is intentionally not automatic
- Root check: exits if not run with
sudo - Interface detection: reads
/sys/class/net(fallback:ip -o link show) - Backup: saves original MAC on first change
- Change: uses
ip link set(fallback:ifconfigif needed) - Restore: reads the stored backup and re‑applies it
Every step is logged with clear messages so you can see exactly what happened.
This tool is provided for educational and authorized use only.
You must:
- own the device or
- have explicit permission to modify the network interface
Unauthorized MAC spoofing may violate:
- local laws
- network policies
- institutional rules
You are responsible for how you use this tool.
This project demonstrates:
- real Linux networking workflows
- secure system scripting
- defensive programming
- proper CLI tool design
- cybersecurity‑oriented thinking
It is portfolio‑ready and interview‑safe when explained correctly.
- ✅ Stable
- ✅ Actively usable
- ✅ Designed for extension
Possible future enhancements:
- NetworkManager persistence support
- systemd service integration
- Unit tests
- Packaging as a pip module
- macchanger_pro.py — the complete MAC management tool
- README.md — full documentation (this file)
Sagar Biswas Cybersecurity & Computer Science Enthusiast
Built to learn how real security tools should behave — not just how to make them work.
If you understand this README, you understand the entire project.
That’s intentional.
This project is a production-grade MAC address management tool for Linux written in Python.
It allows users to safely view, change, randomize, and restore MAC addresses on any network interface without hardcoding values or relying on deprecated tools.
The script uses modern iproute2 commands, enforces root privileges, validates MAC formats, and automatically backs up the original hardware MAC so changes are fully reversible.
Random MACs are generated correctly as locally-administered unicast addresses, which avoids network conflicts and follows industry standards.
I built this project to learn how real system-level security tools should behave — with safety, clarity, and predictable outcomes — not just how to make something work.