Making wlan0 MAC address static/fixed

There are some situations where a stable MAC address is wanted on wlan0/p2p0. Like using the ROCK Pi S in a private wifi network and want to use DHCP-assigned static IP addresses.

After many hours building and debugging the kernel, I came up with the following workaround.

First, read up on NetworkManager configuration to choose whether you want a stable or permanent MAC address for wlan0/p2p0. permanent means to use the hardware MAC address.

In my environment, I opted to use permanent, so I created /etc/NetworkManager/conf.d/20-rock.conf (use the same exact file path to override /usr/lib/NetworkManager/conf.d/20-rock.conf) with the following content:


However, either stable or permanent option requires that there be a fixed hardware MAC address to use as a key in the MAC address maps. From looking at the board datasheet, the Realtek 8723DS driver source code, and the kernel logs, it seems that the Realtek 8723DS doesn’t provide a hardware MAC address. It seems to rely on the MAC address being stored in some Flash memory or some Rockchip NANDC memory, which I’m guessing is not present on the ROCK Pi S. Many have reported seeing the following errors in the boot logs:

vendor storage:20160801 ret = -1

get_wifi_addr_vendor: rk_vendor_read wifi mac address failed (-1)

When the hardware MAC address cannot be read, the rtl8723ds driver assigns a MAC address like 00:E0:4C:XX:YY:ZZ. Realtek’s OUI is 00:E0:4C and the last three octets are random values. The random values are different on every boot.

Luckily, the rtl8723ds kernel module allows specifying the MAC address through configuration. So I added something like the following into /boot/uEnv.txt to feed a specific MAC address of my choice:

Using the permanent option in NetworkManager, that assigned MAC address is seen on the wifi network. A DHCP server can issue static IP addresses corresponding to those “static” MAC addresses.