Posts: 1
Joined: Sat Jan 14, 2017 8:02 pm

Changing MAC address on a Pi3

Sat Jan 14, 2017 8:20 pm

Hey guys!

Newcomer to the forums, but not to RasPi boards. However, this case is driving me nuts now for the nth day in a row...

It happens that I'm renting a room, and not a complete apartment. For a single guy in his early 20's, it's a great, and cheap solution. It also happens that my landlord is a paranoid freak who thinks everyone will start uploading child porn from his home network, if he does not enable the hidden SSID and MAC whitelist on the router... And he actively refuses to add new devices that are not "vital" - because, yes, you guessed right, the longer the MAC whitelist, the less responsive the whole system is. Unfortunately it is well detailed in the contract, and such, I can't do much against it (lately here in Budapest apartment prices went sky high, and even with a quite good salary, you can't really afford a place alone).

However there's one device on the filter that I don't use much (or at all). I haven't told him to remove it, as I could use this MAC for other devices, by spoofing it. No harm done, just getting my stuff done.

First I tried with my RasPi2 with an external Tenda 150Mb USB dongle (W331M), but it actively refused to change MAC. ifconfig would show that the MAC changed, but wpa_supplicant did not pick it up, and used the hardware MAC address. Spent two days researching, to no avail.

Decided to grab a RasPi3 (already wanted one as it would be a media player for my Plex server), and tried with that. No luck, wpa_cli still uses the damn hardware MAC address, no matter what I try ( one of the methods I tried is this viewtopic.php?f=29&t=139942, but also tried macchanger, manually changing MAC address while wlan0 is down, and so on). Unfortunately using cable is not an option.

How could I make this damn MAC address permanent?

Posts: 7851
Joined: Thu May 05, 2016 9:33 am
Location: France

Re: Changing MAC address on a Pi3

Sun Jan 15, 2017 2:35 pm

I don't have the solution offhand for the MAC address thing (perhaps as a config.txt option?) but what I would do in your case is create a network of my own, and NAT all traffic to a single, whitelisted, device.

The raspberry will do as a router, but you could also go for a second hand or cheap router (microtik ?). Any "true" router knows how to spoof its MAC address.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
Posts: 42176
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: Changing MAC address on a Pi3

Sun Jan 15, 2017 2:44 pm

You can muck about with the ethernet interface with
sudo ifconfig eth0 down
sudo ifconfig eth0 hw aa:bb:cc:dd:ee:ff # set new MAC address
sudo ifconfig eth0 up

The same might work for a WiFi dongle if the driver supports it.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

Posts: 7851
Joined: Thu May 05, 2016 9:33 am
Location: France

Re: Changing MAC address on a Pi3

Sun Jan 15, 2017 3:23 pm

FYI, I have an Edimax Nano USB adapter (150mbps), this one accepts spoofing its MAC

Code: Select all

root@berck:~# modprobe -r 8192cu ; modprobe 8192cu rtw_initmac=00:11:22:33:44:55
root@berck:~# ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr 00:11:22:33:44:55  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@berck:~# lsusb | grep -i wireless
Bus 001 Device 004: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
root@berck:~# uname -a
Linux berck 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Posts: 798
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Changing MAC address on a Pi3

Sun Jan 15, 2017 3:54 pm

Have a look at this page.
I have also had problems using both 'ifconfig' and 'macchanger' to change a MAC address in Raspbian Jessie with PIXEL running on my Dell laptop. Even running as root and taking the WiFi and ethernet networks down, I still have permission problems with these commands.

Scroll down the page I referenced. I use 'Automatically - Method 1 - systemd-networkd' to change the MAC address on my laptop so my router would give it a different IP address depending on whether I booted it in Windows or PIXEL.

Hope this helps,

Posts: 9
Joined: Sat Jun 09, 2012 2:54 pm

Re: Changing MAC address on a Pi3

Wed Jan 03, 2018 11:16 pm

I'm seeing duplicate MACs on 3 different Pi3s on the eth0 interface. I haven't tried the wlan0 yet.


When running Fedora:

You can set MACADDR in /etc/sysconfig/network-scripts/ifcfg-<IFACE>

For eth0:

$ cat /etc/sysconfig/network-scripts/ifcfg-eth0


$ ip link show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEF0
link/ether 0a:00:c0:a8:01:0e brd ff:ff:ff:ff:ff:ff

Return to “Troubleshooting”