# ESP 8266 mac address change in AP mode

**URL:** <https://forum.arduino.cc/t/esp-8266-mac-address-change-in-ap-mode/1409227>\
**Category:** Programming\
**Created:** [October 12, 2025, 9:34am UTC](https://forum.arduino.cc/t/esp-8266-mac-address-change-in-ap-mode/1409227 "2025-10-12T09:34:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![orgoneblaster](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/orgoneblaster/32/1100312_2.png) [@orgoneblaster](https://forum.arduino.cc/u/orgoneblaster)\
**Post date:** [October 12, 2025, 9:34am UTC](https://forum.arduino.cc/t/esp-8266-mac-address-change-in-ap-mode/1409227/1 "2025-10-12T09:34:34Z")

</div>

Hello,

I would like to change ESP 8266's mac address in AP mode. Unfortunately, it only works in STA mode. Is there any way to make it work in AP mode?

Thanks,

---

<div class="post-metadata">

**Author:** ![Deva\_Rishi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deva_rishi/32/227254_2.png) [@Deva\_Rishi](https://forum.arduino.cc/u/Deva_Rishi)\
**Post date:** [October 12, 2025, 9:54am UTC](https://forum.arduino.cc/t/esp-8266-mac-address-change-in-ap-mode/1409227/2 "2025-10-12T09:54:06Z")

</div>

Hmm,  
doesn't this work ?

```arduino
#include <ESP8266WiFi.h>

// Set your new MAC Address
uint8_t newMACAddress[] = {0x32, 0xAE, 0xA4, 0x07, 0x0D, 0x66};

void setup(){
  Serial.begin(115200);
  Serial.println();
  
  WiFi.mode(WIFI_STA); //WiFi.mode(WIFI_AP_STA); edit, it needs to be in station mode to begin with
  
  Serial.print("[OLD] ESP8266 Board MAC Address: ");
  Serial.println(WiFi.macAddress());

  // For Soft Access Point (AP) Mode
  wifi_set_macaddr(SOFTAP_IF, &newMACAddress[0]);
  // For Station Mode
  wifi_set_macaddr(STATION_IF, &newMACAddress[0]);
  
  Serial.print("[NEW] ESP8266 Board MAC Address: ");
  Serial.println(WiFi.macAddress());
}
 
void loop(){

}

```

---

<div class="post-metadata">

**Author:** ![orgoneblaster](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/orgoneblaster/32/1100312_2.png) [@orgoneblaster](https://forum.arduino.cc/u/orgoneblaster)\
**Post date:** [October 12, 2025, 10:49am UTC](https://forum.arduino.cc/t/esp-8266-mac-address-change-in-ap-mode/1409227/3 "2025-10-12T10:49:54Z")

</div>

Unfortunately, no. It only works in STA mode only; I got a new mac (in the terminal Wifi.macAddress()). But the wifi analyser app displays the original mac instead of the new one in AP mode.

```arduino
 delay(1000);
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  wifi_set_macaddr(SOFTAP_IF, &newMACAddress[0]);
  wifi_set_macaddr(STATION_IF, &newMACAddress[0]);

  Serial.println();
  Serial.print("Configuring access point...\n");
  WiFi.softAP(ssid, password);
  WiFi.softAPConfig(local_ip, gateway, subnet);
  IPAddress myIP = WiFi.softAPIP();
  
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  Serial.println(WiFi.macAddress());

```

---

<div class="post-metadata">

**Author:** ![Deva\_Rishi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deva_rishi/32/227254_2.png) [@Deva\_Rishi](https://forum.arduino.cc/u/Deva_Rishi)\
**Post date:** [October 12, 2025, 11:26am UTC](https://forum.arduino.cc/t/esp-8266-mac-address-change-in-ap-mode/1409227/4 "2025-10-12T11:26:07Z")

</div>

That is unfortunate. It also doesn't appear to be persistent. I will investigate a bit more later.

---

<div class="post-metadata">

**Author:** ![sonofcy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sonofcy/32/1283617_2.png) [@sonofcy](https://forum.arduino.cc/u/sonofcy)\
**Post date:** [October 12, 2025, 2:02pm UTC](https://forum.arduino.cc/t/esp-8266-mac-address-change-in-ap-mode/1409227/5 "2025-10-12T14:02:28Z")

</div>

If you understood what a MAC is and how it is assigned, maybe then you would understand why you see what you see. I was shocked to discover it could be changed at all.

---

<div class="post-metadata">

**Author:** ![robtillaart](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/robtillaart/32/1098811_2.png) [@robtillaart](https://forum.arduino.cc/u/robtillaart)\
**Post date:** [October 12, 2025, 2:25pm UTC](https://forum.arduino.cc/t/esp-8266-mac-address-change-in-ap-mode/1409227/6 "2025-10-12T14:25:57Z")

</div>

> [@sonofcy](#):
>
> I was shocked to discover it could be changed at all.

Times, they are changing … (Bob Dylan)

---

<div class="post-metadata">

**Author:** ![Deva\_Rishi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deva_rishi/32/227254_2.png) [@Deva\_Rishi](https://forum.arduino.cc/u/Deva_Rishi)\
**Post date:** [October 17, 2025, 10:21am UTC](https://forum.arduino.cc/t/esp-8266-mac-address-change-in-ap-mode/1409227/7 "2025-10-17T10:21:40Z")

</div>

Ok i did some more research and i found this as a very likely solution

```arduino
#include <ESP8266WiFi.h>

//extern "C" {
  #include "user_interface.h"
//}
void initVariant() {
  uint8_t mac[] = {0x36, 0x33, 0x33, 0x33, 0x33, 0x33};
  wifi_set_macaddr(SOFTAP_IF, &mac[0]);
}

void setup() {
  Serial.begin(115200); Serial.println();
  Serial.print("This node AP mac: "); Serial.println(WiFi.softAPmacAddress());
  WiFi.mode(WIFI_STA);
  Serial.print("This node AP (STA) mac: "); Serial.println(WiFi.softAPmacAddress());
  delay(3000);
  // WiFi.mode(WIFI_AP); // <----- without this wifi_set_macaddr wont work
  ESP.restart();
}

void loop() {
}

```

Unfortunately combining them doesn't result in what i thought i should be getting. I don't really read MAC addresses anywhere, so testing will be all on your side.

I even had some trouble compiling for ESP8285 boards (which most of my ESP-01 's are) and apparently there is 2 ways of including `"user_interface.h"`

---

<div class="post-metadata">

**Author:** ![Deva\_Rishi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/deva_rishi/32/227254_2.png) [@Deva\_Rishi](https://forum.arduino.cc/u/Deva_Rishi)\
**Post date:** [October 17, 2025, 10:30am UTC](https://forum.arduino.cc/t/esp-8266-mac-address-change-in-ap-mode/1409227/8 "2025-10-17T10:30:39Z")

</div>

Also my results appear to be core specific up to some extend. I'll dig up a nodeMCU and see what happens later on, because the ESP-01 i have may not be always doing the same as such a board

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [April 15, 2026, 10:31am UTC](https://forum.arduino.cc/t/esp-8266-mac-address-change-in-ap-mode/1409227/9 "2026-04-15T10:31:29Z")

</div>

Closed on April 15, 2026, 10:31am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
