User Tools

Site Tools


operating_systems:linux:debian:interface_name

Differences

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

Link to this comparison view

Next revision
Previous revision
operating_systems:linux:debian:interface_name [2017/10/30 09:18] – created kroduitoperating_systems:linux:debian:interface_name [2022/02/01 13:34] (current) ateixeira
Line 3: Line 3:
  
 With stretch, this problem is more complex, we have to work with the [[https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/|predictable network interface name]].\\ With stretch, this problem is more complex, we have to work with the [[https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/|predictable network interface name]].\\
-physical:eth0 is debian:enp4s0\\  +<code>Left: physical / rightDebian 9 NIC 
-physical:eth1 is debian:enp3s0\\  +eth0 enp4s0 
-physical:eth2 is debian:enp020f0\\  +eth1 enp3s0 
-physical:eth3 is debian:enp020f1\\  +eth2 enp020f0 
-physical:eth4 is debian:enp020f2\\  +eth3 enp020f1 
-physical:eth5 is debian:enp0s20f3\\ +eth4 enp020f2 
 +eth5 enp0s20f3</code>
  
 It's really annoying and we have to fix it (inspired by this [[http://ask.xmodulo.com/change-network-interface-names-permanently-linux.html|article]]).\\  It's really annoying and we have to fix it (inspired by this [[http://ask.xmodulo.com/change-network-interface-names-permanently-linux.html|article]]).\\ 
 For more security, we match the PCI id and the MAC address. Informations below are for the netgate 4860 (centrale 3540). I think you have to check your hardware because it can change over time. For more security, we match the PCI id and the MAC address. Informations below are for the netgate 4860 (centrale 3540). I think you have to check your hardware because it can change over time.
  
-  - Getting the PCI ID and MAC address for each interface.<code>udevadm info -e | grep -A 5 -B 18 "INTERFACE=enp"</code>The result should look like:<code>[...]+  - Getting the PCI ID and MAC address for each interface.<code>udevadm info -e | grep -A 5 -B 18 "INTERFACE=enp" #Stretch 
 +udevadm info -e | grep -A 5 -B 18 "INTERFACE=eth" #Jessie</code>The result should look like:<code>[...]
 P: /devices/pci0000:00/0000:00:14.1/net/enp0s20f1 P: /devices/pci0000:00/0000:00:14.1/net/enp0s20f1
 E: DEVPATH=/devices/pci0000:00/0000:00:14.1/net/enp0s20f1 E: DEVPATH=/devices/pci0000:00/0000:00:14.1/net/enp0s20f1
Line 37: Line 39:
 E: USEC_INITIALIZED=4244300 E: USEC_INITIALIZED=4244300
 [...]</code> [...]</code>
-  - Add rules for the interface name.<code>vim /lib/udev/rules.d/70-persistent-net.rules</code>In my case, the file is the following, but you need to adapt to your configuration.\\ = is for matching, == is for assignation.\\ Don't use the format with [Match] & [Link]. It's seem to be out of date and doesn't work with systemd.<code>SUBSYSTEM=="net", KERNELS=="0000:04:00.0", ATTR{address}=="00:08:a2:0c:b2:xx", NAME="eth0+  - Add rules for the interface name.<code>vim /lib/udev/rules.d/70-persistent-net.rules</code>In my case, the file is the following, but you need to adapt to your configuration.\\ = is for matching, == is for assignation.\\ Don't use the format with [Match] & [Link]. It's seem to be out of date and doesn't work with systemd.<code>SUBSYSTEM=="net", KERNELS=="0000:04:00.0", ATTR{address}=="00:08:a2:0c:b2:xx", NAME="lan0
-SUBSYSTEM=="net", KERNELS=="0000:03:00.0", ATTR{address}=="00:08:a2:0c:b2:xx", NAME="eth1+SUBSYSTEM=="net", KERNELS=="0000:03:00.0", ATTR{address}=="00:08:a2:0c:b2:xx", NAME="lan1
-SUBSYSTEM=="net", KERNELS=="0000:00:14.0", ATTR{address}=="00:08:a2:0c:b2:xx", NAME="eth2+SUBSYSTEM=="net", KERNELS=="0000:00:14.0", ATTR{address}=="00:08:a2:0c:b2:xx", NAME="lan2
-SUBSYSTEM=="net", KERNELS=="0000:00:14.1", ATTR{address}=="00:08:a2:0c:b2:xx", NAME="eth3+SUBSYSTEM=="net", KERNELS=="0000:00:14.1", ATTR{address}=="00:08:a2:0c:b2:xx", NAME="lan3
-SUBSYSTEM=="net", KERNELS=="0000:00:14.2", ATTR{address}=="00:08:a2:0c:b2:xx", NAME="eth4+SUBSYSTEM=="net", KERNELS=="0000:00:14.2", ATTR{address}=="00:08:a2:0c:b2:xx", NAME="lan4
-SUBSYSTEM=="net", KERNELS=="0000:00:14.3", ATTR{address}=="00:08:a2:0c:b2:xx", NAME="eth5"</code>+SUBSYSTEM=="net", KERNELS=="0000:00:14.3", ATTR{address}=="00:08:a2:0c:b2:xx", NAME="lan5"</code> 
 +  - **Only for Jessie (and lower?)**: remove the existing udev rules in /etc and prevent the file generation on next reboot.<code> 
 +echo "# disable net-generator rules in /lib/udev" > /etc/udev/rules.d/75-persistent-net-generator.rules 
 +rm /etc/udev/rules.d/70-persistent-net.rules</code>
   - Adapt interfaces list (specific to your installation).<code>vim /etc/network/interfaces</code><code>[...]   - Adapt interfaces list (specific to your installation).<code>vim /etc/network/interfaces</code><code>[...]
 allow-hotplug eth1 allow-hotplug eth1
-iface eth1 inet dhcp+iface lan1 inet dhcp
 [...]</code> [...]</code>
   - Reboot<code>reboot</code>   - Reboot<code>reboot</code>
   - And check results.<code>ip a</code>   - And check results.<code>ip a</code>
   - Check the correspondence between NIC label and physical label.<code>tail -f /var/log/syslog | grep kernel</code>Connect and disconnect (physically) and check the corresponding line.<code>[...]   - Check the correspondence between NIC label and physical label.<code>tail -f /var/log/syslog | grep kernel</code>Connect and disconnect (physically) and check the corresponding line.<code>[...]
-Oct 30 10:11:50 3540 kernel: [  129.120407] igb 0000:04:00.0 eth0: igb: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX/TX +Oct 30 10:11:50 3540 kernel: [  129.120407] igb 0000:04:00.0 lan0: igb: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX/TX 
-Oct 30 10:11:52 3540 kernel: [  131.774607] igb 0000:04:00.0 eth0: igb: eth0 NIC Link is Down +Oct 30 10:11:52 3540 kernel: [  131.774607] igb 0000:04:00.0 lan0: igb: eth0 NIC Link is Down 
-[...]</code> +[...]</code> 
 +  - If you have some trouble, you can add log.<code>vim /etc/udev/udev.conf</code><code>udev_log="debug"</code>But don't forget to remove after your fixing. 
 + 
 +<note tip>Why interface name suggested are lanX instead of ethX?</note> 
 +I've made some tests with debian 8 and i encounter this problem:\\  
 +If i comment 1 line in udev rules (for example eth4), eth4 retrieve his old default name (eth2) and eth2 get the name "rename". In this case, eth2 physical become eth4 and this is unsafe. For preventing this (and preventing a wrong naming when an interface is out of order), interface name is lanX.\\  
 +If i comment the lan4 line in udev rules, lan4 (eth4 physical) become eth2, but lan2 stay lan2 and eth4 physical simply doesn't work because /etc/network/interfaces doesn't content ethX declarations. 
 + 
 + ====== Changing raspbian 9.9 (stretch) interface name ====== 
 +[[https://askubuntu.com/questions/947519/ubuntu-17-04-how-to-rename-a-usb-network-interface-based-on-path-not-based-on|source]] 
 + 
 +found Path and MAC address 
 +<code> 
 +ifconfig 
 +udevadm info -e | grep -A 5 -B 18 "INTERFACE=eth" 
 +</code> 
 + 
 +add files like 1x-lanx.link in /etc/systemd/network/ with rules like : 
 +<code> 
 +[Match] 
 +Path=<id_path> 
 +MACAddress=00:e0:4c:36:01:6b 
 + 
 +[Link] 
 +Name=lan0 
 +</code> 
 + 
 + 
 +<note important>To get the id_path type: udevadm info /sys/class/net/<network interface name></note> 
 + 
 +add file 99-default.link in /etc/systemd/network/ with rules like : 
 +<code> 
 +[Link] 
 +NamePolicy=kernel database onboard slot path 
 +MACAddressPolicy=persistent 
 +</code> 
 + 
 +to permit user-defined name of USB network interfaces, it's necessary to enable the 80-net-setup-link.rules rule with this command :  
 +<code> 
 +sudo ln -s /lib/udev/rules.d/80-net-setup-link.rules /etc/udev/rules.d/80-net-setup-link.rules 
 +</code> 
 + 
 + ====== Changing debian 11.1 (bullseye) interface name ====== 
 + 
 +found ID_PATH and MAC address 
 +<code> 
 +udevadm info -e | grep -A 5 -B 18 "INTERFACE=<interface name>" 
 +ip a 
 +</code> 
 + 
 +edit files like 1x-lanx.link in /etc/systemd/network/ with rules like : 
 +<code> 
 +[Match] 
 +Path=<id_path> 
 +MACAddress=00:e0:4c:36:01:6b 
 + 
 +[Link] 
 +Name=lan0 
 +</code> 
 + 
 +make sure file 99-default.link is present in /etc/systemd/network/ with rules like : 
 +<code> 
 +[Link] 
 +NamePolicy=kernel database onboard slot path 
 +MACAddressPolicy=persistent 
 +</code> 
 + 
 +to permit user-defined name of USB network interfaces, it's necessary to enable the 80-net-setup-link.rules rule with this command :  
 +<code> 
 +sudo ln -s /lib/udev/rules.d/80-net-setup-link.rules /etc/udev/rules.d/80-net-setup-link.rules 
 +</code>
operating_systems/linux/debian/interface_name.1509355122.txt.gz · Last modified: 2017/10/30 09:18 by kroduit