Random mac-adress on eth0, eth1 not visible

Hi, i have first boot-up my R2 using debian-jessie-line-image. first thing i noticed…everytime i boot-up i have another mac-adress on eth0 (wan-port), how to change that? second, i see no eth1 (lan-Ports), any idea?

regards Frank

Hello Frank,

you can assign static MAC addresses using the instructions from Static MAC-Address for Bananapi

EDIT: Or you can use my ruleset from udev aswell:

cat /etc/udev/rules.d/69-static-mac.rules

# MAC address for eth0 / WAN

ACTION=="add", SUBSYSTEM=="net", ATTR{dev_id}=="0x0", ATTR{ifindex}=="6" RUN+="/sbin/ip link set dev %k address 26:bf:b5:59:15:d0"

# MAC address for eth1 / LAN

ACTION=="add", SUBSYSTEM=="net", ATTR{dev_id}=="0x0", ATTR{ifindex}=="5" RUN+="/sbin/ip link set dev %k address 26:bf:b5:59:15:d1"

You can determine ATTR{ifindex} using cat /sys/class/net/eth0/ifindex

Do you see any other interfaces than eth0 if you run cat /proc/net/dev ?

Regards, Daniel

in proc i see also eth1

ok, i see eth1 is not auto in /etc/network/interfaces…

how to change that mac also (difference in udev-rule)?

i see also in /etc/network/interfaces an hint for changing the HW-Adress:

iface eth0 inet dhcp

hwaddress ether # if you want to set MAC manually

setting MAC via /etc/network/interfaces seems not to work tried that way:

iface eth0 inet static hwaddress ether DE:AD:BE:EF:69:01

i’ve tried setting the mac via udev-rule (but don’t know if udev is running in the boot-process):

(how to create aa code-block here to make it readable??)

nano /etc/udev/rules.d/75-static-mac.rules

#######eth0 ACTION==“add”, SUBSYSTEM==“net”, ATTR{dev_id}==“0x0”, ATTR{ifindex}==“3”, RUN+="/usr/bin/ip link set dev %k address 72:29:3c:06:d0:17" #######eth1 ACTION==“add”, SUBSYSTEM==“net”, ATTR{dev_id}==“0x0”, ATTR{ifindex}==“4”, RUN+="/usr/bin/ip link set dev %k address 8a:df:d4:39:f3:8b"

udevadm info -q all --path /sys/class/net/eth0 | less

P: /devices/platform/1b100000.ethernet/net/eth0

E: DEVPATH=/devices/platform/1b100000.ethernet/net/eth0

E: ID_NET_DRIVER=mtk_eth_soc

E: ID_PATH=platform-1b100000.ethernet

E: ID_PATH_TAG=platform-1b100000_ethernet

E: IFINDEX=3

E: INTERFACE=eth0

E: MATCHDEVID=0x0

E: MATCHIFTYPE=1

E: SUBSYSTEM=net

E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/eth0

E: TAGS=:systemd:

E: UDEV_LOG=6

E: USEC_INITIALIZED=785847


udevadm info -q all --path /sys/class/net/eth1 | less

P: /devices/platform/1b100000.ethernet/net/eth1

E: DEVPATH=/devices/platform/1b100000.ethernet/net/eth1

E: ID_NET_DRIVER=mtk_eth_soc

E: ID_PATH=platform-1b100000.ethernet

E: ID_PATH_TAG=platform-1b100000_ethernet

E: IFINDEX=4

E: INTERFACE=eth1

E: MATCHDEVID=0x0

E: MATCHIFTYPE=1

E: SUBSYSTEM=net

E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/eth1

E: TAGS=:systemd:

E: UDEV_LOG=6

E: USEC_INITIALIZED=788285


cat /sys/class/net/eth0/ifindex

3

cat /sys/class/net/eth1/ifindex

4

udev_eth1.txt (5.1 KB)

i tried now to set MAC with the hwaddress-param in /etc/network/interfaces for eth1, that worked, but not for eth0…also static instead of dhcp/manual works…seems my problem was the appended Comment (# if you want to set MAC manually ) that MUST be removed, else that line creates error and the interface does not get created

that works:

auto eth0
  iface eth0 inet static
  hwaddress ether 08:00:00:00:00:00
  address 192.168.0.10
  netmask 255.255.255.0
  gateway 192.168.0.5

auto eth1
    iface eth1 inet static
    address 192.168.50.1
    hwaddress ether 08:00:00:00:00:01

What solution did you go with to control static MAC?

This is the old ifupdown way…newer images using systemd-networkd

https://wiki.fw-web.de/doku.php?id=en:bpi-r2:network:start#using_systemd

Thank you

For the WAN MAC… /etc/systemd/network/10-wan.link

yes, in the images created by my BPI-Router-Images repo it is prepared here: