I researched using MAC addresses with OUI via NetworkManager to see if it can solve the issue of always having MACs from manufacturers like it happens with macchanger -a or macchanger -A.
I found two links with documentation for nmcli:
As you can see, we have this option in the documentation: generate-mac-address-mask, and I believe the right path to fix this bug is through it!
The approach I intend to follow is to register the OUIs of specific manufacturers (or potentially all OUIs I can get), or even specific categories, in the NetworkManager configuration files, and then try to resolve the issue and get MAC spoofing using MACs from real manufacturers.
Below I’m sharing the step-by-step I’m using to try to fix it, along with examples I tried — so you can also help me if you want! When we find the solution, I’ll edit the post with the discovery and everything will be resolved.
Steps
- Get the updated list of all manufacturer MACs
(If you want to do this on a separate machine)
sudo apt install macchanger;
sudo macchanger --list > maclist.txt;
This will generate an updated list of (almost) all real manufacturer OUIs used. To keep it updated, just periodically recreate maclist.txt using macchanger!
Using Ctrl + F in maclist.txt, you can search for the manufacturers you want to put into nmcli!
I’m trying to use these OUIs:
# example OUIs from Intel, Huawei, and Apple
00:02:b3 - Intel Corporation
0c:37:dc - Huawei Technologies Co., Ltd
b8:ff:61 - Apple
Use them in the configuration file according to the documentation so it looks like this: OUI+:00:00:00
00:02:b3:00:00:00 0c:37:dc:00:00:00 b8:ff:61:00:00:00
I tried this way:
generate-mac-address-mask=FF:FF:FF:00:00:00 68:F7:28:00:00:00 B8:FF:61:00:00:00 0C:37:DC:00:00:00
This was one of the attempts I made to try to make it work (just example):
sudo cat > /etc/NetworkManager/conf.d/00-macrandomize.conf << 'EOF'
[device]
wifi.scan-rand-mac-address=yes
wifi.scan-generate-mac-address-mask=FF:FF:FF:00:00:00 68:F7:28:00:00:00 B8:FF:61:00:00:00 0C:37:DC:00:00:00
[connection]
ethernet.cloned-mac-address=stable
wifi.cloned-mac-address=stable
generate-mac-address-mask=FF:FF:FF:00:00:00 68:F7:28:00:00:00 B8:FF:61:00:00:00 0C:37:DC:00:00:00
connection.stable-id=${CONNECTION}/${BOOT}
ipv6.ip6-privacy=2
ipv4.dhcp-send-hostname=false
ipv6.dhcp-send-hostname=false
[main]
hostname-mode=none
EOF
sudo systemctl restart NetworkManager
This is only one attempt — I tried several different forms. All do not work until!
There are also nmcli commands from the terminal following this pattern that might work. I believe the correct path is indeed this!
Another point is converting the maclist.txt list into the format for generate-mac-address-mask=FF:FF:FF:00:00:00 + list of all MACs to put into nmcli configuration files.
This works:
awk -F'- ' '/^[0-9]+[[:space:]]- /{mac=$2;gsub(/[[:space:]]/,"",mac);oui=substr(mac,1,8);val=oui":00:00:00";if(!printed){print "generate-mac-address-mask=FF:FF:FF:00:00:00 "val;printed=1}else printf " "val}END{if(printed)print ""}' maclist.txt > macnmcli.txt
In macnmcli.txt, the result is already in the format shown in the documentation. Once the problem is resolved, you just register it in the nmcli .conf file and then nmcli will do MAC spoofing using the same manufacturer approach as macchanger -a or macchanger -A!
Another point, after resolving this, is creating a custom list of MACs you want (or from certain categories):
- From the full
maclist.txt, extract only the list of the manufacturers you want!
- Save it as
my-maclist.txt
- Filter using the following:
awk -F'- ' '/^[0-9]+[[:space:]]- /{mac=$2;gsub(/[[:space:]]/,"",mac);oui=substr(mac,1,8);val=oui":00:00:00";if(!printed){print "generate-mac-address-mask=FF:FF:FF:00:00:00 "val;printed=1}else printf " "val}END{if(printed)print ""}' maclist.txt > my-maclist.txt
Then add this to the configuration file:
/etc/NetworkManager/conf.d/00-macrandomize.conf
In the part:
generate-mac-address-mask=
It would be possible to create lists by categories, like:
- one list for router brands
- another for laptops
- another for smartphones
- another for video games, etc.
And create configuration scripts for each one, so the user can decide whether they want to “camouflage” only with router MACs or with video game MACs, and so on…
I believe this is the right direction. I’m asking everyone for help — whoever finds the solution, please post it here. I’ll test it and update the post, and this will be great for everyone who can use Qubes with this setup!