Rock64: MAC Address is NOT Unique! Topic is solved

Having issues with your DietPi installation or found a bug? Post it here.
Post Reply
PDXpi
Posts: 13
Joined: Fri Apr 12, 2019 11:17 pm

Rock64: MAC Address is NOT Unique!

Post by PDXpi »

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

    Code: Select all

    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:

    Code: Select all

    [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,
Eric P.
Portland, Oregon
User avatar
Joulinar
Posts: 3836
Joined: Sat Nov 16, 2019 12:49 am

Re: Rock64: MAC Address is NOT Unique!

Post by Joulinar »

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
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
PDXpi
Posts: 13
Joined: Fri Apr 12, 2019 11:17 pm

Re: Rock64: MAC Address is NOT Unique!

Post by PDXpi »

Joulinar wrote: Fri Jan 29, 2021 2:45 pm 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.
Are you politely suggesting that I should go ask the Armbian community?

;)

TIA,
Eric P.
Portland, Oregon
User avatar
Joulinar
Posts: 3836
Joined: Sat Nov 16, 2019 12:49 am

Re: Rock64: MAC Address is NOT Unique!

Post by Joulinar »

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 ;)
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 2628
Joined: Sat Nov 18, 2017 6:21 pm

Re: Rock64: MAC Address is NOT Unique!

Post by MichaIng »

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

/etc/systemd/network/ should only work together with systemd-networkd but we use ifupdown for network interface setup.
PDXpi
Posts: 13
Joined: Fri Apr 12, 2019 11:17 pm

Re: Rock64: MAC Address is NOT Unique!

Post by PDXpi »

MichaIng wrote: Fri Jan 29, 2021 10:27 pm Hmm, the armbianEnv.txt solution should actually work, the boot.cmd/boot.src configs that load these settings are unchanged.
Could you try eth1addr=<yourMac>

/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:
PDXpi wrote: Fri Jan 29, 2021 5:02 am ...I've gotten two answers:
  • Configure the MAC address in /boot/armbianEnv.txt

    Code: Select all

    ethaddr=36:c9:e3:f1:b8:01 <--- your desired address
    mac_addr=36:c9:e3:f1:b8:01 <--- your desired address
...
But neither answer is effective! i.e., The MAC addresses of each board remain unchanged.

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...

Code: Select all

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!

Code: Select all

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,
Eric P.
Portland, Oregon
User avatar
MichaIng
Site Admin
Posts: 2628
Joined: Sat Nov 18, 2017 6:21 pm

Re: Rock64: MAC Address is NOT Unique!

Post by MichaIng »

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 :?.

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

Code: Select all

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:

Code: Select all

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

Code: Select all

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
PDXpi
Posts: 13
Joined: Fri Apr 12, 2019 11:17 pm

Re: Rock64: MAC Address is NOT Unique!

Post by PDXpi »

I elected for the udev option:

Code: Select all

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:

Code: Select all

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!
Eric P.
Portland, Oregon
User avatar
MichaIng
Site Admin
Posts: 2628
Joined: Sat Nov 18, 2017 6:21 pm

Re: Rock64: MAC Address is NOT Unique!

Post by 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 :(.
Post Reply