User Tools

Site Tools


doc:appunti:linux:sa:if_rename

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:appunti:linux:sa:if_rename [2023/12/15 16:26] niccolodoc:appunti:linux:sa:if_rename [2024/04/12 18:01] (current) – [Debian 9 predictable network interface names] niccolo
Line 3: Line 3:
 ===== With Debian 10 Buster ===== ===== With Debian 10 Buster =====
  
-How to rename a network interface from e.g. **enx00e04c885302** to something more human like **lan0**? +How to rename a network interface from e.g. **enx00e04c885302** to something more human like **lan0**? The preferred method is to create a file **/etc/systemd/network/10-persistent-lan0.link** (one file for each interface to be renamed) with something like this:
- +
-The preferred method is to create a file **/etc/systemd/network/10-persistent-lan0.link** (one file for each interface to be renamed) with something like this:+
  
 <file> <file>
Line 17: Line 15:
 **WARNING**: You cannot use this method to safely assign the default kernel names (''eth0'', ''eth1'', ...) in your preferred order; this is because if systemd tries to rename an interface using a name which is already assigned by the kernel (e.g. it tries to swap ''eth0'' and ''eth1''), it fails. So the target **Name** must not potentially conflict with the names assigned by the kernel. **WARNING**: You cannot use this method to safely assign the default kernel names (''eth0'', ''eth1'', ...) in your preferred order; this is because if systemd tries to rename an interface using a name which is already assigned by the kernel (e.g. it tries to swap ''eth0'' and ''eth1''), it fails. So the target **Name** must not potentially conflict with the names assigned by the kernel.
  
-This method has problem if you need to create a **VLAN**. When the system creates e.g. the **lan.602**, its MAC address matches the systemd snippet, so systemd tries to assign to it the name **lan** but the name already exists, so the interface remains with a temporary name e.g. **rename5**.+**WARNING**: This method has an additional problem if you need to create a **VLAN**. When the system creates e.g. the **lan.602**, its MAC address matches the systemd snippet, so systemd tries to assign to it the name (**lan0** in the example above) but the name already exists, so the interface remains with a temporary name e.g. **rename5**.
  
-A workaround can be the following: tell the kernel to use the old eth0 schema (passing the **net.ifnames=0** option), then instruct systemd to act only on **%%eth*%%** network interfaces:+A workaround can be the following: tell the kernel to use the old ''ethX'' schema (passing the **net.ifnames=0** option), then instruct systemd to act only on **%%eth*%%** network interfaces:
  
 <file> <file>
Line 122: Line 120:
 </file> </file>
  
-**ATTENZIONE**: Pare che **il file con le regole udev viene ignorato** se manca l'opzione **net.ifnames=0** nella cmdline del kernel! Questo almeno è accaduto con Debian 11.7 e kernel 5.10.0-23-amd64.+:!: **ATTENZIONE**: Pare che **il file con le regole udev viene ignorato** se manca l'opzione **net.ifnames=0** nella cmdline del kernel! Questo almeno è accaduto con Debian 11.7 e kernel 5.10.0-23-amd64
 + 
 +:!: **ATTENZIONE**: Il file con le regole udev viene ignorato comunque in **Debian 11**.
  
 ===== Debian 9 Network Interface Naming ===== ===== Debian 9 Network Interface Naming =====
doc/appunti/linux/sa/if_rename.1702653962.txt.gz · Last modified: 2023/12/15 16:26 by niccolo