fonix232
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?

epoch1970
Posts: 2671
Joined: Thu May 05, 2016 9:33 am
Location: Paris, 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
DougieLawson
Posts: 35052
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

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.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

epoch1970
Posts: 2671
Joined: Thu May 05, 2016 9:33 am
Location: Paris, 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

[email protected]:~# modprobe -r 8192cu ; modprobe 8192cu rtw_initmac=00:11:22:33:44:55
[email protected]:~# 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)

[email protected]:~# lsusb | grep -i wireless
Bus 001 Device 004: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
[email protected]:~# 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

dgordon42
Posts: 755
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,
Dave.


markllama
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.

b8:27:eb:be:16:f6

When running Fedora:

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

For eth0:

$ cat /etc/sysconfig/network-scripts/ifcfg-eth0
NAME="eth0"
DEVICE="eth0"
TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
ONBOOT="yes"
IPADDR="192.168.1.14"
PREFIX="24"
GATEWAY="192.168.1.1"
DNS1="192.168.1.1"

IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
MACADDR=0a:00:c0:a8:01:0e

$ 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”