OpenWrt Forum Archive

Topic: Change wifi MAC address

The content of this topic has been archived on 17 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello,

I want to change the wifi MAC address on my TL-WR841n, I tried the usual way using ifconfig:

root@OpenWrt:/# ifconfig
...
wlan1     Link encap:Ethernet  HWaddr 10:FE:ED:EB:65:C0
          inet6 addr: fe80::12fe:edff:feeb:65c0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1317 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1953 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:260870 (254.7 KiB)  TX bytes:515115 (503.0 KiB)

root@OpenWrt:/# ifconfig wlan1 down
root@OpenWrt:/# ifconfig wlan1 hw ether 10:FE:ED:EB:66:A0
root@OpenWrt:/# ifconfig wlan1 up
root@OpenWrt:/# ifconfig
...
wlan1     Link encap:Ethernet  HWaddr 10:FE:ED:EB:66:A0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:1328 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1985 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:263754 (257.5 KiB)  TX bytes:526934 (514.5 KiB)

All good so far, but when I start wifi:

root@OpenWrt:/# wifi
root@OpenWrt:/# ifconfig
...
wlan1     Link encap:Ethernet  HWaddr 10:FE:ED:EB:65:C0
          inet6 addr: fe80::12fe:edff:feeb:65c0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:1056 (1.0 KiB)

The MAC-address gets changed back to the original one.

I tried to join the network manually after changing the MAC address but that didn't work either:

root@OpenWrt:/# iwconfig wlan0 essid mDjMAR1L5IsAQwG4
Error for wireless request "Set ESSID" (8B1A) :
    SET failed on device wlan0 ; Operation not supported.
root@OpenWrt:/# iw dev wlan0 connect -w mDjMAR1L5IsAQwG4
command failed: Operation not supported (-122)

I looked at what the /sbin/wifi script does, but I was unable to find out where the ubus calls are going.

What am I doing wrong? How can I spoof the MAC address for the wifi interface?

Set it as such in your /etc/config/wireless:

uci -q set wireless.@wifi-iface[-1].macaddr=$mac_addr

Thanks nenekofi, that was suprisingly easy!

iasimov wrote:

it's a bit more complex than nenekofi solution, but it's a permanent change.

Thanks for the link, but this "half-permanent" way (e.g. it lasts through reboots) is enough for me. I don't want to risk bricking my router wink


iasimov wrote:

btw, someone know about legal aspects of change mac addr?

That's a good question, according to the wikipedia article it depends on what you do with the spoofed MAC address.

The discussion might have continued from here.