Rock64: MAC Address is NOT Unique!

I have two Rock64 boards:

  • One is Version 2 (4GB).
  • One is Version 3 (4GB).

I’ve installed DietPi 6.34.3 on both boards. But I’m not able to connect both to the same L2 broadcast domain at the same time because each board has the same MAC address (86:e0:c0:ea:fa:a9)!

I’ve inquired about this over on the Official Rock64 forum. And I’ve gotten two answers:

  • Configure the MAC address in /boot/armbianEnv.txt
ethaddr=36:c9:e3:f1:b8:01 <--- your desired address
mac_addr=36:c9:e3:f1:b8:01 <--- your desired address
  • Configure the MAC address in /etc/systemd/network/00-default.link:
[Match]
MACAddress=da:19:c8:7a:6d:f4 <--- whatever your original address is

[Link]
MACAddress=da:19:c8:7a:6d:f5 <--- your desired address
NamePolicy=kernel database onboard slot path

But neither answer is effective! i.e., The MAC addresses of each board remain unchanged.

So I’ll ask the question here, in the forum for discussing the DietPi O/S instead of the forum for disussing the H/W:

When using DietPi as the O/S: Is it possible to manually configure the MAC address of the Gigabit Ethernet interface on the Rock64?

TIA,

Hi,

DietPi themselves did not offer something like this on the DietPi gui. DietPi is not an own OS, it’s a set of scripts on top of a base image. I guess solution would need to be provided on this layer.

Not sure if MichaIng has an idea

Are you politely suggesting that I should go ask the Armbian community?

:wink:

TIA,

I’m not 100% sure but I guess Rock64 is using Armbian as base image (should be visible on the header after you login). So it would be a behaviour of Armbian. And probably on an Armbian forum you will have more knowledgeable people on this :wink:

Hmm, the armbianEnv.txt solution should actually work, the boot.cmd/boot.src configs that load these settings are unchanged.
Could you try eth1addr=

/etc/systemd/network/ should only work together with systemd-networkd but we use ifupdown for network interface setup.

I think that I see the problem, right there:

I had only specified that some Ethernet interface should be configured - And I had not specified which Ethernet interface should be configured (i.e., ethX) So I added that bit…

dietpi@DietPi:~$ cat /boot/armbianEnv.txt 
verbosity=4
bootlogo=false
overlay_prefix=rockchip
rootdev=UUID=1542112e-4bd9-4f4a-9660-e9405c792736
rootfstype=ext4
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u
docker_optimizations=off
console=none
eth0addr=00:06:dc:00:00:01

…and rebooted. But the MAC address remains the same!

dietpi@DietPi:~$ ip address show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 86:e0:c0:ea:fa:a9 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.96/24 brd 192.168.0.255 scope global dynamic eth0
       valid_lft 3371sec preferred_lft 3371sec
    inet6 fe80::84e0:c0ff:feea:faa9/64 scope link 
       valid_lft forever preferred_lft forever

Ideas? Suggestions?

TIA,

eth0addr is not valid: https://www.denx.de/wiki/view/DULG/UBootEnvVariables
So with the single onboard Ethernet adapter, respectively for eth0, ethaddr is correct. Not sure why it has no effect on Armbian ROCK64 currently :thinking:.

Alternatively, ifupdown can assign the MAC address when the interface is brought up:

hwaddress ether 00:06:dc:00:00:01

Add this to /etc/network/interfaces, the eth0 block.

A udev rule could do it earlier on boot, if required, using:

ip l set dev eth0 address 00:06:dc:00:00:01



echo 'SUBSYSTEM=="net", KERNEL=="eth0", ACTION=="add", RUN+="ip l set dev eth0 address 00:06:dc:00:00:01"' > /etc/udev/rules.d/99-eth0-mac.rules

I elected for the udev option:

dietpi@DietPi:~$ ll /etc/udev/rules.d/
total 16
-rw-r--r-- 1 root root   85 Jan 24 07:03 10-wifi-disable-powermanagement.rules
-rw-r--r-- 1 root root   45 Jan  3 12:39 50-mali.rules
-rw-r--r-- 1 root root   96 Jan  3 12:39 50-rk3399-vpu.rules
-rw-r--r-- 1 root root 3449 Nov 19 04:30 50-usb-realtek-net.rules
lrwxrwxrwx 1 root root    9 Dec 16 07:48 80-net-setup-link.rules -> /dev/null

root@DietPi:~# mv /etc/udev/rules.d/80-net-setup-link.rules /tmp

root@DietPi:~# echo 'SUBSYSTEM=="net", KERNEL=="eth0", ACTION=="add", RUN+="ip l set dev eth0 address 00:06:dc:00:00:01"' > /etc/udev/rules.d/99-eth0-mac.rules

root@DietPi:~# cat /etc/udev/rules.d/99-eth0-mac.rules
SUBSYSTEM=="net", KERNEL=="eth0", ACTION=="add", RUN+="ip l set dev eth0 address 00:06:dc:00:00:01"

root@DietPi:~# reboot

And it seems to have worked perfectly:

dietpi@DietPi:~$ ip address show eth0 | grep ether
    link/ether 00:06:dc:00:00:01 brd ff:ff:ff:ff:ff:ff

Many thanks, @MichaIng!

Great!

We should implement this feature into dietpi-config, so allow both: Assigning a custom static MAC address and assigning a random new MAC at boot. It looks like the U-Boot options differs too much across different boards, bootloaders and kernels, so that it would be not always functional or mess of trail & errors to get it right for each board and then maintain those individual methods :frowning:.