0

I need to alter the MAC address for eth1 ethernet device on my embedded system permanently so it retains this MAC address on every boot.

The OS I'm using:

VERSION_ID="v2015.12"
NAME="Angstrom"
ID="angstrom"
PRETTY_NAME="The Ångström Distribution v2015.12"
ANSI_COLOR="1;35"
HOME_URL="http://www.angstrom-distribution.org"

The version of Linux I am using is:

Linux arria10 4.1.33-ltsi-altera #1 SMP Mon Oct 30 10:14:22 PDT 2017 armv7l GNU/Linux

I am able to set the MAC address for eth0 by altering the following bootarg:

setenv ethaddr 00:11:22:33:44:55
save
run bootcmd

Once booted, eth0 takes this MAC address as expected.

When I try to do the same for eth1, using eth1addr a random MAC address is defined when I boot.

I can however alter the MAC address of eth1 once booted by using the following:

ifconfig eth1 down
ifconfig eth1 hw ether 00:11:22:33:44:56
ifconfig eth1 up

This is not a permanent solution for me as I would need to set the MAC every time I have booted the device.

Is there a way to set the MAC address of eth1 from the bootargs? Also any ideas on why I wouldn't be able to set the MAC address using setenv eth1addr?

Edit:
eth0 is RGMII, eth1 is SGMII

  • try systemd-udevd – DDS Feb 14 at 15:58
  • @DDS This facility is not available to me on this version of Linux. Version is Linux arria10 4.1.33-ltsi-altera #1 SMP Mon Oct 30 10:14:22 PDT 2017 armv7l GNU/Linux – Brian Waters Feb 14 at 16:14
  • What about udev rules in /etc/udev/rules.d/70-persistent-net.rules or is this also not possible due to the previous comment? – eblock Feb 14 at 16:19
  • @eblock Is this a file I have to create myself? Do you have a template? – Brian Waters Feb 14 at 16:35
  • 1
    The purported duplicate question is specific to Debian and Debian-derived operating systems. This question has not actually specified an operating system. (No, specifying the kernel is not enough.) – JdeBP Feb 14 at 17:40
0

Don't have an angstrom box at reach, but IIRC you can set this in the /etc/network/interfaces file

auto eth1
iface eth1 inet dhcp # or whatever setting you need for eth1
hwaddress ether 00:11:22:33:44:56
  • Thanks @isalgueiro, unfortunately this didn't work. – Brian Waters Feb 15 at 12:56
  • Do I need to add pre-up and pre-down functionality? – Brian Waters Feb 15 at 13:02
  • It should work without pre-up or -down. Sorry to hear that it didn't work for you – isalgueiro Feb 16 at 8:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.