Changes between Version 2 and Version 3 of ubuntu


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

added predictable network interface name section

Legend:

Unmodified
Added
Removed
Modified
  • ubuntu

    v2 v3  
    192192udhcpc -i wlan0 # obtain dhcp lease
    193193}}}
     194
     195
     196[=#predictable-interface-names]
     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.
     199
     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 [https://github.com/systemd/systemd/blob/master/src/udev/udev-builtin-net_id.c#L20 udev code comments]
     201
     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/99-default.link}}} from the root filesystem.
     205
     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 {{{99-default.link}}} from {{{/lib/systemd/network}}}.
     207
     208References:
     209- [https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/ Predictable Network Interfaces]
     210- [https://www.freedesktop.org/software/systemd/man/systemd.link.html systemd link file notation]
     211- [https://github.com/systemd/systemd/blob/master/src/udev/udev-builtin-net_id.c#L20 udev code documenting naming convention]
     212- [https://major.io/2016/01/20/tinkering-with-systemds-predictable-network-names/ Good Blog article on creating your own link files]
     213- [https://major.io/2015/08/21/understanding-systemds-predictable-network-device-names/ 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"