Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Fix 020000 MAC Address on Android Custom ROMs

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

If your Android device shows a MAC address of 02:00:00:00:00:00 after installing a custom ROM, it means the Wi-Fi or Bluetooth interface failed to load its real hardware address. This usually happens because the ROM's kernel or vendor blob is missing the proper MAC address configuration for your device. The fix involves restoring the correct MAC address using a root terminal command or a small script, and it works on most custom ROMs (LineageOS, crDroid, etc.) as long as you have root access. Below is a step-by-step guide to fix it.

What You'll Need

  • Root access on your device (Magisk or SuperSU installed).
  • A file manager with root access (e.g., Mixplorer, Solid Explorer) or a terminal emulator app (e.g., Termux).
  • Your device's original MAC address. You can find it printed on the box, on a label under the battery (if removable), or in the router's DHCP client list from before the issue. If you don't have it, you can generate a valid one (see Tips).
  • USB debugging enabled (optional, for adb commands if you prefer using a computer).

Step-by-Step

  1. Back up your current MAC address (optional but recommended). Open a terminal or adb shell and run ip link show wlan0 (or ifconfig wlan0 on older ROMs) to see the current MAC. Write it down. This helps if you need to revert.
  2. Create a script to set the MAC address. Using a root file manager, navigate to /data/local/tmp and create a new file named fix_mac.sh. Open it in a text editor and paste the following, replacing XX:XX:XX:XX:XX:XX with your actual MAC address:
    #!/system/bin/sh
    ip link set wlan0 down
    ip link set wlan0 address XX:XX:XX:XX:XX:XX
    ip link set wlan0 up
    If your device uses a different interface name (like wlan1 or eth0), adjust the commands accordingly. You can find the correct name by running ip link and looking for the wireless interface.
  3. Make the script executable. In the file manager, long-press the file, select Properties, and set permissions to 755 (owner read/write/execute, group/others read/execute). Alternatively, in a terminal run: chmod 755 /data/local/tmp/fix_mac.sh.
  4. Run the script as root. Open a terminal (or adb shell) and type:
    su
    sh /data/local/tmp/fix_mac.sh
    This will bring the Wi-Fi interface down, change its MAC address, and bring it back up. You should see no error messages.
  5. Verify the MAC address. Run ip link show wlan0 again. The link/ether line should now show your correct MAC address instead of 02:00:00:00:00:00.
  6. Make the fix persist across reboots. The script only works until the next reboot. To make it permanent, you need to run it at boot. The easiest way is to use a Magisk module or an init.d script. If your ROM supports init.d, copy the script to /system/etc/init.d/ and set permissions to 755. If not, use Magisk's post-fs-data.sh or service.sh in a custom module. A simpler alternative: use an app like Mac Address Changer (from the Play Store) that can set the MAC on boot, but note that many such apps are outdated. The most reliable method is to create a Magisk module: create a folder structure module/system/etc/init.d, place the script there, zip it, and flash via Magisk Manager. Detailed module creation is beyond this guide, but search for "Magisk module init.d" for a template.
  7. Reboot and check. After setting up the boot script, reboot your device. After boot, open a terminal and run ip link show wlan0 to confirm the MAC is correct. If it still shows 02:00:00:00:00:00, the boot script didn't run—check its permissions and path.

Common Mistakes

  • Using the wrong interface name. Not all devices use wlan0. Some use wlan1 or eth0. Check with ip link first.
  • Not running the script as root. Without su, the ip command will fail with permission denied.
  • Setting the MAC to an invalid address. The MAC must be a 48-bit hexadecimal number with colons, and the first octet must be even (unicast). Avoid all-zero or all-ff addresses.
  • Forgetting to make the script executable. If the script is not executable, the system will not run it at boot.
  • Using a script with Windows line endings. If you edit the script on a Windows PC, it may contain \r\n which causes errors. Use a Unix-compatible editor or run dos2unix on the file.

Tips

  • If you don't have the original MAC, generate a valid one. Use a MAC that starts with a vendor prefix that matches your device's chipset (e.g., for Qualcomm, use 00:0A:F5 or 00:1E:B1). You can also use a random locally administered address by setting the second least significant bit of the first octet to 1 (e.g., 02:xx:xx:xx:xx:xx is valid but that's the problem address—use 06:xx:xx:xx:xx:xx instead).
  • Use a terminal app instead of a file manager. If you're comfortable with the command line, you can skip creating a script and just run the commands directly each time, but that's tedious. The script is better.
  • Check if your ROM has a built-in MAC fix. Some custom ROMs (like LineageOS) have a setting under Developer options called "Use random MAC address" or similar. If that's enabled, disable it first. Also, some devices have a persist partition that stores the MAC; a ROM might fail to read it. In that case, the fix might be to reflash the stock firmware's persist partition.
  • Consider using a Magisk module. There are pre-made Magisk modules that fix MAC addresses for specific devices. Search XDA-Developers for your device model. This is often cleaner than a manual script.

Troubleshooting

If the MAC still shows 02:00:00:00:00:00 after running the script: First, check if the script ran without errors. Run sh /data/local/tmp/fix_mac.sh and look for messages. If you get "ip: RTNETLINK answers: Operation not permitted", you are not root or SELinux is blocking. Try setenforce 0 temporarily (if you have root) to see if SELinux is the issue. If it works with SELinux permissive, you need to adjust your script to run in the correct SELinux context—this is advanced; consider using a Magisk module that handles it.

If the MAC changes but Wi-Fi doesn't connect: Some routers or networks have MAC filtering. Make sure the new MAC is allowed. Also, after changing the MAC, forget the Wi-Fi network and reconnect.

If the script doesn't run at boot: Check if your ROM actually supports init.d. Many custom ROMs do not include an init.d runner. Use a Magisk module or a boot script app like Boot Manager (root) to run the script. Also, ensure the script has #!/system/bin/sh as the first line and is executable.

If you accidentally set an invalid MAC and lose Wi-Fi: Reboot the device to reset the MAC to the default (which may be 02:00:00:00:00:00 again). Then edit the script with a correct MAC and rerun.

Frequently Asked Questions

Why does my MAC become 02:00:00:00:00:00 after flashing a custom ROM?

This usually means the ROM's kernel or vendor blobs are not reading the MAC address stored in the device's NVRAM or persist partition. It's a common bug on devices where the MAC is not hardcoded in the SoC but stored in a separate partition.

Is it safe to change my MAC address?

Yes, changing the MAC address on your own device is safe and legal in most places, as long as you're not doing it to impersonate another device or bypass security restrictions. Note that some networks may have MAC filtering, so changing it could temporarily disconnect you.

Will this fix work on all Android devices?

The method works on any device with root access and a Linux kernel that supports the ip command. However, some devices have additional layers (like a hardware MAC that is re-set by the driver) that may override your changes. In those cases, you may need a device-specific fix.

Do I need to re-flash the ROM to fix the MAC?

No, the script method is enough. Re-flashing the same ROM likely won't help because the bug is in the ROM itself. If you want a permanent fix, consider trying a different ROM or a Magisk module.

What if I don't have root access?

Without root, you cannot change the MAC address because the ip command requires root privileges. You would need to root your device, which is beyond the scope of this guide.

Can I use a random MAC address instead of the original?

Yes, you can use any valid MAC address. However, some apps or services may expect a consistent MAC for features like Wi-Fi calling or device authentication. It's best to use the original if you have it.