# USB ethernet not named eth1 on rpi4

**URL:** <https://forums.balena.io/t/usb-ethernet-not-named-eth1-on-rpi4/50611>\
**Category:** Product support\
**Created:** [December 11, 2019, 7:25pm UTC](https://forums.balena.io/t/usb-ethernet-not-named-eth1-on-rpi4/50611 "2019-12-11T19:25:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xyala](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/xyala/32/632_2.png) [@xyala](https://forums.balena.io/u/xyala)\
**Post date:** [December 11, 2019, 7:25pm UTC](https://forums.balena.io/t/usb-ethernet-not-named-eth1-on-rpi4/50611/1 "2019-12-11T19:25:15Z")

</div>

Hi there,

I’ve been recently playing with a RPI3 and the Amazon basic USB gigabit ethernet adapter.  
It works well. Automatically detects as eth1 interface.  
Result from: nmcli d

```
DEVICE TYPE STATE CONNECTION         
eth0 ethernet connected Wired connection 1 
supervisor0 bridge connected supervisor0        
eth1 ethernet connected eth1               
wlan0 wifi disconnected --                 
balena0 bridge unmanaged --                 
br-723d1e15cb31 bridge unmanaged --                 
resin-dns bridge unmanaged --                 
lo loopback unmanaged --                 
resin-vpn tun unmanaged --                       

```

Now, on my RPI4, the behavior is different.  
Result from: nmcli d

```
DEVICE TYPE STATE CONNECTION         
eth0 ethernet connected Wired connection 2 
supervisor0 bridge connected supervisor0        
enp1s0u2 ethernet connecting (getting IP configuration) Wired connection 1 
wlan0 wifi disconnected --                 
balena0 bridge unmanaged --                 
br-aaf04606d358 bridge unmanaged --                 
resin-dns bridge unmanaged --                 
veth7449af8 ethernet unmanaged --                 
lo loopback unmanaged --                 
resin-vpn tun unmanaged --

```

Ideally I’d like it to appear directly as eth1 so it works well with some of the configsI’m using etc (same base code is going to run on Pi3 and Pi4).

Question is why not eth1 straight like on the rpi3, and how to change this?  
Thanks!

---

<div class="post-metadata">

**Author:** ![pdcastro](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pdcastro/32/1264_2.png) [@pdcastro](https://forums.balena.io/u/pdcastro)\
**Post date:** [December 11, 2019, 8:19pm UTC](https://forums.balena.io/t/usb-ethernet-not-named-eth1-on-rpi4/50611/3 "2019-12-11T20:19:27Z")

</div>

Out of interest, were you running the same version of balenaOS on both devices? (RPi3 and RPi4) Which version exactly?

I’ve found this other thread where the network interface is renamed through an udev rule, which sounds promising: [Rename network interface](https://forums.balena.io/t/rename-network-interface/31822)

And also this other page (not balena specific) where they mention that a network interface could be renamed through a NetworkManager connection profile (`nmcli connection modify ...`): [https://www.thegeekdiary.com/how-to-set-a-custom-interface-name-with-networkmanager-in-centos-rhel-7/](https://www.thegeekdiary.com/how-to-set-a-custom-interface-name-with-networkmanager-in-centos-rhel-7/)

Perhaps you could try one of these approaches and let us know how it goes? 🙂

---

<div class="post-metadata">

**Author:** ![xyala](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/xyala/32/632_2.png) [@xyala](https://forums.balena.io/u/xyala)\
**Post date:** [December 11, 2019, 8:38pm UTC](https://forums.balena.io/t/usb-ethernet-not-named-eth1-on-rpi4/50611/5 "2019-12-11T20:38:03Z")

</div>

RPI3 is balenaOS 2.43.0+rev1  
And  
RPI4 is balenaOS 2.41.0+rev4

I believe each are the latest recommended production ones.

Thanks for sharing these methods. I’m wondering - which would be the recommended on? And how can I have these executed automatically on the first device boot up. So nobody has to go-in each time to set it right.

---

<div class="post-metadata">

**Author:** ![pdcastro](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pdcastro/32/1264_2.png) [@pdcastro](https://forums.balena.io/u/pdcastro)\
**Post date:** [December 12, 2019, 1:40am UTC](https://forums.balena.io/t/usb-ethernet-not-named-eth1-on-rpi4/50611/7 "2019-12-12T01:40:08Z")

</div>

@xyala, I’ve now successfully tested the udev method as follows.

First, I was able to reproduce the `enp1s0u2` interface name with a USB-Ethernet adapter, using an RPi4 device running balenaOS 2.44.0+rev3:

```nohighlight
$ dmesg
...
[394.126615] ax88179_178a 2-2:1.0 eth1: register 'ax88179_178a' at usb-0000:01:00.0-2, ASIX AX88179 USB 3.0 Gigabit Ethernet, 00:0e:c6:aa:cb:79
[394.154992] ax88179_178a 2-2:1.0 enp1s0u2: renamed from eth1

```

Note the last line above: `enp1s0u2: renamed from eth1`. Colleagues have pointed out that this appears to be the “Predictable Network Interface Names” feature; some references: [ref1](https://wiki.debian.org/NetworkInterfaceNames), [ref2](https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/), [ref3](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-understanding_the_predictable_network_interface_device_names).

Then I edited the `config.json` file (on the root of the SD card) to add an udev rule to rename the interface to `newname1`:

```json
  "os":{
   "udevRules": { "10" : "SUBSYSTEM==\"net\", ACTION==\"add\", ATTR{address}==\"00:0e:c6:aa:cb:79\", NAME=\"newname1\"" }
  },

```

This rule matches on the MAC address of my network interface (`00:0e:c6:aa:cb:79`), but it should be possible to write a rule that matches on vendor and product IDs listed with `lsusb -v`, in case you wanted to write a single rule for all devices in your fleet. More on udev rules: [ref4](http://reactivated.net/writing_udev_rules.html), [ref5](https://medium.com/swlh/hot-plugging-usb-devices-in-balenaos-5dca4b05ca7e), [ref6](https://forums.balena.io/t/custom-udev-rules/2415).

Then I created a single-container (‘main’) balena app with this trivial Dockerfile:

```auto
FROM balenalib/raspberrypi3:stretch
ENV UDEV=1
CMD ["/bin/bash"]

```

In my experiment, it was important to use a balenalib base image (in the `FROM` Dockerfile line) because then my Dockerfile “inherits” the default `ENTRYPOINT ["/usr/bin/entry.sh"]` instruction; references: [ref7](https://www.balena.io/docs/reference/base-images/base-images/#how-the-images-work-at-runtime), [ref8](https://hub.docker.com/r/balenalib/raspberrypi3).

Then after pushing the app and rebooting the device, the interface was renamed to `newname1`, as per udev rule:

```auto
$ dmesg
[7.996531] ax88179_178a 2-2:1.0 eth1: register 'ax88179_178a' at usb-0000:01:00.0-2, ASIX AX88179 USB 3.0 Gigabit Ethernet, 00:0e:c6:aa:cb:79
[8.103277] ax88179_178a 2-2:1.0 newname1: renamed from eth1

$ ifconfig
...
newname1 Link encap:Ethernet HWaddr 00:0E:C6:AA:CB:79
          UP BROADCAST MULTICAST MTU:1500 Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

```
