]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd.net-naming-scheme.xml
Merge pull request #14105 from keszybz/man-directives-cleanup
[thirdparty/systemd.git] / man / systemd.net-naming-scheme.xml
CommitLineData
0b1e5b6e
ZJS
1<?xml version='1.0'?>
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4<!-- SPDX-License-Identifier: LGPL-2.1+ -->
5
6<refentry id="systemd.net-naming-scheme">
7 <refentryinfo>
8 <title>systemd.net-naming-scheme</title>
9 <productname>systemd</productname>
10 </refentryinfo>
11
12 <refmeta>
13 <refentrytitle>systemd.net-naming-scheme</refentrytitle>
14 <manvolnum>7</manvolnum>
15 </refmeta>
16
17 <refnamediv>
18 <refname>systemd.net-naming-scheme</refname>
19 <refpurpose>Network device naming schemes</refpurpose>
20 </refnamediv>
21
22 <refsect1>
23 <title>Description</title>
24
2ebe027b
ZJS
25 <para>Network interfaces names and MAC addresses may be generated based on certain stable interface
26 attributes. This is possible when there is enough information about the device to generate those
27 attributes and the use of this information is configured. This page describes interface naming, i.e. what
28 possible names may be generated. Those names are generated by the
0b1e5b6e
ZJS
29 <citerefentry><refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
30 builtin <command>net_id</command> and exported as udev properties
31 (<varname>ID_NET_NAME_ONBOARD=</varname>, <varname>ID_NET_LABEL_ONBOARD=</varname>,
32 <varname>ID_NET_NAME_PATH=</varname>, <varname>ID_NET_NAME_SLOT=</varname>).</para>
33
2ebe027b
ZJS
34 <para>Names and MAC addresses are derived from various stable device metadata attributes. Newer versions
35 of udev take more of these attributes into account, improving (and thus possibly changing) the names and
36 addresses used for the same devices. Different versions of those generation rules are called "naming
37 schemes". The default naming scheme is chosen at compilation time. Usually this will be the latest
38 implemented version, but it is also possible to set one of the older versions to preserve
39 compatibility. This may be useful for example for distributions, which may introduce new versions of
d238709c 40 systemd in stable releases without changing the naming scheme. The naming scheme may also be overridden
2ebe027b 41 using the <varname>net.naming-scheme=</varname> kernel command line switch, see
0b1e5b6e
ZJS
42 <citerefentry><refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
43 Available naming schemes are described below.</para>
44
ce6304f7 45 <para>After the udev properties have been generated, appropriate udev rules may be used to actually rename
2ebe027b
ZJS
46 devices based on those properties. See the description of <varname>NamePolicy=</varname> and
47 <varname>MACAddressPolicy=</varname> in
48 <citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
0b1e5b6e
ZJS
49 </refsect1>
50
51 <refsect1>
52 <title>Naming</title>
53
54 <para>All names start with a two-character prefix that signifies the interface type.</para>
55
56 <table>
57 <title>Two character prefixes based on the type of interface</title>
58
59 <tgroup cols='2'>
60 <thead>
61 <row>
62 <entry>Prefix</entry>
63 <entry>Description</entry>
64 </row>
65 </thead>
66 <tbody>
67 <row>
68 <entry><constant>en</constant></entry>
69 <entry>Ethernet</entry>
70 </row>
71 <row>
72 <entry><constant>ib</constant></entry>
73 <entry>InfiniBand</entry>
74 </row>
75 <row>
76 <entry><constant>sl</constant></entry>
77 <entry>serial line IP (slip)</entry>
78 </row>
79 <row>
80 <entry><constant>wl</constant></entry>
81 <entry>Wireless local area network (WLAN)</entry>
82 </row>
83 <row>
84 <entry><constant>ww</constant></entry>
85 <entry>Wireless wide area network (WWAN)</entry>
86 </row>
87 </tbody>
88 </tgroup>
89 </table>
90
91 <para>The udev <command>net_id</command> builtin exports the following udev device properties:</para>
92
93 <variablelist>
94 <varlistentry>
95 <term><varname>ID_NET_NAME_ONBOARD=<replaceable>prefix</replaceable><constant>o</constant><replaceable>number</replaceable></varname></term>
96
97 <listitem><para>This name is set based on the ordering information given by the firmware for
98 on-board devices. The name consists of the prefix, letter <constant>o</constant>, and a number
99 specified by the firmware. This is only available for PCI devices.</para>
100 </listitem>
101 </varlistentry>
102
103 <varlistentry>
104 <term><varname>ID_NET_LABEL_ONBOARD=<replaceable>prefix</replaceable> <replaceable>label</replaceable></varname></term>
105
106 <listitem><para>This property is set based on label given by the firmware for on-board devices. The
107 name consists of the prefix concatenated with the label. This is only available for PCI devices.
108 </para>
109 </listitem>
110 </varlistentry>
111
112 <varlistentry>
113 <term><varname>ID_NET_NAME_MAC=<replaceable>prefix</replaceable><constant>x</constant><replaceable>AABBCCDDEEFF</replaceable></varname></term>
114
115 <listitem><para>This name consists of the prefix, letter <constant>x</constant>, and 12 hexadecimal
116 digits of the MAC address. It is available if the device has a fixed MAC address. Because this name
117 is based on an attribute of the card itself, it remains "stable" when the device is moved (even
118 between machines), but will change when the hardware is replaced.</para>
119 </listitem>
120 </varlistentry>
121
122 <varlistentry>
123 <term><varname>ID_NET_NAME_SLOT=<replaceable>prefix</replaceable>[<constant>P</constant><replaceable>domain</replaceable>]<constant>s</constant><replaceable>slot</replaceable>[<constant>f</constant><replaceable>function</replaceable>][<constant>n</constant><replaceable>port_name</replaceable>|<constant>d</constant><replaceable>dev_port</replaceable>]</varname></term>
124 <term><varname>ID_NET_NAME_SLOT=<replaceable>prefix</replaceable>[<constant>P</constant><replaceable>domain</replaceable>]<constant>s</constant><replaceable>slot</replaceable>[<constant>f</constant><replaceable>function</replaceable>][<constant>n</constant><replaceable>port_name</replaceable>|<constant>d</constant><replaceable>dev_port</replaceable>]<constant>b</constant><replaceable>number</replaceable></varname></term>
125 <term><varname>ID_NET_NAME_SLOT=<replaceable>prefix</replaceable>[<constant>P</constant><replaceable>domain</replaceable>]<constant>s</constant><replaceable>slot</replaceable>[<constant>f</constant><replaceable>function</replaceable>][<constant>n</constant><replaceable>port_name</replaceable>|<constant>d</constant><replaceable>dev_port</replaceable>]<constant>u</constant><replaceable>port</replaceable>…[<constant>c</constant><replaceable>config</replaceable>][<constant>i</constant><replaceable>interface</replaceable>]</varname></term>
126 <term><varname>ID_NET_NAME_SLOT=<replaceable>prefix</replaceable>[<constant>P</constant><replaceable>domain</replaceable>]<constant>s</constant><replaceable>slot</replaceable>[<constant>f</constant><replaceable>function</replaceable>][<constant>n</constant><replaceable>port_name</replaceable>|<constant>d</constant><replaceable>dev_port</replaceable>]<constant>v</constant><replaceable>slot</replaceable></varname></term>
127
128 <listitem><para>This property describes the slot position. Different schemes are used depending on
129 the bus type, as described in the table below. In all cases, PCI slot information must be known. In
130 case of USB, BCMA, and SR-VIO devices, the full name consists of the prefix, PCI slot identifier,
131 and USB or BCMA or SR-VIO slot identifier. The first two parts are denoted as "…" in the table
132 below.</para>
133
134 <table>
135 <title>Slot naming schemes</title>
136
137 <tgroup cols='2'>
138 <thead>
139 <row>
140 <entry>Format</entry>
141 <entry>Description</entry>
142 </row>
143 </thead>
144
145 <tbody>
146 <row>
147 <entry><replaceable>prefix</replaceable> [<constant>P</constant><replaceable>domain</replaceable>] <constant>s</constant><replaceable>slot</replaceable> [<constant>f</constant><replaceable>function</replaceable>] [<constant>n</constant><replaceable>port_name</replaceable> | <constant>d</constant><replaceable>dev_port</replaceable>]</entry>
148 <entry>PCI slot number</entry>
149 </row>
150
151 <row>
152 <entry>… <constant>b</constant><replaceable>number</replaceable></entry>
153 <entry>Broadcom bus (BCMA) core number</entry>
154 </row>
155
156 <row>
157 <entry>… <constant>u</constant><replaceable>port</replaceable>… [<constant>c</constant><replaceable>config</replaceable>] [<constant>i</constant><replaceable>interface</replaceable>]</entry>
158 <entry>USB port number chain</entry>
159 </row>
160
161 <row>
162 <entry>… <constant>v</constant><replaceable>slot</replaceable></entry>
163 <entry>SR-VIO slot number</entry>
164 </row>
165 </tbody>
166 </tgroup>
167 </table>
168
169 <para>The PCI domain is only prepended when it is not 0. All multi-function PCI devices will carry
170 the <constant>f<replaceable>function</replaceable></constant> number in the device name, including
171 the function 0 device. For non-multi-function devices, the number is suppressed if 0. The port name
172 <replaceable>port_name</replaceable> is used, or the port number
173 <constant>d</constant><replaceable>dev_port</replaceable> if the name is not known.</para>
174
175 <para>For BCMA devices, the core number is suppressed when 0.</para>
176
177 <para>For USB devices the full chain of port numbers of hubs is composed. If the name gets longer
178 than the maximum number of 15 characters, the name is not exported. The usual USB configuration
179 number 1 and interface number 0 values are suppressed.</para>
180 </listitem>
181
182 <para>SR-IOV virtual devices are named based on the name of the parent interface, with a suffix of
183 <constant>v</constant> and the virtual device number, with any leading zeros removed. The bus
184 number is ignored. This device type is found in IBM PowerVMs.</para>
185 </varlistentry>
186
187 <varlistentry>
188 <term><varname>ID_NET_NAME_PATH=<replaceable>prefix</replaceable><constant>c</constant><replaceable>bus_id</replaceable></varname></term>
189 <term><varname>ID_NET_NAME_PATH=<replaceable>prefix</replaceable><constant>a</constant><replaceable>vendor</replaceable><replaceable>model</replaceable><constant>i</constant><replaceable>instance</replaceable></varname></term>
190 <term><varname>ID_NET_NAME_PATH=<replaceable>prefix</replaceable><constant>i</constant><replaceable>address</replaceable><constant>n</constant><replaceable>port_name</replaceable></varname></term>
191 <term><varname>ID_NET_NAME_PATH=<replaceable>prefix</replaceable>[<constant>P</constant><replaceable>domain</replaceable>]<constant>p</constant><replaceable>bus</replaceable><constant>s</constant><replaceable>slot</replaceable>[<constant>f</constant><replaceable>function</replaceable>][<constant>n</constant><replaceable>phys_port_name</replaceable>|<constant>d</constant><replaceable>dev_port</replaceable>]</varname></term>
192 <term><varname>ID_NET_NAME_PATH=<replaceable>prefix</replaceable>[<constant>P</constant><replaceable>domain</replaceable>]<constant>p</constant><replaceable>bus</replaceable><constant>s</constant><replaceable>slot</replaceable>[<constant>f</constant><replaceable>function</replaceable>][<constant>n</constant><replaceable>phys_port_name</replaceable>|<constant>d</constant><replaceable>dev_port</replaceable>]<constant>b</constant><replaceable>number</replaceable></varname></term>
193 <term><varname>ID_NET_NAME_PATH=<replaceable>prefix</replaceable>[<constant>P</constant><replaceable>domain</replaceable>]<constant>p</constant><replaceable>bus</replaceable><constant>s</constant><replaceable>slot</replaceable>[<constant>f</constant><replaceable>function</replaceable>][<constant>n</constant><replaceable>phys_port_name</replaceable>|<constant>d</constant><replaceable>dev_port</replaceable>]<constant>u</constant><replaceable>port</replaceable>…[<constant>c</constant><replaceable>config</replaceable>][<constant>i</constant><replaceable>interface</replaceable>]</varname></term>
194
195 <listitem><para>This property describes the device installation location. Different schemes are
196 used depending on the bus type, as described in the table below. For BCMA and USB devices, PCI path
197 information must known, and the full name consists of the prefix, PCI slot identifier, and USB or
198 BCMA location. The first two parts are denoted as "…" in the table below.</para>
199
200 <table>
201 <title>Path naming schemes</title>
202
203 <tgroup cols='2'>
204 <thead>
205 <row>
206 <entry>Format</entry>
207 <entry>Description</entry>
208 </row>
209 </thead>
210
211 <tbody>
212 <row>
213 <entry><replaceable>prefix</replaceable> <constant>c</constant><replaceable>bus_id</replaceable></entry>
214 <entry>CCW or grouped CCW device identifier</entry>
215 </row>
216
217 <row>
218 <entry><replaceable>prefix</replaceable> <constant>a</constant><replaceable>vendor</replaceable> <replaceable>model</replaceable> <constant>i</constant><replaceable>instance</replaceable></entry>
219 <entry>ACPI path names for ARM64 platform devices</entry>
220 </row>
221
222 <row>
223 <entry><replaceable>prefix</replaceable> <constant>i</constant><replaceable>address</replaceable> <constant>n</constant><replaceable>port_name</replaceable></entry>
224 <entry>Netdevsim (simulated networking device) device number and port name</entry>
225 </row>
226
227 <row>
228 <entry><replaceable>prefix</replaceable> [<constant>P</constant><replaceable>domain</replaceable>] <constant>p</constant><replaceable>bus</replaceable> <constant>s</constant><replaceable>slot</replaceable> [<constant>f</constant><replaceable>function</replaceable>] [<constant>n</constant><replaceable>phys_port_name</replaceable> | <constant>d</constant><replaceable>dev_port</replaceable>]</entry>
229 <entry>PCI geographical location</entry>
230 </row>
231
232 <row>
233 <entry>… <constant>b</constant><replaceable>number</replaceable></entry>
234 <entry>Broadcom bus (BCMA) core number</entry>
235 </row>
236
237 <row>
238 <entry>… <constant>u</constant><replaceable>port</replaceable>… [<constant>c</constant><replaceable>config</replaceable>] [<constant>i</constant><replaceable>interface</replaceable>]</entry>
239 <entry>USB port number chain</entry>
240 </row>
241
242 </tbody>
243 </tgroup>
244 </table>
245
246 <para>CCW and grouped CCW devices are found in IBM System Z mainframes. Any leading zeros and
247 dots are suppressed.</para>
248
249 <para>For PCI, BCMA, and USB devices, the same rules as described above for slot naming are
250 used.</para>
251 </listitem>
252 </varlistentry>
253 </variablelist>
254 </refsect1>
255
256 <refsect1>
257 <title>History</title>
258
259 <para>The following "naming schemes" have been defined:</para>
260
261 <variablelist>
262 <varlistentry>
263 <term><constant>v238</constant></term>
264
265 <listitem><para>This is the naming naming that was implemented in systemd 238.</para></listitem>
266 </varlistentry>
267
268 <varlistentry>
269 <term><constant>v239</constant></term>
270
271 <listitem><para>Naming was changed for virtual network interfaces created with SR-IOV and NPAR and
272 for devices where the PCI network controller device does not have a slot number associated.</para>
273
274 <para>SR-IOV virtual devices are named based on the name of the parent interface, with a suffix of
275 <literal>v<replaceable>port</replaceable></literal>, where <replaceable>port</replaceable> is the
276 virtual device number. Previously those virtual devices were named as if completely independent.
277 </para>
278
279 <para>The ninth and later NPAR virtual devices are named following the scheme used for the first
280 eight NPAR partitions. Previously those devices were not renamed and the kernel default
281 ("eth<replaceable>N</replaceable>") was used.</para>
282
283 <para>Names are also generated for PCI devices where the PCI network controller device does not
284 have an associated slot number itself, but one of its parents does. Previously those devices were
285 not renamed and the kernel default was used.</para>
286 </listitem>
287 </varlistentry>
288
289 <varlistentry>
290 <term><constant>v240</constant></term>
291
2ebe027b 292 <listitem><para>The <literal>ib</literal> prefix and stable names for infiniband devices are
0b1e5b6e
ZJS
293 introduced. Previously those devices were not renamed.</para>
294
295 <para>The ACPI index field (used in <varname>ID_NET_NAME_ONBOARD=</varname>) is now also used when
296 0.</para>
297
298 <para>A new naming policy <varname>NamePolicy=keep</varname> was introduced. With this policy, if
299 the network device name was already set by userspace, the device will not be renamed
300 again. Previously, this naming policy applied implicitly, and now it must be explicitly
301 requested. Effectively, this means that network devices will be renamed according to the
302 configuration, even if they have been renamed already, if <constant>keep</constant> is not
b0343f8c 303 specified as the naming policy in the <filename index="false">.link</filename> file. See
0b1e5b6e 304 <citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry>
2ebe027b 305 for a description of <varname>NamePolicy=</varname>.</para></listitem>
0b1e5b6e
ZJS
306 </varlistentry>
307
96848152
ZJS
308 <varlistentry>
309 <term><constant>v241</constant></term>
310
311 <listitem><para><option>MACAddressPolicy=persistent</option> was extended to set MAC addresses
312 based on the device name. Previously addresses were only based on the
b0343f8c 313 <varname index="false">ID_NET_NAME_*</varname> attributes, which meant that interface names would
96848152
ZJS
314 never be generated for virtual devices. Now a persistent address will be generated for most
315 devices, including in particular bridges.</para>
316
317 <para>Note: when userspace does not set a MAC address for a bridge device, the kernel will
318 initially assign a random address, and then change it when the first device is enslaved to the
319 bridge. With this naming policy change, bridges get a persistent MAC address based on the bridge
320 name instead of the first enslaved device.</para></listitem>
321 </varlistentry>
322
0b1e5b6e
ZJS
323 <varlistentry>
324 <term><constant>v243</constant></term>
325
2ebe027b
ZJS
326 <listitem><para>Support for renaming netdevsim (simulated networking) devices was added. Previously
327 those devices were not renamed.</para>
8c053c83
ZJS
328
329 <para>Previously two-letter interface type prefix was prepended to
2ebe027b 330 <varname>ID_NET_LABEL_ONBOARD=</varname>. This is not done anymore.</para></listitem>
0b1e5b6e 331 </varlistentry>
0b1e5b6e 332 </variablelist>
2ebe027b
ZJS
333
334 <para>Note that <constant>latest</constant> may be used to denote the latest scheme known (to this
335 particular version of systemd.</para>
0b1e5b6e
ZJS
336 </refsect1>
337
338 <refsect1>
339 <title>Examples</title>
340
341 <example>
342 <title>Using <command>udevadm test-builtin</command> to display device properties</title>
343
344 <programlisting>$ udevadm test-builtin net_id /sys/class/net/enp0s31f6
345...
346Using default interface naming scheme 'v243'.
347ID_NET_NAMING_SCHEME=v243
348ID_NET_NAME_MAC=enx54ee75cb1dc0
349ID_OUI_FROM_DATABASE=Wistron InfoComm(Kunshan)Co.,Ltd.
350ID_NET_NAME_PATH=enp0s31f6
351...</programlisting>
352 </example>
353
354 <example>
355 <title>PCI Ethernet card with firmware index "1"</title>
356
357 <programlisting>ID_NET_NAME_ONBOARD=eno1
8c053c83 358ID_NET_NAME_ONBOARD_LABEL=Ethernet Port 1
0b1e5b6e 359 </programlisting>
0b1e5b6e
ZJS
360 </example>
361
362 <example>
363 <title>PCI Ethernet card in hotplug slot with firmware index number</title>
364
365 <programlisting># /sys/devices/pci0000:00/0000:00:1c.3/0000:05:00.0/net/ens1
366ID_NET_NAME_MAC=enx000000000466
367ID_NET_NAME_PATH=enp5s0
368ID_NET_NAME_SLOT=ens1</programlisting>
369 </example>
370
371 <example>
372 <title>PCI Ethernet multi-function card with 2 ports</title>
373
374 <programlisting># /sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.0/net/enp2s0f0
375ID_NET_NAME_MAC=enx78e7d1ea46da
376ID_NET_NAME_PATH=enp2s0f0
377
378# /sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.1/net/enp2s0f1
379ID_NET_NAME_MAC=enx78e7d1ea46dc
380ID_NET_NAME_PATH=enp2s0f1</programlisting>
381 </example>
382
383 <example>
384 <title>PCI WLAN card</title>
385
386 <programlisting># /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/net/wlp3s0
387ID_NET_NAME_MAC=wlx0024d7e31130
388ID_NET_NAME_PATH=wlp3s0</programlisting>
389 </example>
390
391 <example>
392 <title>PCI IB host adapter with 2 ports</title>
393
394 <programlisting># /sys/devices/pci0000:00/0000:00:03.0/0000:15:00.0/net/ibp21s0f0
395ID_NET_NAME_PATH=ibp21s0f0
396
397# /sys/devices/pci0000:00/0000:00:03.0/0000:15:00.1/net/ibp21s0f1
398ID_NET_NAME_PATH=ibp21s0f1</programlisting>
399 </example>
400
401 <example>
402 <title>USB built-in 3G modem</title>
403
404 <programlisting># /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4:1.6/net/wwp0s29u1u4i6
405ID_NET_NAME_MAC=wwx028037ec0200
406ID_NET_NAME_PATH=wwp0s29u1u4i6</programlisting>
407 </example>
408
409 <example>
410 <title>USB Android phone</title>
411
412 <programlisting># /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/net/enp0s29u1u2
413ID_NET_NAME_MAC=enxd626b3450fb5
414ID_NET_NAME_PATH=enp0s29u1u2</programlisting>
415 </example>
416
417 <example>
418 <title>s390 grouped CCW interface</title>
419
420 <programlisting># /sys/devices/css0/0.0.0007/0.0.f5f0/group_device/net/encf5f0
421ID_NET_NAME_MAC=enx026d3c00000a
422ID_NET_NAME_PATH=encf5f0</programlisting>
423 </example>
424 </refsect1>
425
426 <refsect1>
427 <title>See Also</title>
428 <para>
429 <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
430 <citerefentry><refentrytitle>udevadm</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
431 <ulink url="https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames">the
432 original page describing stable interface names</ulink>
433 </para>
434 </refsect1>
435
436</refentry>