inindev / nanopi-r6

stock debian arm64 linux for the nanopi r6c
GNU General Public License v3.0
7 stars 1 forks source link

Confusion with mac addresses #5

Open visicon-masc opened 1 month ago

visicon-masc commented 1 month ago

Hi!

First, thanks for your excellent work! 💪

I have a problem with the mac addresses of the R6C. I have multiple R6C and found out, that they use the same mac address. I use the same debian image for both devices (cloned by dd).

I’m not sure, but I think the R6C does not provide a physical mac address, stored on some eeprom, right? Is it defined in the device tree? I haven’t found the script that generates the mac address…

Main question: How could I change the mac address in a proper way? Defining a mac address in /etc/network/interfaces seems to be too late in some scenarios (firewall).

My goal is to clone a master image and change the mac address by some script.

Any help is highly appreciated! Thanks in advance!

Bye, Marc. 🖖

inindev commented 2 weeks ago

Sorry for the late reply. The solution I use for this is to create configuration files for each device:

ls -al /etc/systemd/network
total 12
-rw-r--r-- 1 root root 100 Jun 16 05:44 10-name-lan1.link
-rw-r--r-- 1 root root 100 Jun 16 05:44 10-name-lan2.link
-rw-r--r-- 1 root root  86 Jun 16 05:44 10-name-wan0.link

inside the file you provide over-rides for the matching interface:

[Match]
Path=platform-3c0000000.pcie-pci-0000:01:00.0
[Link]
Name=lan1
MACAddress=01:23:45:67:89:ab

use udevadm to get the match values for your nics:

udevadm info /sys/class/net/* | grep 'ID_PATH='
E: ID_PATH=platform-3c0000000.pcie-pci-0000:01:00.0
E: ID_PATH=platform-3c0400000.pcie-pci-0001:01:00.0
E: ID_PATH=platform-fe2a0000.ethernet

(the devices above are for the r5s)