Geordon
Posts: 22
Joined: Fri Dec 27, 2013 6:29 am

WLAN MAC address changes at every reboot?

Sun Apr 07, 2019 8:00 am

I am in the US and have Xfinity as my Internet provider. They have the rented routers set up so that you can do some basic LAN and usage monitoring on their website, where you can see the devices connected to the WiFi router.

This evening, I discovered that my brand new RPi 3 B+ keeps changing the MAC address that the router sees every time it reboots. Some examples of the addresses that have shown tonight are:
26FAC023F266
323B93DE1451
AAF284033D5D
5A779C7B38A5
2A61D54909F0

This also causes a new IP address to be assigned via DHCP, so my ssh keys are getting screwed up every time I reboot the Pi.

I have updated and upgraded all of the installed software on the Pi.

Two questions:
  • What is causing this?
  • How can I either force a consistent MAC address or hard code an IP address for the wlan0 interface?
This is a crazy thing and it shouldn't be doing what it's doing, but I don't know where to start looking to figure this out. I would have thought that the MAC address was hard-coded into the wlan hardware...

User avatar
B.Goode
Posts: 7868
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: WLAN MAC address changes at every reboot?

Sun Apr 07, 2019 8:12 am

What Operating System is running on your RPi 3b+?

What additional software have you installed?

(Your expectation is correct: the wlan Mac address should be 'hardwired' and derived from the system hardware serial number. The Mac addresses you are seeing are not from the range assigned to Raspberry Pi Foundation/Trading. Something else 'odd' is going on.)

Are you in a position to put a completely standard unmodified release of Raspbian Stretch on a new/spare microSD card and check its behaviour?

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

Re: WLAN MAC address changes at every reboot?

Sun Apr 07, 2019 10:32 am

I've got a 3B that does this. It's got a static IP assigned by my router but the MAC changes at every boot and it gets a DHCP pool address.

I've not had enough time to find whether it's a firmware bug or a Raspbian bug.

It runs my ADS-B receiver so it's going to be a pain to build a new SDCard - so at the moment that's on hold until Raspbian Buster emerges from its cocoon some time in the next few months. That Raspberry will be the first on Buster.

It works ok and it does the FlightAware job ok as it is so I'm applying the "if it ain't broke" rule.
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 doctor free zone.

Geordon
Posts: 22
Joined: Fri Dec 27, 2013 6:29 am

Re: WLAN MAC address changes at every reboot?

Sun Apr 07, 2019 2:44 pm

DougieLawson wrote: I've got a 3B that does this. It's got a static IP assigned by my router but the MAC changes at every boot and it gets a DHCP pool address.

I've not had enough time to find whether it's a firmware bug or a Raspbian bug.

[...]

It works ok and it does the FlightAware job ok as it is so I'm applying the "if it ain't broke" rule.
It's driving me batty. However, after I burned the SD card with Stretch (again) it seems to be holding the MAC address fine. Is there somewhere on the Pi that I can manually set the IP address snd still get everything else via DHCP?

I'm glad to know its not just me experiencing this weirdness.

Andyroo
Posts: 3319
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: WLAN MAC address changes at every reboot?

Sun Apr 07, 2019 2:52 pm

You can set a static IP in /etc/dhcpcd.conf

Mine has:

Code: Select all

interface wlan0
    static ip_address=192.168.1.2/24
    static routers=192.168.1.254
For my WiFi link but you can do the same for eth0 if you want.
Need Pi spray - these things are breeding in my house...

Geordon
Posts: 22
Joined: Fri Dec 27, 2013 6:29 am

Re: WLAN MAC address changes at every reboot?

Sun Apr 07, 2019 8:25 pm

Andyroo wrote:
Sun Apr 07, 2019 2:52 pm
You can set a static IP in /etc/dhcpcd.conf
I'm slightly confused. In order to get something similar, I had to install udhcpd, which seems to be a full DHCP server implementation. My Xfinity router is my local DHCP service provider, and I want it to stay that way.

Is there a package that I should be looking for to install that file, or do I just need to manually create it as you showed and that will be enough to get the job done to force the specified IP address?

Geordon
Posts: 22
Joined: Fri Dec 27, 2013 6:29 am

Re: WLAN MAC address changes at every reboot?

Sun Apr 07, 2019 9:04 pm

Ok, I was able to force the WiFi address, but the MAC is still flipping all over the place with reboots, which is playing havoc with the router's device table. I plugged the Pi in via Ethernet and was able to use the network preferences tool to configure the address.

This is definitely an annoying issue. Is there somewhere I can submit a bug report or something?

mattmiller
Posts: 2061
Joined: Thu Feb 05, 2015 11:25 pm

Re: WLAN MAC address changes at every reboot?

Sun Apr 07, 2019 9:26 pm

JFI I just tried rebooting my Pi3B+ to see what happens and its kept its MAC address of b8:27:eb:7f:21:68 so it doesn't happen to them all

glum
Posts: 26
Joined: Wed May 16, 2018 11:27 am

Re: WLAN MAC address changes at every reboot?

Sun Apr 07, 2019 10:17 pm

In order to get something similar, I had to install udhcpd
`dhcpcd` is the default dhcp client in Raspbian. You don't need to install anything.

Geordon
Posts: 22
Joined: Fri Dec 27, 2013 6:29 am

Re: WLAN MAC address changes at every reboot?

Sun Apr 07, 2019 10:25 pm

Aurgh! I just rebooted my Pi again (while it was still plugged into Ethernet) and BOTH of the interfaces changed MAC addresses!

User avatar
NGC6543
Posts: 75
Joined: Thu Feb 28, 2019 7:30 pm
Location: Lancashire, UK

Re: WLAN MAC address changes at every reboot?

Sun Apr 07, 2019 11:37 pm

Assuming (dangerous, I know) that the (seemingly top secret) LAN7515 is similar to the LAN7500, the MAC address is either stored in an external EEPROM or is configured by the driver. I cannot see an EEPROM anywhere near the LAN7515, so in the absence of any other clues must assume it's done by the driver.

Edit to add: Just realised we're mainly talking about WLAN. The below still applies.

Now, that should be done by some algorithm that doesn't change. It's simply wrong that it can do so without external influence. Anyway...

External influence... if the driver supports the standard ifconfig command to change MAC address, perhaps putting it in a startup script would do the trick.

Code: Select all

ifconfig eth0 hw ether MAC-ADDRESS
Maybe worth a try. I'm not running it my 3B+, because it's working properly and I don't want to scupper it :lol:

The other possibility of course is that the LAN7515 holds the MAC address internally in which case, if no software is deliberately changing the MAC, something is broken.

User avatar
rpdom
Posts: 14451
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: WLAN MAC address changes at every reboot?

Mon Apr 08, 2019 5:37 am

NGC6543 wrote:
Sun Apr 07, 2019 11:37 pm
The other possibility of course is that the LAN7515 holds the MAC address internally in which case, if no software is deliberately changing the MAC, something is broken.
The Ethernet MAC is set by the driver and based on the Pi's serial number.

The built-in WiFi MAC is set the same way, but the bottom 48 bits are xored with 0x555555 to make it different to the Ethernet MAC.

andrum99
Posts: 574
Joined: Fri Jul 20, 2012 2:41 pm

Re: WLAN MAC address changes at every reboot?

Mon Apr 08, 2019 7:31 am

rpdom wrote:
Mon Apr 08, 2019 5:37 am
NGC6543 wrote:
Sun Apr 07, 2019 11:37 pm
The other possibility of course is that the LAN7515 holds the MAC address internally in which case, if no software is deliberately changing the MAC, something is broken.
The Ethernet MAC is set by the driver and based on the Pi's serial number.

The built-in WiFi MAC is set the same way, but the bottom 48 bits are xored with 0x555555 to make it different to the Ethernet MAC.
Just had a quick look at the driver for the LAN7515, and if I've read it correctly it attempts to get a MAC address from Device Tree, then EEPROM, then OTP, then falls back to generating a random MAC address. How does the serial number get passed to the driver to calculate the MAC address? Is the OTP referenced in the driver One Time Programmable memory, or something else?

incognitum
Posts: 279
Joined: Tue Oct 30, 2018 3:34 pm

Re: WLAN MAC address changes at every reboot?

Mon Apr 08, 2019 11:21 am

rpdom wrote:
Mon Apr 08, 2019 5:37 am
The Ethernet MAC is set by the driver and based on the Pi's serial number.

The built-in WiFi MAC is set the same way, but the bottom 48 bits are xored with 0x555555 to make it different to the Ethernet MAC.
While the values are both derived from serial, I recall they are SET in different ways though.

The wifi chip has its own OTP.
Unlike Ethernet, in which case the Pi's firmware calculates desired MAC and passes it to Linux through device-tree, so driver can set it.
Geordon wrote:
Sun Apr 07, 2019 10:25 pm
Aurgh! I just rebooted my Pi again (while it was still plugged into Ethernet) and BOTH of the interfaces changed MAC addresses!
Are you sure that both wifi and LAN are changing?
Are you running something different than Raspbian?

User avatar
RaTTuS
Posts: 10323
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: WLAN MAC address changes at every reboot?

Mon Apr 08, 2019 12:31 pm

Code: Select all

cat /etc/debian_version ; uname -v ; ip link show
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

Return to “Troubleshooting”