A Media Acess Control (MAC) address is a unique 12 digit hexidecial number (identifier) that is assigned to a Network Interface Controller (NIC). ie Ethernet, Wi-Fi and Bluetooth. MAC addresses are usuall represented as 6 groups of 2 digit hexidecimal numbers seperated by a color, dash or space.
The first 3 groups are the Organizationally Unique Identifier (OUI).
OUI | Organization |
---|---|
3c:2e:F9 | Apple |
48:9e:bd | HP |
94:e2:3c | Intel |
e4:5f:01 | Raspberry Pi |
Linux allows you to change a MAC address. You can do this with the application macchanger or with the ip link set command. I prefer the ip link set command, because I don't have to install macchanger, I don't have to worry about it collecting data, and I don't have to worry about bugs. :
Use the following ip link set commands to change a mac address
sudo ip link set dev eno1 down
sudo ip link set dev eno1 address xx.xx.xx.xx.xx.xx
sudo ip link set dev eno1 up
where eno1 is the network device name, and xx:xx:xx:xx:xx:xx the new 6 digit hex MAC address.
This is not persistant. When you reboot, it will revert back to the hardware mac address. However, you can set up a cron job that executes everytime the system boots.
Create a new file, mac_changer.sh, in the /etc directory that is owned by root:
sudo vi /etc/mac_changer.sh
Place the following contents in mac_changer.sh:
ip link set dev eno1 down
ip link set dev eno1 address xx.xx.xx.xx.xx.xx
ip link set dev eno1 up
Make it executabe by only root:
sudo chmod u+x mac_changer.sh
Create a root cron job that runs everytime the system reboots:
sudo crontab -e
At the end of this file, add the following new line:
@reboot /etc/mac_changer.sh
Some older articles use ipconfig instead of ip link set, but ipconfig is deprecated and being phased out.
References: