You are not logged in.

#1 2014-06-04 06:17:27

alex.forencich
Member
Registered: 2011-05-29
Posts: 96

How to rename usb<n> to eth<n>

Short version: With udev set to use 'old-style' network card naming (eth0, eth1, wlan0, ...), how do you change cards that init as 'usb<n>' to 'eth<n>'?

Long version: I have a new laptop on the way that doesn't have a wired ethernet card.  However, the work I do requires a wired ethernet card from time to time, and I also have to use software which has a license key tied to the MAC address of eth0 (namely, Altera Quartus and Xilinx ISE).  I found a method for creating a faked-out eth0 that should do the trick (http://jms.id.au/wiki/FakeEth0).  However, now comes the problem of the wired ethernet card.  I have three different USB ethernet cards - one in a docking station on my desk, one for my computer bag, and one for a VM passthrough for a certain piece of test equipment.  Ideally, the faked out card would sit at eth0 and then any of the USB cards should appear as eth1 (or if two cards are connected, eth1 and eth2).  This way, the naming is consistent no matter which card I use and I won't have to reconfigure wicd when I plug in a different adapter as the wired adapter name will always be the same.  Two of them work fine and show up as eth1 when connected.  However, one of the adapters shows up as usb0 instead of eth1.  Every time I switch between this adapter and a different adatper, I will have to reconfigure wicd and point it to the correct card as it only supports controlling a single wired ethernet card at a time.  Is there a way to force this to show up as eth<n> instead of usb<n>?  I really don't want to do a static rename (just rename usb0 to eth1 on connect) because this could cause issues if I happen to have a different card plugged in as eth1 already.  I presume this can be done by modifying the udev rules file 80-net-setup-link.rules, but I can't see any obvious way of implementing this.

Offline

#2 2014-06-06 01:29:49

alex.forencich
Member
Registered: 2011-05-29
Posts: 96

Re: How to rename usb<n> to eth<n>

I have tried a basic rename with udev as a stopgap until a better solution is found, but it does not seem to work.  I added

KERNEL=="usb0", NAME="eth1"

to /etc/udev/rules.d/70-persistent-net.rules, but the device still appears as usb0 when I plug it in.  Any ideas on how to do this properly, aside from modifying the cdc_ncm driver itself?

Last edited by alex.forencich (2014-06-06 01:31:00)

Offline

#3 2014-06-06 01:50:45

alex.forencich
Member
Registered: 2011-05-29
Posts: 96

Re: How to rename usb<n> to eth<n>

Update: Interestingly, that udev rule will actually rename the device correctly on boot, but not if the device is plugged in after boot.  If I boot with the device connected, it comes up as eth1.  If I unplug it and plug it back in, it appears as usb0.  Very odd.

Offline

#4 2014-06-06 22:00:24

J.Martinsson
Member
Registered: 2014-06-06
Posts: 8

Re: How to rename usb<n> to eth<n>

Offline

#5 2014-06-06 22:27:12

alex.forencich
Member
Registered: 2011-05-29
Posts: 96

Re: How to rename usb<n> to eth<n>

Tried that, doesn't work on hotplug; only on boot.

Offline

#6 2014-08-27 08:52:54

silasdavis
Member
Registered: 2013-02-13
Posts: 17

Re: How to rename usb<n> to eth<n>

I'm having a similar probably with a USB NIC

KERNEL=="en*", ATTRS{address}=="xx:xx:xx:xx:xx:xx", NAME="usbnic", RUN+="/etc/udev/rules.d/nic-start.sh"

It comes up as /sys/class/net/enp0s20u1 in sysfs.

This rule works in so much as it fires my script (which actually just writes to a file for test purposes). It doesn't seem to give me a rename though. I'm trying to get ifplugd to start when my USB NIC is attached, which it is singularly failing to do, and I was hoping I might be able to catch it with a later rule once it was named.

Offline

#7 2014-08-27 16:22:53

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: How to rename usb<n> to eth<n>

You could try with a *.link file. This requires systemd-networkd to be running.

Example /etc/systemd/network/90-eth0.link

[Match]
MACAddress=xx:xx:xx:xx:xx:xx

[Link]
Description=Internal Ethernet Card
Name=eth0

R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

Board footer

Powered by FluxBB