Usb to ethernet modules

Hi there, that’s a good indication that UDEV is at least functioning in the container. Next, you could try a very generic rule along the lines of:

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="testudev"

You should try with one USB device plugged in, after you establish its MAC address and substitute it into ATTR{address}=="...". This match is case sensitive.

Some more information may be useful here, specifically under the Network interfaces section.

Thank you.
made some progress but i’m missing something (i know now better about udev, but still a beginner) - its still not working, and i keep seeing “eth1” instead of the testudev name.
this is the rule (its located in /etc/dev/rules.d/ethernet.rules):
SUBSYSTEM==“net”, ACTION==“add”, ATTR{address}==“00:e0:4c:68:1e:1d”, NAME=“testudev”
this is ifconfig output (the usb to ethernet only):
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::dfd2:5e82:b0a8:b0e3 prefixlen 64 scopeid 0x20
ether 00:e0:4c:68:1e:1d txqueuelen 1000 (Ethernet)
RX packets 95 bytes 5700 (5.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0

this is the udevadm monitor — environment output now (it wasnt on network_mode:host, thats why no net events):

monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[975.118495] remove /devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.0/net/eth1/queues/rx-0 (queues)
KERNEL[975.118613] remove /devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.0/net/eth1/queues/tx-0 (queues)
KERNEL[975.118679] remove /devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.0/net/eth1 (net)
KERNEL[975.136393] remove /devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.0 (usb)
KERNEL[975.138947] remove /devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2 (usb)
KERNEL[980.290034] add /devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2 (usb)
KERNEL[980.291392] add /devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:2.0 (usb)
KERNEL[980.292157] add /devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:2.1 (usb)
KERNEL[980.292613] remove /devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:2.0 (usb)
KERNEL[980.292718] remove /devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:2.1 (usb)
KERNEL[980.293395] add /devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.0 (usb)
KERNEL[980.533042] add /devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.0/net/eth1 (net)
KERNEL[980.533186] add /devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.0/net/eth1/queues/rx-0 (queues)
KERNEL[980.537165] add /devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.0/net/eth1/queues/tx-0 (queues)

Hi, we can’t see anything wrong with the rule you posted. I just tested this solution Rename network interface renaming the network interface using config.json on the host OS and it worked for me after a reboot of the device, so it might be worth trying that simpler approach rather than attempting to do this from the container.

If you want to continue debugging your existing solution, can you double check the quoted characters as mentioned by Anton above which were incorrect in an earlier example, and also I assume you rebooted the device?

worked with changing the config.json like here:

“udevRules”: { “10” : “SUBSYSTEM==“net”, ACTION==“add”, ATTR{address}==“00:00:00:00:00:00”, NAME=“testudev”” }
but i have a followup question regarding this.
we are planned to manufacture thousands of systems this year, and in the manufacturing process we will have two identical USB to Ethernet modules on our board, and i’m not sure how to solve it in the assembly line, how can i guaranty that i will always have permanent ethernet device names? since now the rule is mac address based, i wont be able to do the same on assembly line.

Hello, just to clarify, so far the issue is solved if you know the mac address of the usb-to-ethernet dongle? If so then I’d suggest having an initial setup logic in your application where in that step you get the mac addresses of the plugged dongles, create the udev rules you want based on these mac addresses. This process should happen once.

create the udev inside the container you mean, right? (now i’ve changed it directly in the config.json)

so the flow you suggest is:

  1. on first time, if no udev rules, create them according to the mac address of the usb to Ethernet in the container with privileged permissions
  2. reboot device is needed, no? (will the rules will stay after reboot?)

yes I think if it is to productise this, adding udev rules from inside the container makes sense. Yes about 1. and experimenting with 2. might answer if a reboot is needed. Maybe save everything in a state file, if the setup is complete, what rules should be on the device etc.

when i tried it directly from a config.json a reboot was needed, ill try and update here.