Intro
MAC address (Media Access Control) is an identifier for our network devices that we use. It’s unique identifier, every network devices has different identities.
Mostly, MAC address are available at IEEE 802 networking technology such as Ethernet, Wi-Fi, and Bluetooth. And every devies that we uses such as Laptop, Computer, or even Smartphone has MAC address on top of it.
For this guide, i will show you how to automatically change MAC address of your Linux system using systemd-networkd
service and using the NetworkManager
application.
Check MAC address
Before going any further, check the MAC address on the system using the ip
command as below.
|
|
And you will be shown the MAC address of your machine as link/ether 12:9a:5b:0d:xx:xx ...
.
If you want to know what a vender of your MAC address you used, visit the site https://macvendors.com/, copy and paste your MAC address on the page, and you will get details vender of your MAC address you’re using.
Spoof MAC address with systemd-networkd service
The systemd-networkd
is a services that manages networking configuration. As networking devices appears, the service will automatically detects and configure your networking devies. Also, it can create virtual network devices.
The systemd-networkd
is part of systemd, so ensure you’re using an operating system with systemd
running on top of your OS.
Run the systemd-networkd
services and add it to start automaticall on the system boot using following commands.
|
|
Next, create a new configuration for your devices on the /etc/systemd/network
directory. For example below I create the configuration wlan0.link
to change my wlan0
interface MAC address.
|
|
Change MACAddress=xx:xx:xx:xx:xx:xx
with your real MAC address, copy and paste to your configuration.
[Match]
MACAddress=xx:xx:xx:xx:xx:xx
[Link]
MACAddressPolicy=random
NamePolicy=kernel database onboard slot path
Save.
NOTE:
Instead of random MAC address on every boot, you can use pre-defined static MAC address by changing the MACAddressPolicy=random
to static configuration MACAddress=Static Spoofed MAC
.
Now restart the systemd-networkd
services to apply.
|
|
Check again your MAC address usin gthe ip a
command and it has been changed. Otherwise, you can reboot your system.
Spoof MAC Address with NetworkManager
The second way to change MAC address is by using the NetworkManager
application, mostly available on every Linux Desktop.
Edit the /etc/NetworkManager/NetworkManager.conf
configuration file.
|
|
Now paste the following configuration to the end of the line.
[device-mac-randomization]
# "yes" is already the default for scanning
wifi.scan-rand-mac-address=yes
[connection-mac-randomization]
# Randomize MAC for every ethernet connection
ethernet.cloned-mac-address=random
# Generate a random MAC for each WiFi and associate the two permanently.
wifi.cloned-mac-address=random
Save and close.
Next, restart the NetworkManager
services to apply.
|
|
As a result, you will get random MAC address everytime you make connection to the network, on Wi-Fi and Ethernet.