-2

I have several raspberry pi zero w devices that all need the same installed packages, users, etc, and I would like to be able to duplicate the micro SD cards (or something that achieves the same effect), in order to avoid redoing the setup process with each pi.

I attempted this by making a disk image of one pi's SD card, and flashing it to a second SD card, and this worked for the most part. The problem is that both pis now have the same MAC addresses on their wlan0 interface, and as they're going to be on the same network, this won't work.

I haven't been able to find any resources on permanently changing the wlan0 MAC address on the zero w 2s, and I was under the impression it should be read from the hardware directly, but copying the SD cards seems to have copied the MAC addresses as well.

Is there a way to either reset the MAC addresses to the correct hardware-set ones, or to copy all of the pi files without changing the MAC addresses?

5
  • If they have the same MAC you did something wrong on the first because each Pi has a unique MAC related to serial number. Incidentally you have provided no evidence that they are the same.
    – Milliways
    Commented Dec 3, 2023 at 7:02
  • If you do duplicate SD Cards it is expedient to ensure each has a unique hostname (which is easily changed).
    – Milliways
    Commented Dec 3, 2023 at 7:07
  • Running ifconfig on both pis shows that the MAC addresses (and IP addresses) are identical. The hostnames were changed, and are different between the pis. Commented Dec 3, 2023 at 7:17
  • DO NOT put detail in Comments - edit your Question. ifconfig is deprecated - Use ip a & ip r and post IN YOUR QUESTION. It is possible to override MAC but this is not normal.
    – Milliways
    Commented Dec 3, 2023 at 7:31
  • I’m voting to close this question because it is based on your imagination.
    – Seamus
    Commented Dec 5, 2023 at 5:41

2 Answers 2

0

I'll begin this answer by saying that you must have been in an altered state of consciousness if you thought you saw what you claim to have seen; i.e.: "both pis now have the same MAC addresses on their wlan0 interface". Let me be clear: That.did.not.happen.

Exactly how RPi.com generates their MAC addresses is (at least partly) proprietary, but two minutes of research suggest strongly that it is derived in part from the RPi serial number, and is not stored on the SD card: this forum thread, and this item in the documentation both say that what you claim to have happened - did not happen:

MAC addresses are hardware dependent and do not go with the SD card.

>64-65 — MAC address; if set, system will use this in preference to the automatically generated address based on the serial number [from the section on OTP memory]

But even without these claims in the forum and documentation, this can be easily proven through a simple experiment:

  1. create a backup image file of your RPi & copy/burn it to another SD card

  2. put the copied SD card in a second RPi & boot

  3. check the MAC addresses on both RPis:

ethtool --show-permaddr eth0    # for the Ethernet adapter 
ethtool --show-permaddr wlan0   # for the WiFi adapter 

or, run ifconfig if you prefer - does not matter - you will not see the same MAC address on the RPis.

Let me summarize this for you: Being skeptical is OK; making false claims is not.

1

All Pi have a serial number (programmed at manufacture) and MAC address/es are algorithmically derived from this (you have to search to discover the algorithm but the code is available - originally the last 6 bytes of MAC and CPUID were identical - still true for eth0).

The MAC addresses are documented and (if set) the values can be listed with vcgencmd otp_dump.

See OTP Register and Bit Definitions for detail.

The MAC address is normally algorithmically derived from the serial number (in OTP register 28). The algorithm has been documented and has changed over time - (from the inclusion of WiFi in Pi3). It is possible to override this by storing MAC in OTP registers 64-65 (but this is specific to the chip - not OS).

From what I remember the last byte of wlan0 MAC is derived from eth0 MAC by exclusive OR with 0x55.

Some OS ignore these and allocate different MAC on the fly - sometimes randomly but you need to look at the OS documentation for detail.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.