I'm using an Arduino Mega. I know that Ethernet Shield 2's come with a sticker with the MAC Address printed on it. This would imply to me that this address is hardcoded into the shield. Is there any way to recover the MAC without manually entering it in the sketch? Thanks!

2 Answers 2


No, the W5500 chip does not have a mac address. You can give it any mac address that you want. The router might not like some mac addresses though.

There are online mac address generators.

The sticker with the mac address is an extra service. It is unique number. But it is just a number on a sticker, it is not related to that specific shield.

Often the mac address DEADBEEFFEED was used. But when two different Arduino boards use the same mac address, the router thinks it is the same device. When there are two devices with the same mac address at the same time connected, that is for sure a way to mess up the router.

  • 1
    It would have been so simple to include a little I2C, SPI or 1-Wire EEPROM on there with the MAC address programmed in at the factory. The price difference would have been negligible. Such a shame they never bothered...
    – Majenko
    Commented Jul 29, 2017 at 10:15
  • Thanks for the info. I was afraid of that. Basically, this prototype will eventually go into large-scale production (Using a proprietary board developed from the Arduino code/circuitry, etc. I end up with) so using a randomly-generated mac seems like a bad way to go. Ah well, I'm sure there's an alternative to the Ethernet shield. Commented Aug 1, 2017 at 20:24

This is an old question, but I wanted to share my code which fixes this. Basically, the next code generates a "locally managed address" and stores it to EEPROM. On subsequent starts, it read the address from EEPROM so that you would generally get the same IP address from the DHCP server.

If you do not have EEPROM, you may have another memory that survives programming cycles (SPI Flash, RTC RAM, etc) - you'll need to update the sketch for that.

#include <EEPROM.h>

// If defined, report information about MAC ADDRESS INITIALISATION

// Local mac address, initialiser can be removed (when using initMacAddress)
uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};

void initMacAddress() {
  // Rather than having a fixed MAC address for an Arduino sketch,
  // this implements a different, random address which is persistant
  // by storing it to EEPROM (which only works when EEPROM is available).

  for(int i=0;i<6;i++) {

  // Generating a new MAC address if the address found is not locally
  // Administrated.  This test requires that the 2 lower bits of the first
  // byte are equal to "2" (bits 1 and 0).
  // Normally it is only required that bit 1 is "1", but checking bit 0 for a 0
  // allows to detect an uninitialized EEPROM.
  if((mac[0]&0x03)!=2) { // Is this a locally administered address?
    // No a locally managed address, generate random address and store it.
      Serial.println("GENERATE NEW MAC ADDR");
    // make sure random numbers used are not always the same
    for(int i=0;i<6;i++) {
      if(i==0) {mac[0]&=0xFC;mac[0]|=0x2;} // Make locally administered address


        if(mac[i]<10) {Serial.print('0');}  // Print two digets

void setup() {

EDIT: An anonymous use suggested a call to randomSeed(analogRead(0)); to ensure that the generated value is random. This (may) need to be done only once in the program. It's best done in the 'setup()' as the analog pin that can actually be used depends on the application - one might also use more complex & random initialisation schemes.

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.