]> git.ipfire.org Git - thirdparty/systemd.git/blame - docs/PredictableNetworkInterfaceNames.moin
(no commit message)
[thirdparty/systemd.git] / docs / PredictableNetworkInterfaceNames.moin
CommitLineData
afce8ff3
LP
1[[http://www.freedesktop.org/wiki/docs/|Back to systemd]]
2
7b1e4518
LP
3= Predictable Network Interface Names =
4
6f99e670 5Starting with v197 systemd/udev will automatically assign predictable, stable network interface names for all local Ethernet, WLAN and WWAN interfaces. This is a departure from the traditional interface naming scheme ("eth0", "eth1", "wlan0", ...), but should fix real problems.
7b1e4518
LP
6
7== Why? ==
8
6f99e670 9The 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. As 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. This 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 10
ee83da3a 11To fix this problem multiple solutions have been proposed and implemented. For a longer time udev shipped support for assigning permanent "ethX" names to certain interfaces based on their MAC addresses. This 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. The 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. As a result support for this has been removed from systemd/udev a while back.
7b1e4518 12
1f6bee93 13Another 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. In a way this naming scheme is similar to what is already done natively in udev for various device nodes via /dev/*/by-path/ symlinks. In 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 14
6f99e670 15Finally, 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. This 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 16
cd6c4dd5 17We believe it is a good default choice to generalize the scheme pioneered by "biosdevname". Assigning 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. That said, they admittedly are sometimes harder to read than the "eth0" or "wlan0" everybody is used to. Example: "enp5s0"
6dbee955 18
b1661148 19== What precisely has changed in v197? ==
7b1e4518 20
13f79279 21With 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. The following different naming schemes for network interfaces are now supported by udev natively:
7b1e4518 22
648f251f
LP
23 1. Names incorporating Firmware/BIOS provided index numbers for on-board devices (example: {{{eno1}}})
24 2. Names incorporating Firmware/BIOS provided PCI Express hotplug slot index numbers (example: {{{ens1}}})
25 3. Names incorporating physical/geographical location of the connector of the hardware (example: {{{enp2s0}}})
26 4. Names incorporating the interfaces's MAC address (example: {{{enx78e7d1ea46da}}})
27 5. Classic, unpredictable kernel-native ethX naming (example: {{{eth0}}})
7b1e4518 28
93aae438 29By 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. Policy 4) is not used by default, but is available if the user chooses so.
7b1e4518 30
e13da0ac 31This combined policy is only applied as last resort. That means, if the system has biosdevname installed, it will take precedence. If the user has added udev rules which change the name of the kernel devices these will take precedence too. Also, any distribution specific naming schemes generally take precedence.
7b1e4518 32
ee83da3a
LP
33== Come again, what good does this do? ==
34
35With this new scheme you now get:
36
d363512c 37 * Stable interface names across reboots
ee83da3a
LP
38 * Stable interface names even when hardware is added or removed, i.e. no re-enumeration takes place
39 * Stable interface names when kernels or drivers are updated/changed
e2f9b633 40 * Stable interface names even if you have to replace broken ethernet cards by new ones
ee83da3a
LP
41 * The names are automatically determined without user configuration, they just work
42 * 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
43 * Fully stateless operation, changing the hardware configuration will not result in changes in /etc
44 * Compatibility with read-only root
45 * The network interface naming now follows more closely the scheme used for aliasing block device nodes and other device nodes in /dev via symlinks
46 * Applicability to both x86 and non-x86 machines
47 * The same on all distributions that adopted systemd/udev
48 * It's easy to opt out of the scheme (see below)
49
7b1e4518
LP
50== I don't like this, how do I disable this? ==
51
52You basically have three options:
53
54 1. You disable the assignment of fixed names, so that the unpredictable kernel names are used again. For this, simply mask udev's rule file for the default policy: {{{ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules}}}
6f99e670 55 2. You create your own manual naming scheme, for example by naming your interfaces "internet0", "dmz0" or "lan0". For that create your own udev rules file and set the NAME property for the devices. Make sure to order it before the default policy file, for example by naming it {{{/etc/udev/rules.d/70-my-net-names.rules}}}
7b1e4518
LP
56 3. You alter the default policy file, for picking a different naming scheme, for example for naming all interface names after their MAC address by default: {{{cp /usr/lib/udev/rules.d/80-net-name-slot.rules /etc/udev/rules.d/80-net-name-slot.rules}}}, then edit the file there and change the lines as necessary.
57
ee83da3a 58== How does the new naming scheme look like, precisely? ==
7b1e4518 59
6f99e670 60That's documented in detail in a comment block [[http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20|the sources of the net_id built-in]]. Please refer to this in case you are wondering how to decode the new interface names.