How to fix the random MAC?

network

#1

I have Resin running on a fleet of RPI 3B+, the problem is that on each reboot the devices show up with a different MAC address. This is a pain as we want the DHCP-server to assign the same IP address to the devices, but with the random MAC’s that does not work.

Is there a way to fix this without too much code? Are there service variables I can set?

Thanks for any suggestions,

Thomas


#4

The MAC address is randomized during WiFi scanning. When you connect to a network the permanent MAC address will be used.

You may see the permanent MAC address by running the following command from a host OS terminal:
nmcli -p -f general.hwaddr device show wlan0.

Please let me know whether this solves the issue for you.


#6

Thanks for the reply, but unfortunately I have a different use case: my connection is wired; I have consistently seen this behavior on multiple resin devices.


#7

I will try to reproduce and get back to you.


#8

I tried this on a couple of RPis with Resin OS v2.15.1 using the internal Ethernet interface, but could not reproduce. Can you please tell me more about your configuration.


#9

I just tested and still see this. I use an RPI 3B+ with Resin OS 2.12.5+rev1 connected to an Unifi switch. The Unifi USG device is acting as DHCP server.

Picture below is from my Unifi dashboard showing the same device before and after a reboot. Same port, same device name, different MAC.


#10

The MAC address is determined by the PI’s or Compute Module’s firmware. There are reasons to change the MAC (most of them being dubious) but an OS should never just change the MAC if you do not force it to. I’m pretty sure and hope that also applies to resinOS.

Can you really reproduce that on a clean install of resinOS with no user container running?

edit: I’ve never done this, but it appears that you could put your container into a macvlan network which "allow you to assign a MAC address to a container, making it appear as a physical device on your network. "