I bought the Miniature WiFi Module from ADAFruit (http://www.adafruit.com/products/814) and was wondering if it is possible to change the MAC address associated with it. I have tried using the following code:

sudo ifdown wlan0

sudo ifconfig wlan0 hw ether 00:11:22:33:44:55

sudo ifup wlan0


sudo ifdown wlan0

sudo macchanger -r wlan0

sudo ifup wlan0

or by adding a line in /etc/network/interfaces

hwaddress ether 00:11:22:33:44:55

When using lsusb the device shows up as "Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter". In /etc/hostapd/hostapd.conf, driver=rtl1871xdrv. I am running ISC DHCP Server.

The device works otherwise. I just want to be able to change the MAC address

  • This question has absolutely nothing to do with Raspberry Pi, please, choose another section of StackExchange for this type of inquiry.
    – lenik
    Oct 20, 2013 at 10:39
  • 2
    ah, sorry. Was using Raspbian so looked like a good place to put it. I will find another location.
    – Joseph
    Oct 20, 2013 at 16:31
  • Some drivers require the device to be up to do that. Try sudo ifconfig wlan0 up ; sudo macchanger -r wlan0
    – M Noit
    Oct 21, 2013 at 11:19
  • Unfortunately this doesn't work either. It has the error "Can't read permanent MAC: Operation not supported. Even though there is output for the NEW MAC, ifconfig shows the old MAC address.
    – Joseph
    Oct 22, 2013 at 2:17

5 Answers 5


For "Raspbian GNU/Linux 8 (jessie)" (cat /etc/os-release), "Raspberry Pi reference 2017-06-21" (cat /etc/rpi-issue) (maybe also 2017-07-05) (thanks @Heinrich Ulbricht) and earlier see my answer here.

For "Raspbian GNU/Linux 9 (stretch)" (cat /etc/os-release), "Raspberry Pi reference 2017-08-16" (cat /etc/rpi-issue) (maybe also 2017-07-05) and later things changed. For example eth0 is now listed by systemd’s predictable network interface name enxb827ebxxxxxx. So my previous method via if-pre-up.d stopped working.

Instead you can use systemd and create the file /etc/systemd/network/00-mac.link as explained here:


NamePolicy=kernel database onboard slot path
  • 2
    Confirmed working with Raspian Stretch Lite. Kudos, Frank.
    – vhs
    Jun 2, 2018 at 19:58
  • 1
    Confirming, too, that it works with Raspbian GNU/Linux 9.
    – typo
    Oct 21, 2018 at 12:52
  • 1
    I just did the second one on Buster and it worked. Cheap Chinese Ethernet adapters came with the same MAC address. ~$1.20 for 3x USB and Ethernet though, can't complain too much. Nov 24, 2019 at 19:57

I had the same issue - most of the standard ways of doing this didnt seem to work on the raspberry.

My situation was a bit different - I have a Raspberry PI B where the ethernet chip has died and so I used a usb-ethernet adpater. The adapter is maybe not the highest quality as it didnt have a unique MAC address. The adapter is assigned to eth1

I found the answer by enzorik here... http://www.raspberrypi.org/forums/viewtopic.php?f=6&t=5486, worked for me. Essentially...

Create a new script: sudo nano /etc/init.d/mac.sh

Paste into this script (settign your MAC address as required) ...

#! /bin/sh
ifconfig eth1 down hw ether 00:00:00:00:00:00
ifconfig eth1 up 

Make it executable: sudo chmod +x /etc/init.d/mac.sh

Then run: sudo update-rc.d /etc/init.d/mac.sh defaults

  • I would suggest to rather save mac.sh in /etc/network/if-pre-up.d/. This will avoid the usage of update-rc.d. See my answer below. Mar 18, 2017 at 1:32
  • I ran into this same issue. I'm gonna try this. But the forum link you refer to is no longer good. Nov 24, 2019 at 19:45

For "Raspbian GNU/Linux 9 (stretch)" (cat /etc/os-release), "Raspberry Pi reference 2017-08-16" (cat /etc/rpi-issue) (maybe also 2017-07-05) and later see my answer here.

For "Raspbian GNU/Linux 8 (jessie)" (cat /etc/os-release), "Raspberry Pi reference 2017-06-21" (cat /etc/rpi-issue) (thanks @Heinrich Ulbricht) (maybe also 2017-07-05) and earlier

you can add the following script to /etc/network/if-pre-up.d/mac:


if [ "$IFACE" = wlan0 ]; then
    ip link set dev "$IFACE" address b8:27:eb:xx:xx:xx

and make it executable with

chmod +x /etc/network/if-pre-up.d/mac

This should work with systemd and be more robust than the older update-rc.d method.

  • 1
    Tested successfully with "Raspbian GNU/Linux 8 (jessie)" (cat /etc/os-release), "Raspberry Pi reference 2017-06-21" (cat /etc/rpi-issue). (I'm documenting this to narrow down the release frame it works for since your second answer suggests it stops working at some point.) Nov 20, 2017 at 14:45
  • 1
    Note this method will not work on Raspian Stretch. Thankfully Frank added a second answer and both are still technically correct.
    – vhs
    Jun 2, 2018 at 19:51
  • I just did the linked answer on Buster and it worked. Cheap Chinese Ethernet adapters came with the same MAC address. ~$1.20 for 3x USB and Ethernet though, can't complain too much. Nov 24, 2019 at 19:56

it is possible to change your mac address but this is a feature of the hardware and drivers.

i was successful using two wifi adapters TL-WN722N and the Alfa AWUS036H

however you should be aware that the Alfa AWUS036H has to be powered through a powered usb hub. if you try and run it directly off the pi you will get kernel panics.

service ifplugd stop

service wicd stop

ifconfig wlan0 down

macchanger -r wlan0 

ifconfig wlan0 up

good luck


For the 8192cu driver you could do this by creating the file /etc/modprobe.d/8192cu.conf (the filename does not matter but it should have .conf extension) and adding a line that looks like:

options 8192cu rtw_initmac="XX:XX:XX:XX:XX:XX"

where "XX:XX:XX:XX:XX:XX" is the static MAC address

  • 1
    I have this exact same Model RTL8188CUS and this is the only solution that worked. Thank you!
    – Rucent88
    Oct 23, 2016 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.