Changing the MAC address does not require restarting NetworkManager if you tell NetworkManager to change it. To do this, specify
802-11-wireless.cloned-mac-address in the NetworkManager profile:
nmcli con modify "My Little Wifi" wifi.cloned-mac-address 12:34:56:AB:CD:EF
nmcli con up "My Little Wifi"
# (reconnect to apply)
(The default for this parameter is
permanent which uses the hardware address. You can also set it to
preserve to use the address set by external tools.)
Is there any way of detecting a change in network connection outside of the "NetworkManager" actions? I am asking for Fedora specifically, but I'm sure the solution would be general for Linux.
No, it wouldn't be. Linux can generically tell you what SSID it's currently associated to, but that's too late – the change needs be done before userspace tells the kernel to associate with a specific network.
- To change the interface's MAC address, it must be set to "down" (disabled), otherwise the OS will refuse the change.
- Wi-Fi associations are between peers identified by their MAC address. If you somehow change the address while associated, the AP/router won't recognize you anymore and the client has to reassociate.
So you need to hook into the distro-specific network management program. Admittedly, most of them (including NetworkManager) use the same wpa_supplicant software under the hood, but 1) it's often sent configuration from different sources in different ways, and 2) it only has an option to randomize the MAC address, but not to use a specific one.