Cannot set MAC address to any hex of my choice

Posted on

Problem :

I set my mac address for the wifi chip via:

/sbin/ifconfig wlan0 down                                                          
/sbin/ifconfig wlan0 hw ether ${WIFI_MAC_ADDR}    
/sbin/ifconfig wlan0 up    

Say the default mac address is 98:00:00:00:00:00. I if change the mac address to any new address that still starts with 98, then I have no problem.

However, if I change the 98 to any other number, then I get the following error:

wlan0: set cur_etheraddr failed
dhd_sysioc_thread _dhd_set_mac_address() failed

Why?

Solution :

The least significant bit of the first octet is reserved as the “group bit” (multicast/broadcast flag bit). MAC addresses with that bit set are not valid unicast addresses, thus are not valid to use as the MAC address of a NIC.

So in the nibble where you have a 0x8, these (even) values are legal:

0x0
0x2
0x4
0x6
0x8
0xa
0xc
0xe

And these (odd) values are illegal:

0x1
0x3
0x5
0x7
0x9
0xb
0xd
0xf

Leave a Reply

Your email address will not be published. Required fields are marked *