how to get a static MAC after reboot? - Solution

This forum is for supported devices using an ARMv7 Samsung SoC.

how to get a static MAC after reboot? - Solution

Postby yacoob1 » Sat Jan 05, 2019 1:22 pm

Hi.

I'm starting this new topic as I found out this one https://archlinuxarm.org/forum/viewtopic.php?f=47&t=11946#p56553 without a definite answer.
I run into the same, problem, namely my odroid u2 would generate new mac address for ethernet port on every reboot. There was also an error in the journalctl log:
$this->bbcode_second_pass_code('', 'Jan 05 11:33:16 alarm systemd-udevd[235]: Could not generate persistent MAC address for eth0: No such file or directory')

After some searching I found out that the boot. script has macaddress assignment commented out, so the system was trying to generate random one on every boot.

The script in /boot/boot.txt starts with
$this->bbcode_second_pass_code('', '# After modifying, run ./mkscr

# MAC address configuration
#setenv macaddr "00:1e:ee:61:7a:39"
...')

First you need to remove the comment before setenv command. You probably shouldn't leave the default macaddress, so I generated a random one. Note MAC addresses have some limitations (two bits in first byte are important and cannot be random) as described here https://superuser.com/a/725472 and the proper one-liner was found here https://serverfault.com/a/631119

$this->bbcode_second_pass_code('', 'printf '%02x' $((0x$(od /dev/urandom -N1 -t x1 -An | cut -c 2-) & 0xFE | 0x02)); od /dev/urandom -N5 -t x1 -An | sed 's/ /:/g'')
resulting with a proper random MAC address - mine was:
$this->bbcode_second_pass_code('', 'c2:f6:f1:5a:99:27')

So, I copied this random MAC and pasted it into the /boot/boot.txt script into the quotes of setenv macaddr command. Now it read:

$this->bbcode_second_pass_code('', '# After modifying, run ./mkscr

# MAC address configuration
setenv macaddr "c2:f6:f1:5a:99:27"
...')

Next, it's important to generate proper uboot script (boot.scr) out of the source boot.txt:
$this->bbcode_second_pass_code('', '[root@alarm boot]# ./mkscr
Image Name: U-Boot boot script
Created: Sat Jan 5 13:10:40 2019
Image Type: ARM Linux Script (uncompressed)
Data Size: 668 Bytes = 0.65 KiB = 0.00 MiB
Load Address: 00000000
Entry Point: 00000000
Contents:
Image 0: 660 Bytes = 0.64 KiB = 0.00 MiB
')

(Note, you need to have uboot-tools installed, so, if running the above commands in archlinux, install them with
$this->bbcode_second_pass_code('', 'pacman -S uboot-tools'))

Next, reboot the odroid.

You can check if your mac address is now persistent over reboots
$this->bbcode_second_pass_code('', 'ifconfig eth0 |grep ether')

Hope this helps,

Y
yacoob1
 
Posts: 1
Joined: Sat Jan 05, 2019 12:54 pm

Re: how to get a static MAC after reboot? - Solution

Postby renegat » Wed Jan 23, 2019 3:04 am

Works! :D
Thank you for pointing out the reservation of the U/L-Bit!
Now I know why my fully random MAC created with macchanger could not work.
Odroid U3+ / U3 / U2 / C1+ / XU4 / HC1 / MC1
RPi 1B / 1B+ / 2B / 3B / Zero WH
renegat
 
Posts: 26
Joined: Sat Oct 12, 2013 1:56 pm


Return to Samsung

Who is online

Users browsing this forum: No registered users and 3 guests