Disable MAC address randomization in Fedora 40

configurationfedoramac addressnetworkmanagerwifi

I upgraded to Fedora 40 and was introduced to its new feature of MAC address randomization (for Wi-Fi interfaces at least).

How do I disable it? Links I found didn't work for me:

https://discussion.fedoraproject.org/t/f40-change-proposal-wifi-mac-randomization-system-wide/99856/5

https://fedoraproject.org/wiki/Changes/StableSSIDMACAddress

I tried to follow the advice from link 2 and create 2 files in /etc/NetworkManager/conf.d/:

22-wifi-mac-addr.conf:

  [connection.22-wifi-mac-addr]
  match-device=type:wifi
  wifi.cloned-mac-address=stable-ssid

  [.config]
  enable=nm-version-min:1.45

and 90-wifi-mac-addr.conf:

  [connection-90-wifi-mac-addr-conf]
  wifi.cloned-mac-address=permanent

I followed instructions literally: e.g. the 22* file has section named [connection.22-wifi-mac-addr] while the 90* file has one named [connection-90-wifi-mac-addr-conf] (i.e. the dot and minus after the word 'connection', present and absent '-conf' suffix etc.). Also I tried to make it uniform, sort of to fix all of the typos. Nothing, after I restarted the NetworkManager.service:

# systemctl  restart NetworkManager.service

the MAC address keeped to change on every enable/disable Wifi toggle.

Could someone help me please?

Best Answer

I tried to follow the advice from link 2 and create 2

I don't think that is what link 2 suggests.

The Fedora change introduces a new file /usr/lib/NetworkManager/conf.d/22-wifi-mac-addr.conf. That's all.

You can prevent that file from being loaded at all, by creating a file /etc/NetworkManager/conf.d/22-wifi-mac-addr.conf. That file can be empty, or contain additional configuration.

Of course, you can drop any other configuration snippets (preferably sorted after "22*"), to overwrite that configuration. Configuration snippets are loaded in a documented order, where later files overwrite earlier ones.

See man NetworkManager.conf.

Also, it's possible that the best choice is not to change the default back. Instead, modify the few profiles that should use a certain MAC address. For example with nmcli connection modify "$PROFILE" wifi.cloned-mac-address permanent. You probably should do that instead.

the MAC address keeped to change on every enable/disable Wifi toggle.

Are you sure about that? Note that while NetworkManager is not connected, the MAC address also gets randomized. That is nothing new. Did you check that the MAC address also changes while being connected?

You could disable the randomization during scanning via wifi.scan-rand-mac-address. See man NetworkManager.conf. But there should be no need to do that.

Related Question