Given the increased prevalence of systems which track people's movements by their Mac addresses I'd like to obscure mine.

I have a rooted galaxy note 2 with busybox installed. I can change my MAC address like so:

busybox ifconfig wlan0 hw ether 11:22:33:44:55:66

however, if I disable and re-enable my wireless, or I reboot my phone, it gets forgotten. is there somewhere I can put a script so it will be run every time my wireless turns on?


6 Answers 6


How about Chainfire's tool Pry-Fi which was announced over at XDA?
It works great and it is available via the official Google play-store at:

Here’s a screenshot showing the tool in action…

screenshot of Chainfire's tool Pry-Fi

  • I tried Pry-Fi. Despite my phone being listed as tested, it caused wi-fi to become entirely unusable. I couldn't even see any networks to connect to. I had to uninstall to get access to my home network again.
    – mc0e
    Aug 15, 2016 at 11:49

You could do that using e.g. Tasker, the mighty automation tool:

  • Condition: Monitor Start (i.e., Tasker was started; alternatively: Device Boot, i.e. boot process finished)
  • Task: Run Shell, with your command as parameter

If you like it more fancy, you could even use Variable Randomize to generate a different MAC each time...

  • Would this trigger as part of the process of going online or shortly afterward? If possible I'd like to not broadcast the hardware's MAC at all.
    – mc0e
    Dec 9, 2013 at 15:13
  • This would trigger where you defined it, as described: Monitor start is when Tasker gets activated, which is usually immediately after boot (or when you start/restart Tasker, or activate its Monitoring service manually). If you use Device Boot as condition, it would only get "triggered" after boot, but not when you start/restart the Tasker monitor manually. So in both cases, it would be applied immediately after boot. I cannot say whether network initialization might be faster.
    – Izzy
    Dec 9, 2013 at 15:45
  • The activation would have to track when wi-fi is turned on, and change the MAC before any packets are broadcast. I'm not all that confident that that could be relied on, but perhaps I'm wrong.
    – mc0e
    Aug 15, 2016 at 11:53
  • @mc0e If you have doubts on that, add a second profile with a different condition (something that triggers on network changes), and apply the same task to it :)
    – Izzy
    Aug 15, 2016 at 13:22

In addition to the other answer with Tasker ("You could do that using e.g. Tasker, the mighty automation tool:"), here a little Task (description export) with randomizing the MAC:

TestMacChanger (130)
    A1: Variable Set [ Name:%count To:0 Do Maths:On Append:Off ] 
    A2: Variable Randomize [ Name:%random Min:0 Max:15 ] 
    A3: Variable Convert [ Name:%random Function:Decimal to Hex Store Result In:%rhex ] 
    A4: Test Variable [ Type:Length Data:%rhex Store Result In:%len ] 
    A5: Variable Set [ Name:%rhex To:0%rhex Do Maths:Off Append:Off ] If [ %len eq 1 ]
    A6: Variable Convert [ Name:%rhex Function:To Upper Case Store Result In: ] 
    A7: Variable Set [ Name:%mac To:%mac:%rhex Do Maths:Off Append:Off ] If [ %mac Set ]
    A8: Variable Set [ Name:%mac To:%rhex Do Maths:Off Append:Off ] If [ %mac !Set ]
    A9: Variable Add [ Name:%count Value:1 Wrap Around:0 ] 
    A10: Goto [ Type:Action Label Number:1 Label:randomstart ] If [ %count < 6 ]
    A11: Variable Set [ Name:%mac To:00:11:22:33:44:55 Do Maths:Off Append:Off ] If [ %mac !Set ]
    A12: Flash [ Text:%mac Long:On ] 
    A13: Run Shell [ Command:su
busybox ifconfig wlan0 hw ether %mac Timeout (Seconds):0 Use Root:On Store Output In:%output Store Errors In:%error Store Result In: Continue Task After Error:On ] 
    A14: Flash [ Text:%error Long:Off ] If [ %error Set ]

This is doing a loop for 6 random hex values to get a random mac as e.g. 01:4F:89:BA:3F:0C Then it is setting this random mac as own mac.

I can see the new mac with this command:

busybox iplink show wlan0

After a reboot the old mac is reset.


Use Chainfire's app called Pry-Wifi which does exactly that.


As things move forward, I've got a new phone (a Pixel 5a), which has such a built in option, but that's for Developers.

First I had to enable the developer feature (see here for original):

  • Open Settings » About Phone
  • Click on Build Number 7 times

Next, I went to the Developer feature (you can use the search feature if you have a slightly different phone):

  • Open Settings » System » Advanced » Developer options
  • Scroll down to "Wi-Fi-enhanced MAC randomization" and Enable

As you probably know, the default is to generate a random MAC address once per network, address that gets saved once and for all unless you change the above flag. So with the default, if you use different WiFi networks, it at least will use a different MAC for each connection point.


I feel like this could be done with a bash script or editing the init file to include the command you have here.

  • 1
    This isn't helpful; what would OP put in the script? Where would it go?
    – Peanut
    Dec 8, 2013 at 22:22
  • 1
    This is really a repeat of stuff I've put forward in the original question. I have no problem writing a script, but I don't know where it would need to go in order to be triggered each time my phone goes online.
    – mc0e
    Dec 9, 2013 at 15:12
  • In addition, that would require modifying the boot image; init scripts are part of that. Any modifications of init files in the "mounted file system" will be lost after boot (see e.g. initrd @ Wikipedia for details).
    – Izzy
    Dec 9, 2013 at 15:49
  • If I get a way to set the MAC address that survives the NIC going up and down, that's a step forward, even if I have to modify the script after each phone reboot. Especially so if it means the MAC address gets set before any packets get broadcast each time the wifi link goes up.
    – mc0e
    Dec 12, 2013 at 8:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .