Changes between Version 2 and Version 3 of ubuntu

02/09/2018 07:48:41 PM (6 years ago)
Tim Harvey

added predictable network interface name section


  • ubuntu

    v2 v3  
    192192udhcpc -i wlan0 # obtain dhcp lease
     197== Predictable Interface Names (systemd/udev) ==
     198The Linux kernel creates Ethernet network interfaces named 'eth<n>' where <n> starts at 0 and increments for each device registered by various drivers. The kernel makes no guarantee that these names remain constant across kernel versions or even power cycles. It is not uncommon for example for USB network interfaces to get registered in an inconsistent fashion between power cycles. It is also not uncommon for a kernel change (ie making a built-in driver be a module instead) to cause interface names move around due to changes in the registration order.
     200To combat this uncertainty a feature referred to as 'Predictable Interface Names' is implemented in Linux distros which use {{{systemd}}} and {{{udev}}}. Specifically this feature has been in {{{udevd}}} since v197. In this case the network interfaces are re-named based on udev rules according to their bus topology. For example under this scheme a PCI based Ethernet network interface on bus 5, slot 0, function 1 would be names 'enp5s0f1'. The best documentation for the naming scheme appears to be the [ udev code comments]
     202Predictable interface names is enabled by default on systems using {{{systemd}}}/{{{udev}}} however you can disable it in a couple of ways:
     203 * pass in a kernel command-line parameter of {{{net.ifnames=0}}}. Note that this is 'not' a kernel feature (thus is independent of what kernel version you are using) but the {{{systemd}}}/{{{udev}}} components that implement this feature look for that on the command-line.
     204 * remove {{{/lib/systemd/network/}}} from the root filesystem.
     206Alternatively you can also create your own {{{link}}} files to name interfaces to your liking. A {{{link}}} file defines matching criteria and link criteria for naming. You can use 'udevadm info <device>' to obtain details that {{{udev}}} knows about devices (ie 'udevadm info /sys/class/net/eth0' or /udevadm info /dev/ttyUSB0'). Your link files should be placed in {{{/etc/systemd/network}}} and should sort before {{{}}} from {{{/lib/systemd/network}}}.
     209- [ Predictable Network Interfaces]
     210- [ systemd link file notation]
     211- [ udev code documenting naming convention]
     212- [ Good Blog article on creating your own link files]
     213- [ Good Blog article about Predictive Interface Names]
     214- net/core/dev.c:dev_change_name - changes name of device by passing strings like "eth%d"