NIC without MAC

Discussion in 'UDOO X86' started by am1982, Aug 21, 2019.

  1. am1982

    am1982 UDOOer

    Joined:
    Mar 13, 2018
    Messages:
    14
    Likes Received:
    4
    We've purchased this M.2 Ethernet modules as extension. My problem was, that one of three modules has no MAC address on both ports. It's also listed in the Bios Utility as 00:00:00:00:00:00. The internal Ethernet NIC has a MAC. If I don't set the MAC address to a valid address, it's impossible to bring the devices up. I guess the MAC is flashed on the chip and maybe during this process was a failure.

    Here my solution for this silly problem:
    /etc/udev/rules.d/75-mac-spoof.rules
    Code:
    ACTION=="add", SUBSYSTEM=="net", ENV{DEVPATH}=="/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/0000:02:01.0/0000:03:00.0/net/enp3s0", RUN+="/usr/bin/ip link set dev $name address 00:c0:08:xx:xx:xx"
    ACTION=="add", SUBSYSTEM=="net", ENV{DEVPATH}=="/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/0000:02:02.0/0000:04:00.0/net/enp4s0", RUN+="/usr/bin/ip link set dev $name address 00:c0:08:xx:xx:xx"

    There are other methods to change the mac address.
    • systemd-networkd (/etc/systemd/network/xxxxx.link)
    • macchanger
    I hope you don't need this information, because having no MAC is extremely rare and in normal situations you don't change a MAC address.
     
    waltervl and LDighera like this.
  2. am1982

    am1982 UDOOer

    Joined:
    Mar 13, 2018
    Messages:
    14
    Likes Received:
    4
    I have this problem also on the second device.

    Code:
    root@xc11:/home/skyradar# ip l
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: enp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
        link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
    3: enp4s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
        link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
    4: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
        link/ether 00:c0:08:98:46:79 brd ff:ff:ff:ff:ff:ff
    
    The devices enp3s0 and enp4s0 are the dual Ethernet extension ports.
    Currently I'm trying to set the MAC address with link files in /etc/systemd/network/, which looks a bit easier.
    But currently the created link file is parsed, but only the 99-default.link applies to the link.
    The created link file:

    /etc/systemd/network/enp3s0.link
    Code:
    [Match]
    Path=pci-0000:03:00.0
    
    [Link]
    MACAddressPolicy=persistent
    MACAddress=00:c0:08:98:46:78
    
    Status with networkctl:
    Code:
    root@xc11:/home/skyradar# networkctl status enp3s0
    ● 2: enp3s0
           Link File: /usr/lib/systemd/network/99-default.link
        Network File: n/a
                Type: ether
               State: off (unmanaged)
                Path: pci-0000:03:00.0
              Driver: r8169
              Vendor: Realtek Semiconductor Co., Ltd.
               Model: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (RTL8111/8168 PCI Express Gigabit Ethernet controller)
    Triggering the mechanism:
    Code:
    root@xc11:/home/skyradar# udevadm test-builtin net_setup_link /sys/class/net/enp3s0
    Load module index
    Parsed configuration file /etc/systemd/network/enp3s0.link
    Parsed configuration file /usr/lib/systemd/network/99-default.link
    Created link configuration context.
    ID_NET_DRIVER=r8169
    Config file /usr/lib/systemd/network/99-default.link applies to device enp3s0
    link_config: autonegotiation is unset or enabled, the speed and duplex are not writable.
    ID_NET_LINK_FILE=/usr/lib/systemd/network/99-default.link
    Unload module index
    Unloaded link configuration context.
    As you can see still /usr/lib/systemd/network/99-default.link is used for this interface.
    But the mac is not set.

    And here the demonstration, that no mac-address were set and what happens if I want to bring up the interface with an invalid mac address. Setting the address solves the problem. I want to use the systemd for this task. Hopefully I get this to work.
    If you have any clue what's wrong with this approach, tell me.

    Code:
    root@xc11:/home/skyradar# ip a l
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2: enp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
        link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
    3: enp4s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
        link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
    4: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
        link/ether 00:c0:08:98:46:79 brd ff:ff:ff:ff:ff:ff
        inet 192.168.10.100/24 brd 192.168.10.255 scope global enp5s0
           valid_lft forever preferred_lft forever
        inet6 fe80::2c0:8ff:fe98:4679/64 scope link
           valid_lft forever preferred_lft forever
    root@xc11:/home/skyradar# ip l s dev enp3s0 up
    RTNETLINK answers: Cannot assign requested address
    root@xc11:/home/skyradar# ip l s dev enp3s0 address 00:c0:08:98:46:77
    root@xc11:/home/skyradar# ip l s dev enp3s0 up
    root@xc11:/home/skyradar# ip l
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: enp3s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
        link/ether 00:c0:08:98:46:77 brd ff:ff:ff:ff:ff:ff
    3: enp4s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
        link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
    4: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
        link/ether 00:c0:08:98:46:79 brd ff:ff:ff:ff:ff:ff
    root@xc11:/home/skyradar#
    
     
  3. am1982

    am1982 UDOOer

    Joined:
    Mar 13, 2018
    Messages:
    14
    Likes Received:
    4
    Finally I got it working with systemd-networkd (link-files) and netplan (Ubuntu).

    Code:
    root@xc11:/etc/systemd/network# tree /etc/systemd/network
    /etc/systemd/network
    ├── 10-enp3s0.link
    └── 20-enp4s0.link
    
    root@xc11:/etc/systemd/network# for file in *.link; do echo -e "\n\nFile: $file\n================\n"; cat $file; done
    
    
    File: 10-enp3s0.link
    ================
    
    [Match]
    Path=pci-0000:03:00.0
    
    [Link]
    MACAddress=00:c0:08:98:46:77
    AutoNegotiation=yes
    
    
    File: 20-enp4s0.link
    ================
    
    [Match]
    Path=pci-0000:04:00.0
    
    [Link]
    MACAddress=00:c0:08:98:46:78
    AutoNegotiation=yes
    
    root@xc11:/etc/systemd/network# tree /etc/netplan/
    /etc/netplan/
    └── 50-cloud-init.yaml
    
    root@xc11:/etc/systemd/network# cat /etc/netplan/50-cloud-init.yaml
    # This file is generated from information provided by
    # the datasource.  Changes to it will not persist across an instance.
    # To disable cloud-init's network configuration capabilities, write a file
    # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
    # network: {config: disabled}
    network:
        ethernets:
            enp5s0:
                dhcp4: false
                addresses: [192.168.10.100/24, ]
                gateway4: 192.168.10.1
                nameservers:
                    addresses: [192.168.10.1, ]
            enp3s0:
                dhcp4: false
                addresses: [192.168.1.1/24]
            enp4s0:
                dhcp4: false
                addresses: [192.168.16.1/24]
        version: 2
    
    Compared to the udev configuration it's a little bit easier.
    In the .link files you should not use OriginalName to match the interface. Handling the interfaces with the original names given from kernel does keep the order of the detected interfaces. With the Rule OriginalName I was not able to address eth0, eth1, eth2.
    Instead I use the Path: pci-0000:03:00.0 and pci-0000:04:00.0

    To check if your configuration is applied, you could used udevadm:
    Code:
    root@xc11:/etc/systemd/network# udevadm test-builtin net_setup_link /sys/class/net/enp3s0
    Load module index
    Parsed configuration file /usr/lib/systemd/network/99-default.link
    Parsed configuration file /etc/systemd/network/20-enp4s0.link
    Parsed configuration file /etc/systemd/network/10-enp3s0.link
    Created link configuration context.
    ID_NET_DRIVER=r8169
    Config file /etc/systemd/network/10-enp3s0.link applies to device enp3s0
    link_config: autonegotiation is unset or enabled, the speed and duplex are not writable.
    ID_NET_LINK_FILE=/etc/systemd/network/10-enp3s0.link
    Unload module index
    Unloaded link configuration context.
    root@xc11:/etc/systemd/network# udevadm test-builtin net_setup_link /sys/class/net/enp4s0
    Load module index
    Parsed configuration file /usr/lib/systemd/network/99-default.link
    Parsed configuration file /etc/systemd/network/20-enp4s0.link
    Parsed configuration file /etc/systemd/network/10-enp3s0.link
    Created link configuration context.
    ID_NET_DRIVER=r8169
    Config file /etc/systemd/network/20-enp4s0.link applies to device enp4s0
    link_config: autonegotiation is unset or enabled, the speed and duplex are not writable.
    ID_NET_LINK_FILE=/etc/systemd/network/20-enp4s0.link
    Unload module index
    Unloaded link configuration context.
    Important are the lines:
    * Config file /etc/systemd/network/10-enp3s0.link applies to device enp3s0
    * Config file /etc/systemd/network/20-enp4s0.link applies to device enp4s0

    The configuration of netplan is described here: https://netplan.io/

    I hope no one else has this problem with missing mac address. This is really annoying and cost me 2 days to find out how to solve this problem in a not hacky way. The first solution was the hack, the second is does not look like a hack.
     
    ccs_hello likes this.

Share This Page