]> git.ipfire.org Git - thirdparty/systemd.git/blame - docs/PREDICTABLE_INTERFACE_NAMES.md
network: DHCP version logging typos
[thirdparty/systemd.git] / docs / PREDICTABLE_INTERFACE_NAMES.md
CommitLineData
c3e270f4
FB
1---
2title: Predictable Network Interface Names
a22a4e1d 3category: Networking
b41a3f66 4layout: default
0aff7b75 5SPDX-License-Identifier: LGPL-2.1-or-later
c3e270f4
FB
6---
7
cedf08c7 8# Predictable Network Interface Names
7b1e4518 9
9ed6cf02 10Starting with v197 systemd/udev will automatically assign predictable, stable network interface names for all local Ethernet, WLAN and WWAN interfaces.
11This is a departure from the traditional interface naming scheme (`eth0`, `eth1`, `wlan0`, ...), but should fix real problems.
7b1e4518 12
cedf08c7 13## Why?
7b1e4518 14
9ed6cf02 15The classic naming scheme for network interfaces applied by the kernel is to simply assign names beginning with `eth0`, `eth1`, ... to all interfaces as they are probed by the drivers.
16As the driver probing is generally not predictable for modern technology this means that as soon as multiple network interfaces are available the assignment of the names `eth0`, `eth1` and so on is generally not fixed anymore and it might very well happen that `eth0` on one boot ends up being `eth1` on the next.
17This can have serious security implications, for example in firewall rules which are coded for certain naming schemes, and which are hence very sensitive to unpredictable changing names.
7b1e4518 18
9ed6cf02 19To fix this problem multiple solutions have been proposed and implemented.
20For a longer time udev shipped support for assigning permanent `ethX` names to certain interfaces based on their MAC addresses.
21This turned out to have a multitude of problems, among them: this required a writable root directory which is generally not available; the statelessness of the system is lost as booting an OS image on a system will result in changed configuration of the image; on many systems MAC addresses are not actually fixed, such as on a lot of embedded hardware and particularly on all kinds of virtualization solutions.
22The biggest of all however is that the userspace components trying to assign the interface name raced against the kernel assigning new names from the same `ethX` namespace, a race condition with all kinds of weird effects, among them that assignment of names sometimes failed.
23As a result support for this has been removed from systemd/udev a while back.
6dbee955 24
9ed6cf02 25Another solution that has been implemented is `biosdevname` which tries to find fixed slot topology information in certain firmware interfaces and uses them to assign fixed names to interfaces which incorporate their physical location on the mainboard.
26In a way this naming scheme is similar to what is already done natively in udev for various device nodes via `/dev/*/by-path/` symlinks.
27In many cases, biosdevname departs from the low-level kernel device identification schemes that udev generally uses for these symlinks, and instead invents its own enumeration schemes.
7b1e4518 28
9ed6cf02 29Finally, many distributions support renaming interfaces to user-chosen names (think: `internet0`, `dmz0`, ...) keyed off their MAC addresses or physical locations as part of their networking scripts.
30This is a very good choice but does have the problem that it implies that the user is willing and capable of choosing and assigning these names.
7b1e4518 31
9ed6cf02 32We believe it is a good default choice to generalize the scheme pioneered by `biosdevname`.
33Assigning fixed names based on firmware/topology/location information has the big advantage that the names are fully automatic, fully predictable, that they stay fixed even if hardware is added or removed (i.e. no reenumeration takes place) and that broken hardware can be replaced seamlessly.
34That said, they admittedly are sometimes harder to read than the `eth0` or `wlan0` everybody is used to. Example: `enp5s0`
7b1e4518 35
7b1e4518 36
cedf08c7 37## What precisely has changed in v197?
7b1e4518 38
9ed6cf02 39With systemd 197 we have added native support for a number of different naming policies into systemd/udevd proper and made a scheme similar to biosdevname's (but generally more powerful, and closer to kernel-internal device identification schemes) the default.
40The following different naming schemes for network interfaces are now supported by udev natively:
ee83da3a 41
f9e6d499
ZJS
421. Names incorporating Firmware/BIOS provided index numbers for on-board devices (example: `eno1`)
431. Names incorporating Firmware/BIOS provided PCI Express hotplug slot index numbers (example: `ens1`)
441. Names incorporating physical/geographical location of the connector of the hardware (example: `enp2s0`)
451. Names incorporating the interfaces's MAC address (example: `enx78e7d1ea46da`)
56fbd531
LP
461. Classic, unpredictable kernel-native ethX naming (example: `eth0`)
47
9ed6cf02 48By default, systemd v197 will now name interfaces following policy 1) if that information from the firmware is applicable and available, falling back to 2) if that information from the firmware is applicable and available, falling back to 3) if applicable, falling back to 5) in all other cases.
49Policy 4) is not used by default, but is available if the user chooses so.
ee83da3a 50
9ed6cf02 51This combined policy is only applied as last resort.
52That means, if the system has biosdevname installed, it will take precedence.
53If the user has added udev rules which change the name of the kernel devices these will take precedence too.
54Also, any distribution specific naming schemes generally take precedence.
ee83da3a 55
3c31f15c 56
cedf08c7 57## Come again, what good does this do?
7b1e4518 58
f9e6d499 59With this new scheme you now get:
7b1e4518 60
f9e6d499 61* Stable interface names across reboots
4368c496 62* Stable interface names even when hardware is added or removed, i.e. no re-enumeration takes place (to the level the firmware permits this)
f9e6d499
ZJS
63* Stable interface names when kernels or drivers are updated/changed
64* Stable interface names even if you have to replace broken ethernet cards by new ones
65* The names are automatically determined without user configuration, they just work
66* The interface names are fully predictable, i.e. just by looking at lspci you can figure out what the interface is going to be called
471d407e 67* Fully stateless operation, changing the hardware configuration will not result in changes in `/etc`
f9e6d499 68* Compatibility with read-only root
471d407e 69* The network interface naming now follows more closely the scheme used for aliasing block device nodes and other device nodes in `/dev` via symlinks
f9e6d499
ZJS
70* Applicability to both x86 and non-x86 machines
71* The same on all distributions that adopted systemd/udev
8745120c
LP
72* It's easy to opt out of the scheme (see below)
73
9ed6cf02 74Does this have any drawbacks? Yes, it does.
75Previously it was practically guaranteed that hosts equipped with a single ethernet card only had a single `eth0` interface.
76With this new scheme in place, an administrator now has to check first what the local interface name is before they can invoke commands on it, where previously they had a good chance that `eth0` was the right name.
7b1e4518 77
cedf08c7
JR
78
79## I don't like this, how do I disable this?
80
f9e6d499 81You basically have three options:
cedf08c7 82
e90d48ae 831. You disable the assignment of fixed names, so that the unpredictable kernel names are used again. For this, simply mask udev's .link file for the default policy: `ln -s /dev/null /etc/systemd/network/99-default.link`
931bc195 841. You create your own manual naming scheme, for example by naming your interfaces `internet0`, `dmz0` or `lan0`. For that create your own `.link` files in `/etc/systemd/network/`, that choose an explicit name or a better naming scheme for one, some, or all of your interfaces. See [systemd.link(5)](https://www.freedesktop.org/software/systemd/man/systemd.link.html) for more information.
7c4a7c6d 851. You pass the `net.ifnames=0` on the kernel command line
cedf08c7
JR
86
87## How does the new naming scheme look like, precisely?
88
9ed6cf02 89That's documented in detail the [systemd.net-naming-scheme(7)](https://www.freedesktop.org/software/systemd/man/systemd.net-naming-scheme.html) man page.
90Please refer to this in case you are wondering how to decode the new interface names.