How do I get my Pi4 (Fedora) to use a real and stable MAC address?

Sep 13, 2024 Last reply: 1 year ago 20 Replies

The current fad is to use random MAC addresses. I want anything that is "infrastructure" to have unique and stable MAC addresses, so that DHCP can give them stable IP addresses. My Pi4 runs Fedora (which is very stable on it except for the GUI), but it seems to always come up with randomized MAC addresses. Does it not HAVE a hardware MAC address?



And if it has one, where do I tell Fedora to use it?


Well there are various places. RASPI-CONFIG can I think turn it off for ethernet.

Oh. its network manager that does it

If you have a GUI look under 'interface' and 'etherne't and select desired option from 'cloned MAC address'

If no GUI use nmcli But I don't have the magic spell

I disable NetworkManager on machines I consider “servers” or “infrastructure”. Then I manually configure the network interfaces.

So how do I manually configure the ethernet port to use the hardware MAC address?

Every NIC has a built-in address, which it should default to.

Or, a quick look at the docs

formatting link
gives

ip link set «device» address «addr»

Not quite responsive:

1) I do not want to invent a MAC address, I want to tell it to use the manufacturer's supposedly unique default address AFTER the OS/driver/network-manager/whatever has already wiped it out during the boot process. Your command example assumes that I know what it is. 2)As you can see in the subject line, I am running Fedora, not rasp(b)ian. Even if Fedora's GUI does not work on the RP4, I would rather run headless than have to learn Debian system management after a decade of living in RedHat world.

Actually, I think it might be

ip link set «device» macaddr ...

There are “del” and “flush” options there, in addition to “set” -- I expect one of them will have the effect of reverting to the default MAC address.

No, it is in fact the first form. Note that the link must be down before you can change its MAC address.

Also if you set this to a non-default value, “ip link show” will show that default value as the “permaddr”. So you can easily set it back to that.

Running headless, using ssh to login, I cannot use an interactive command to do this. Does this information live in a configuration file somewhere under /etc? And the difference between raspian (a Debian derivative) and Fedora (which uses systemd) *does* make a difference.

Unfortunately you are probably the only one here that is using RedHat on a Pi.

AFAIK, ethernet defaults to 'one permanent MAC address' - its only wifi that tends to switch around for security in public wifi spaces.

Have you actually checked to see if you are getting ethernet randomisation? ifconfig -a will display it

Yes you can.

Yes.

Debian uses systemd.

Are you just trolling?

Please, stop with the ad-hominem bullshit. If you can’t help, shut up.

This what I use, when NIC MAC is changed by a new install.

#!/bin/sh UUID=$(nmcli -t con show | grep Wired | cut -d: -f2) nmcli connection down $UUID nmcli connection modify $UUID ethernet.cloned-mac-address "xx:xx:xx:xx:xx:xx" #put here your preferred MAC address nmcli connection modify $UUID -ethernet.mac-address "" nmcli connection up $UUID

After logged in with SSH, you *are using* an interactive command.

The distribution should not change the systemd setup. The configuration files are in /lib/systemd/, /run/systemd and /etc/systemd. Please get the systemd documentation and read it. The network setup is in network subdirectory in the three places.

On a Raspberry, the hardware MAC address is probably b8:27:eb:xx:yy:zz. Please post what the first octet (b8 above) is.

You may well be right about that.

Thank you for an actually useful suggestion. I had forgotten to check that and just assumed that was the cause of a change in IP address.

Hang on a minute.... IP address or MAC address?

IP address may change any time you connect to the DHCP server (if you are using DHCP).

ifconfig -a eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 *inet 192.168.0.101* netmask 255.255.255.0 broadcast 192.168.0.255 inet6 fe80::9a2:3187:4600:cfc1 prefixlen 64 scopeid 0x20

*ether d8:3a:dd:85:22:b1* txqueuelen 1000 (Ethernet) RX packets 335547 bytes 39007037 (37.2 MiB) RX errors 0 dropped 158 overruns 0 frame 0 TX packets 348598 bytes 256465720 (244.5 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

This is a statically configured *IP address* on a Pi 4B I assume the Ethernet *MAC* address is always the same.

Looking up the MAC address online: Result: MAC Address Prefix Manufacturer D83ADD Raspberry Pi Trading Ltd

My DHCP server on that network has a list of known hosts (known by their MAX address) and what their IP address should be. Hence my annoyance when employees with iPhones have randomized MAC addresses.

The "hobby" RPI4 in my "work" network was acquired in the hope that it may grow into being able to become an edge router for my home network.

The edge router on my work network is a very nice headless AMD64 with 4 Gigabit ethernet ports running Fedora with iptables, OpenVPN and lots of logging to keep the subnets behind it safe.

Considering the time I have spent on my RPI experiments, the savings on the hardware have been a false economy.

--- discussion snopped ---

The randomised MAC addresses of iPhones are from the 'locally administered' MAC address ranges. The non-local non-multicast addresses have a first octet of x0, x4, x8 or xc, where x is any hex digit.

The locally administered addresses have a first octet of x2, x6, xa or xe (like 76:f9:76:17:f6:4d, from my iPhone).

The iPhone MAC address fudging can be turned on/off for each network separately, from the 'i' menu of the WiFi connection. Just tell your folks to turn off the fudging for your network or stay outside.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required