Jump to content

Changing MAC address for RockpiS - 21.08.2 Focal / Linux 5.14.5-rockchip64


rossyduck

Recommended Posts

Using the 5.xx kernal I have been changing the eth0 MAC address at  /etc/NetworkManager/system-connections/  'Wired connection 1.nmconnection'.  This has changed a bit as the versions progress - but version  Armbian 21.08.2 Focal / Linux 5.14.5-rockchip64 has now moved the "wired ..." file to the /run/NetworkManager/system-connections/ and suspect the file is recreated at every boot (edits do not stick).  I have tried to set MAC  at /boot/armbianEnv.txt and in the eth config file.  None work.  Any ideas as to how to set the MAC address - and is it now even possible?.

Link to comment
Share on other sites

On 9/21/2021 at 12:02 AM, rossyduck said:

5.14.5-rockchip64

 

6 hours ago, rossyduck said:

Still no fix for this.  Holding back our project.

For that reason (edge kernel) and missing logs your issue report was invalid anyways so you are lucky that someone answered.

Link to comment
Share on other sites

I ran into the same issue...  This might be a fix...

A udev script assigns an Ethernet address derived from the UUID of the root partition.
So, each machine's WiFi should be unique and unchanging -- until its root partition is reformatted.

 

Note that that ‘42’ argument in macaddr.rules should be unique to each network interface whose Ethernet address is being assigned this way.

Further, this prefix less 2 should be exactly divisible by 4


/etc/udev/rules.d/05-wlan0-macaddr.rules:
 

KERNEL==“wlan0”, ACTION==“add” RUN+=“fixEtherAddr %k 42”


/lib/udev/fixEtherAddr:

#!/bin/sh
#Assign specified interface a fixed, unique Ethernet MAC address constructed
#as given prefix byte followed by 1st five bytes of the root partition’s UUID.
#Ethernet prefix byte value less 2 should be exactly divisible by 4
#e.g. (prefix - 2) % 4 == 0

[ “$2” ] || {
echo “Specify network interface and first Ethernet address byte in hex” >&2
exit 1
}

ethaddr() {
echo -n “$1”
/bin/lsblk -no UUID /bin/findmnt -no SOURCE / |
/bin/tr -d ‘-’ | /bin/fold -b2 |
for byte in 1 2 3 4 5; do read hex; echo -n “:$hex”; done
}

/usr/sbin/ifconfig $1 hw ether ethaddr $2

This file must be made executable (chmod +x /lib/udev/fixEtherAddr)

 

reboot and you should see the wlan0 interface's Ethernet address like this:

brent@pebble:/etc/udev/rules.d$ /sbin/ifconfig wlan0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

...
        ether 42:bb:a9:cc:8a:e9  txqueuelen 1000  (Ethernet)

 

brent@pebble:/etc/udev/rules.d$ /sbin/blkid

/dev/mmcblk0p1: UUID="bba9cc8a-e9bb-499a-a089-e5394b7a4fde"

 

 

 

 

Link to comment
Share on other sites

I use a single master image to build all my machines, so the root partition UUID is identical for all instances.

@brentr, do you have a magical script for this? I guess I could just create a random MAC and save it to disk somewhere...

Interestingly, Armbian seems to include logic to generate a random mac: function set_fixed_mac() in https://github.com/armbian/build/blob/f90bd10622b9e526be9fc4e6fe5cdcf56b529e52/packages/bsp/common/usr/lib/armbian/armbian-common#L35

Any ideas why it doesn't work?

I'm running a Rock Pi S, and here are my logs: https://paste.armbian.com/efayiretiy
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines