# [solved] Rename enp0s29u1 to enp0s20u1

## grant123

How can I have network interface enp0s29u1u1 renamed to enp0s20u1 at boot?Last edited by grant123 on Sun Aug 24, 2014 4:47 pm; edited 1 time in total

----------

## VoidMage

 *grant123 wrote:*   

> How can I have network interface enp0s29u1u1 renamed to enp0s20u1 at boot?

 

...and the point of doing that would be ?

----------

## grant123

It's so I can use a script I've written with all of my laptops instead of with most of them.

----------

## John R. Graham

Ah, the benefits of "predictable network naming". Why not rename them both to something more sensible, like "net0" or even disable the new mechanisms and let them go back to the traditional "eth0"? Search "predictable network names" and you will find the solution stated many times over.

- John

----------

## VoidMage

Why not make use of the same command noted in udev's pkg_postinst notes ?

----------

## grant123

 *John R. Graham wrote:*   

> Ah, the benefits of "predictable network naming". Why not rename them both to something more sensible, like "net0" or even disable the new mechanisms and let them go back to the traditional "eth0"? Search "predictable network names" and you will find the solution stated many times over.

 

I like the new functionality because I can plug various network interfaces into the same USB port and always end up with the same device name.  Are you referring to the /etc/udev/rules.d/ files?  I'm working on that now.

 *VoidMage wrote:*   

> Why not make use of the same command noted in udev's pkg_postinst notes ?

 

I just read through it but I don't see a command like that.

----------

## grant123

The solutions I can find online require me to specify the network adapter's MAC address in the udev rule, but I'm looking for something that will rename based on where it is plugged in (or based on the default name).  Can this be done?

----------

## Hu

 *grant123 wrote:*   

> How can I have network interface enp0s29u1u1 renamed to enp0s20u1 at boot?

 Move the network card from PCI slot 29 to PCI slot 20.  Unfortunately, this may be difficult or warranty-voiding on laptop hardware.  Your problem is that you are allowing udev to name it based on where it is plugged in.

----------

## Ant P.

 *Hu wrote:*   

>  *grant123 wrote:*   How can I have network interface enp0s29u1u1 renamed to enp0s20u1 at boot? Move the network card from PCI slot 29 to PCI slot 20.  Unfortunately, this may be difficult or warranty-voiding on laptop hardware.  Your problem is that you are allowing udev to name it based on where it is plugged in.

 

...and reprogram its firmware so the card appears as a flat topology instead of a sub-device. I'm assuming that's the reason for the double "u1u1" on the end.

----------

## grant123

 *Hu wrote:*   

> Move the network card from PCI slot 29 to PCI slot 20.  Unfortunately, this may be difficult or warranty-voiding on laptop hardware.  Your problem is that you are allowing udev to name it based on where it is plugged in.

 

I'm trying to rename USB device enp3s0u1 to enp0s20u1 so it works with my script.  I like having my interfaces named based on their location, but I want to be able to override that in certain situations like this one.  Can I do that?

----------

## VoidMage

 *grant123 wrote:*   

>  *Hu wrote:*   Move the network card from PCI slot 29 to PCI slot 20.  Unfortunately, this may be difficult or warranty-voiding on laptop hardware.  Your problem is that you are allowing udev to name it based on where it is plugged in. 
> 
> I'm trying to rename USB device enp3s0u1 to enp0s20u1 so it works with my script.  I like having my interfaces named based on their location, but I want to be able to override that in certain situations like this one.  Can I do that?

 

 :Rolling Eyes:  Of course you can - it's just not a good idea to do so or rather a wrong approach to getting a good solution.

You do know where those names come from, right ?

Before, I was referring to the line 

```
udevadm test-builtin net_id /sys/class/net/<ifname> 2> /dev/null
```

Of course, by the time udev rules had ran, it won't be much help, but as you're scripting something anyway, you could  - for example - check the content of /sys/class/net/ and based on the output 'udevadm test-builtin net_id' identify the one you're interested in.

----------

## grant123

It's probably obvious but I'm not getting it.  It's been a long day.  Can udevadm rename a network interface?  If not, what should I use it for?

----------

## Roman_Gruber

It seems the posters above try to tell you that you should determine your network interface name on these commands and than use the output of that for your scripts. 

Sidenote, I dislike those new naming scheme and when you use a script anyway a proper approach is to search for a defined pattern for your device and than use that device in your script. some things wont change like MAC and therfore you should be able to write your script.

I also agree with the posters above that a human readable format like net0 is something preferable as some numbers and letters name which is hard to remember. ...

----------

## grant123

 *tw04l124 wrote:*   

> It seems the posters above try to tell you that you should determine your network interface name on these commands and than use the output of that for your scripts.

 

The udevadm command above takes the interface name as input, but maybe there's another udevadm command that lists all interface names?  But this strategy breaks down if there are multiple connected interfaces since I wouldn't know which is which.

 *tw04l124 wrote:*   

> Sidenote, I dislike those new naming scheme and when you use a script anyway a proper approach is to search for a defined pattern for your device and than use that device in your script. some things wont change like MAC and therfore you should be able to write your script.

 

I want my USB network interfaces to be interchangeable so I don't have to keep track of which interface goes with which laptop.  What I really want to be able to do is define names for interfaces keyed on the interface location instead of the interface MAC address.

I was able to get this udev rule to execute:

```
SUBSYSTEM=="net", KERNEL=="enp3s0u1", NAME="net0"
```

But it doesn't happen automatically at boot, I have to execute this command:

```
udevadm trigger --action=add
```

How can I execute that command before the /etc/init.d/net.* scripts run?

----------

## Roman_Gruber

I think you should search for a way to add it as a separate service or make a rule that it is loaded at the proper way before you start your network.

----------

## grant123

I'd rather not write an initscript for it.  How would that rule be set up?

----------

## grant123

Here's the solution:

```
SUBSYSTEM=="net", ACTION=="add", ENV{ID_NET_NAME_PATH}=="enp3s0u1", NAME="net0"
```

https://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=4&chap=2#doc_chap4

----------

## Roman_Gruber

```
menuentry ' title ' --class gento --class gnu-linux --class gnu --class os {

 linux /kernel-name init=linuxrc ramdisk=8192 crypt_root=dev/mapper/abc realroot=/dev/mapper/cde dolvm net.ifnames=0

 initrd /initramfs-genkernel-x86_64-3.5.3-gentoo_Sept_2012

}
```

I do not know if it was already mentioned but if you want the old behaviour you just need to add net.ifnames=0, as you can see on the example above which I personally use atm in my grub.cfg

----------

## grant123

I can't go with the old behavior because I want to define network device names based on location instead of MAC address.

----------

