fooness
Posts: 44
Joined: Fri Aug 09, 2013 1:22 pm

Raspberry Pi 3 wlan0 MAC-address change in /boot/cmdline.txt

Sun Mar 13, 2016 12:59 pm

Hello folks,

is there a way to change wlan0’s MAC-address, like it is possible with eth0, in /boot/cmdline.txt via e.g. "brcmfmac_sdio.macaddr=B8:27:EB:AB:CD:EF"?

Thank you in advance!

User avatar
DougieLawson
Posts: 36560
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Raspberry Pi 3 wlan0 MAC-address change in /boot/cmdline

Sun Mar 13, 2016 2:31 pm

I tried using sudo ifconfig wlan0 hw ether aa:bb:cc:dd:ee:ff and that failed with

Code: Select all

[ 6846.526297] brcmfmac: _brcmf_set_mac_address: Setting cur_etheraddr failed, -52
the device driver may not support having locally administered MAC addresses.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

fooness
Posts: 44
Joined: Fri Aug 09, 2013 1:22 pm

Re: Raspberry Pi 3 wlan0 MAC-address change in /boot/cmdline

Sun Mar 13, 2016 3:21 pm

Thank you for testing this. Pity, I hoped it would work like with the onboard ethernet device.

Severian
Posts: 49
Joined: Wed Jul 10, 2013 6:22 am

Re: Raspberry Pi 3 wlan0 MAC-address change in /boot/cmdline

Mon Mar 14, 2016 7:26 am

Howdy,
I don't have a PI 3, but I have done something similar for other wireless nics. I added a script to /etc/network/if-up.d to change the MAC. If the built in wireless does not support changing MAC addresses, then that is another reason not to use it. I won't use it because of the proprietary firmware blob it needs. I don't expect everyone to care about software freedom, but I hope people are not offended by those who do care.
Good luck,
Ralph

fooness
Posts: 44
Joined: Fri Aug 09, 2013 1:22 pm

Re: Raspberry Pi 3 wlan0 MAC-address change in /boot/cmdline

Mon Mar 14, 2016 9:41 am

Hey again,

so it seems, I can change the MAC address via the command given in the post above:

Code: Select all

sudo ifconfig wlan0 hw ether aa:bb:cc:dd:ee:ff
Though, I did not yet find a way to change it via cmdline.txt …

How could it be done with a script?

Thank you!

User avatar
RaTTuS
Posts: 10500
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Raspberry Pi 3 wlan0 MAC-address change in /boot/cmdline

Mon Mar 14, 2016 9:50 am

Severian wrote:Howdy,
I don't have a PI 3, but I have done something similar for other wireless nics. I added a script to /etc/network/if-up.d to change the MAC. If the built in wireless does not support changing MAC addresses, then that is another reason not to use it. I won't use it because of the proprietary firmware blob it needs. I don't expect everyone to care about software freedom, but I hope people are not offended by those who do care.
Good luck,
Ralph
well you wont be using any part of the RPi then ....
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

Severian
Posts: 49
Joined: Wed Jul 10, 2013 6:22 am

Re: Raspberry Pi 3 wlan0 MAC-address change in /boot/cmdline

Mon Mar 14, 2016 7:41 pm

Howdy,
There is more than one way to setup the script. The easiest is to install the macchanger program using apt-get. It will ask you if you want to run it upon boot. It will add a script to /etc/network/if-pre-up.d/ for you, if you say yes.

I usually put a file in /etc/network/if-up.d. Call it what you want, but don't put an extension on the name. So, use newmac, instead of the more normal newmac.sh. Put something like what I have between the dashed lines in it.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#!/bin/sh

if [ "$IFACE" = wlan0 ]; then
ip link set dev "$IFACE" address 44:ab:41:33:b4:65
fi

if [ "$IFACE" = wlan2 ]; then
ip link set dev "$IFACE" address 44:ab:41:33:b4:66
fi
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


To RaTTuS:
I use all parts of the RPi. When I get a Pi 3, I probably will delete the wifi blob for the built in wifi and continue to use nice open atheros wifi nics. That risk is easy to mitigate, so why not do it? The closed nature of the GPU firmware is the worst thing about the RPi, and it does keep me from using the RPi in some projects. On other projects, I just complain and use it.
Good day,
Ralph

fooness
Posts: 44
Joined: Fri Aug 09, 2013 1:22 pm

Re: Raspberry Pi 3 wlan0 MAC-address change in /boot/cmdline

Tue Mar 15, 2016 3:03 pm

May I please ask, what’s the difference between 'ifconfig wlan0 hw ether aa:bb:cc:dd:ee:ff' and 'ip link set dev wlan0 address aa:bb:cc:dd:ee:ff'?

Thank you!

User avatar
RaTTuS
Posts: 10500
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Raspberry Pi 3 wlan0 MAC-address change in /boot/cmdline

Tue Mar 15, 2016 3:05 pm

Severian wrote:....
I use all parts of the RPi. When I get a Pi 3, I probably will delete the wifi blob for the built in wifi and continue to use nice open atheros wifi nics. That risk is easy to mitigate, so why not do it? The closed nature of the GPU firmware is the worst thing about the RPi, and it does keep me from using the RPi in some projects. On other projects, I just complain and use it.
Good day,
Ralph
but you still use the bootcode.bin which boots the RPi - that is still closed , without it you don't have a working Pi
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

Severian
Posts: 49
Joined: Wed Jul 10, 2013 6:22 am

Re: Raspberry Pi 3 wlan0 MAC-address change in /boot/cmdline

Wed Mar 16, 2016 4:07 am

fooness wrote:May I please ask, what’s the difference between 'ifconfig wlan0 hw ether aa:bb:cc:dd:ee:ff' and 'ip link set dev wlan0 address aa:bb:cc:dd:ee:ff'?
Yes, go ahead and ask. ;-)



Basically, ifconfig is the old way of doing it. That command is depracated, but still working for now. ip and its subcommands is the newer way and I am trying to get used to using that command, since it is supposed to be the "proper" way to do it.

Have fun,

fooness
Posts: 44
Joined: Fri Aug 09, 2013 1:22 pm

Re: Raspberry Pi 3 wlan0 MAC-address change in /boot/cmdline

Wed Mar 16, 2016 12:31 pm

Very good explained, thank you!

Return to “Advanced users”