Ubuntu does not randomize WiFi/Bluetooth MAC address by default. How can I enable MAC address randomization?
For Wi-Fi on Ubuntu Desktop, first list your saved connections:
nmcli -f NAME,TYPE connection show
Replace "Your WiFi" below with the Wi-Fi connection’s name:
sudo nmcli connection modify "Your WiFi" \
802-11-wireless.cloned-mac-address random
Reconnect to apply it; this briefly disconnects Wi-Fi:
nmcli connection down "Your WiFi"
nmcli connection up "Your WiFi"
This persists for that saved connection and generates a new MAC each time it connects. Use stable instead of random to keep a consistent generated address for that connection profile. (source)
Not sure about Bluetooth though.
If you’re uncomfortable with the command line here are the steps to do it in the GUI on GNOME
Thank you. This randomizes your MAC only for the connection you’re connected to. I found some guide that apparently does this automatically both for scanning and also after you’re connected but I haven’t tried it yet. Could you take a look at this and let me know if these changes are valid?
For WiFi:
First check whether your WiFi hardware supports MAC randomization via executing the following in Terminal to turn off your WiFi hardware:
sudo ip link set dev wlan0 down
Then attempt to assign a random MAC address to it:
sudo ip link set dev wlan0 address 11:32:56:78:9C:BD
Turn on your WiFi hardware and check whether the change was successful via:
sudo ip link set dev wlan0 up
ip link show wlan0
Execute the following in Terminal to open a new file for MAC address randomization:
sudo vi /etc/NetworkManager/conf.d/mac-randomization.conf
Then write the following in it:
[device]
# Randomizes the MAC address while scanning for WiFi networks
wifi.scan-rand-mac-address=yes
[connection]
# Randomizes the MAC address when associating/connecting to a network
# Use "stable" instead of "random" if you want the same randomized MAC for the same network (useful for captive portals)
wifi.cloned-mac-address=random
Save the file and restart NetworkManager to apply the changes:
sudo systemctl restart NetworkManager
For Bluetooth:
First check whether your Bluetooth hardware supports MAC randomization via executing the followings in the Terminal:
sudo btmgmt info | grep le
If you see le appearing in the result, your Bluetooth hardware supports MAC randomization.
Then execute the following to open the BlueZ main configuration file:
sudo vi /etc/bluetooth/main.conf
Look for Privacy = off after locating the [LE] section (or create it if it doesn’t exist) and change it to Privacy = on.
[LE]
Privacy = on
Then restart your Bluetooth hardware via the following so the change takes effect:
sudo systemctl restart bluetooth
Update: it seems that this works well. I see that my WiFi MAC address has got randomized. Haven’t tested Bluetooth yet though
I don’t think its possible to randomise Bluetooth MAC?