I wonder how it is possible to change the mac address of a wifi dongle using
I tried this but without success:
cat > /etc/systemd/network/00-wlx*********.link <<EOF [Match] Name=wlx********** [Link] MACAddress=xx:xx:xx:xx:xx:xx
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It only takes a minute to sign up.Sign up to join this community
For a *.link file there is no option
Name= defined in section
[Match]. Instead you can use
OriginalName=. But according to
man systemd.link there are some quirks with it:
A whitespace-separated list of shell-style globs matching the device name, as exposed by the udev property "INTERFACE". This cannot be used to match on names that have already been changed from userspace. Caution is advised when matching on kernel-assigned names, as they are known to be unstable between reboots.
Best is to use
MACAddress= as @Jaromanda X suggested but there are other options (see man page, there are also some examples).
If you already have a systemd unit for example to configure an interface then you can simply add a statement to the
[Service] section like:
ExecStartPre=/sbin/ip link set wlan0 address b8:27:eb:06:e8:88
Instead of ExecStartPre you can also use ExecStartPost, it depends on your situation. The interface must be DOWN to change the mac address. It is also not a bad idea to use
b8:27:eb as first three bytes if you are on a built-in RasPi device because that is the identifier for Raspberry Pi.