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+ -->
6 <refentry id=
"systemd.link">
8 <title>systemd.link
</title>
9 <productname>systemd
</productname>
13 <refentrytitle>systemd.link
</refentrytitle>
14 <manvolnum>5</manvolnum>
18 <refname>systemd.link
</refname>
19 <refpurpose>Network device configuration
</refpurpose>
23 <para><filename><replaceable>link
</replaceable>.link
</filename></para>
27 <title>Description
</title>
29 <para>Network link configuration is performed by the
30 <command>net_setup_link
</command> udev builtin.
</para>
32 <para>The link files are read from the files located in the system
33 network directory
<filename>/usr/lib/systemd/network
</filename>,
34 the volatile runtime network directory
35 <filename>/run/systemd/network
</filename>, and the local
36 administration network directory
37 <filename>/etc/systemd/network
</filename>. Link files must have
38 the extension
<filename>.link
</filename>; other extensions are
39 ignored. All link files are collectively sorted and processed in
40 lexical order, regardless of the directories in which they live.
41 However, files with identical filenames replace each other. Files
42 in
<filename>/etc
</filename> have the highest priority, files in
43 <filename>/run
</filename> take precedence over files with the same
44 name in
<filename>/usr/lib
</filename>. This can be used to
45 override a system-supplied link file with a local file if needed.
46 As a special case, an empty file (file size
0) or symlink with the
47 same name pointing to
<filename>/dev/null
</filename> disables the
48 configuration file entirely (it is
"masked").
</para>
50 <para>The link file contains a [Match] section, which determines if a given link file may be applied to a
51 given device, as well as a [Link] section specifying how the device should be configured. The first (in
52 lexical order) of the link files that matches a given device is applied. Note that a default file
53 <filename>99-default.link
</filename> is shipped by the system. Any user-supplied
54 <filename>.link
</filename> should hence have a lexically earlier name to be considered at all.
</para>
56 <para>See
<citerefentry><refentrytitle>udevadm
</refentrytitle><manvolnum>8</manvolnum></citerefentry> for
57 diagnosing problems with
<filename>.link
</filename> files.
</para>
61 <title>[Match] Section Options
</title>
63 <para>A link file is said to match a device if all matches specified by the
64 <literal>[Match]
</literal> section are satisfied. When a link file does not contain valid settings
65 in
<literal>[Match]
</literal> section, then the file will match all devices and
66 <command>systemd-udevd
</command> warns about that. Hint: to avoid the warning and to make it clear
67 that all interfaces shall be matched, add the following:
68 <programlisting>OriginalName=*
</programlisting>
69 The following keys are accepted:
</para>
71 <variablelist class='network-directives'
>
73 <term><varname>MACAddress=
</varname></term>
75 <para>A whitespace-separated list of hardware addresses. Use full colon-, hyphen- or dot-delimited hexadecimal. See the example below.
76 This option may appear more than once, in which case the lists are merged. If the empty string is assigned to this option, the list
77 of hardware addresses defined prior to this is reset.
</para>
80 <programlisting>MACAddress=
01:
23:
45:
67:
89:ab
00-
11-
22-
33-
44-
55 AABB.CCDD.EEFF
</programlisting></para>
84 <term><varname>OriginalName=
</varname></term>
86 <para>A whitespace-separated list of shell-style globs matching
87 the device name, as exposed by the udev property
88 "INTERFACE". This cannot be used to match on names that have
89 already been changed from userspace. Caution is advised when matching on
90 kernel-assigned names, as they are known to be unstable
91 between reboots.
</para>
95 <term><varname>Path=
</varname></term>
97 <para>A whitespace-separated list of shell-style globs matching
98 the persistent path, as exposed by the udev property
99 <varname>ID_PATH
</varname>.
</para>
103 <term><varname>Driver=
</varname></term>
105 <para>A whitespace-separated list of shell-style globs matching the driver currently bound to the
106 device, as exposed by the udev property
<varname>ID_NET_DRIVER
</varname> of its parent device, or if that
107 is not set, the driver as exposed by
<command>ethtool -i
</command> of the device itself.
</para>
111 <term><varname>Type=
</varname></term>
113 <para>A whitespace-separated list of shell-style globs matching
114 the device type, as exposed by the udev
115 property
<varname>DEVTYPE
</varname>.
</para>
119 <term><varname>Property=
</varname></term>
121 <para>A whitespace-separated list of udev property name with its value after a equal
122 (
<literal>=
</literal>). If multiple properties are specified, the test results are ANDed.
123 If the list is prefixed with a
"!", the test is inverted. If a value contains white
124 spaces, then please quote whole key and value pair. If a value contains quotation, then
125 please escape the quotation with
<literal>\
</literal>.
</para>
127 <para>Example: if a .link file has the following:
128 <programlisting>Property=ID_MODEL_ID=
9999 "ID_VENDOR_FROM_DATABASE=vendor name" "KEY=with \"quotation\
""</programlisting>
129 then, the .link file matches only when an interface has all the above three properties.
134 <term><varname>Host=
</varname></term>
136 <para>Matches against the hostname or machine ID of the host. See
<varname>ConditionHost=
</varname> in
137 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
138 for details. When prefixed with an exclamation mark (
<literal>!
</literal>), the result is negated.
139 If an empty string is assigned, then previously assigned value is cleared.
144 <term><varname>Virtualization=
</varname></term>
146 <para>Checks whether the system is executed in a virtualized environment and optionally test
147 whether it is a specific implementation. See
<varname>ConditionVirtualization=
</varname> in
148 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
149 for details. When prefixed with an exclamation mark (
<literal>!
</literal>), the result is negated.
150 If an empty string is assigned, then previously assigned value is cleared.
155 <term><varname>KernelCommandLine=
</varname></term>
157 <para>Checks whether a specific kernel command line option is set. See
158 <varname>ConditionKernelCommandLine=
</varname> in
159 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
160 for details. When prefixed with an exclamation mark (
<literal>!
</literal>), the result is negated.
161 If an empty string is assigned, then previously assigned value is cleared.
166 <term><varname>KernelVersion=
</varname></term>
168 <para>Checks whether the kernel version (as reported by
<command>uname -r
</command>) matches a certain
169 expression. See
<varname>ConditionKernelVersion=
</varname> in
170 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
171 details. When prefixed with an exclamation mark (
<literal>!
</literal>), the result is negated.
172 If an empty string is assigned, then previously assigned value is cleared.
177 <term><varname>Architecture=
</varname></term>
179 <para>Checks whether the system is running on a specific architecture. See
180 <varname>ConditionArchitecture=
</varname> in
181 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
182 for details. When prefixed with an exclamation mark (
<literal>!
</literal>), the result is negated.
183 If an empty string is assigned, then previously assigned value is cleared.
192 <title>[Link] Section Options
</title>
194 <para>The [Link] section accepts the following
197 <variablelist class='network-directives'
>
199 <term><varname>Description=
</varname></term>
201 <para>A description of the device.
</para>
205 <term><varname>Alias=
</varname></term>
207 <para>The
<varname>ifalias
</varname> interface property is set to this value.
</para>
211 <term><varname>MACAddressPolicy=
</varname></term>
213 <para>The policy by which the MAC address should be set. The
214 available policies are:
219 <term><option>persistent
</option></term>
221 <para>If the hardware has a persistent MAC address, as
222 most hardware should, and if it is used by the kernel,
223 nothing is done. Otherwise, a new MAC address is
224 generated which is guaranteed to be the same on every
225 boot for the given machine and the given device, but
226 which is otherwise random. This feature depends on ID_NET_NAME_*
227 properties to exist for the link. On hardware where these
228 properties are not set, the generation of a persistent MAC address
233 <term><option>random
</option></term>
235 <para>If the kernel is using a random MAC address,
236 nothing is done. Otherwise, a new address is randomly
237 generated each time the device appears, typically at
238 boot. Either way, the random address will have the
239 <literal>unicast
</literal> and
240 <literal>locally administered
</literal> bits set.
</para>
244 <term><option>none
</option></term>
246 <para>Keeps the MAC address assigned by the kernel.
</para>
253 <term><varname>MACAddress=
</varname></term>
255 <para>The MAC address to use, if no
256 <varname>MACAddressPolicy=
</varname>
261 <term><varname>NamePolicy=
</varname></term>
263 <para>An ordered, space-separated list of policies by which the interface name should be set.
264 <varname>NamePolicy=
</varname> may be disabled by specifying
<option>net.ifnames=
0</option> on the
265 kernel command line. Each of the policies may fail, and the first successful one is used. The name
266 is not set directly, but is exported to udev as the property
<option>ID_NET_NAME
</option>, which
267 is, by default, used by a
268 <citerefentry><refentrytitle>udev
</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
269 rule to set
<varname>NAME
</varname>. The available policies are:
274 <term><option>kernel
</option></term>
276 <para>If the kernel claims that the name it has set
277 for a device is predictable, then no renaming is
282 <term><option>database
</option></term>
284 <para>The name is set based on entries in the udev's
285 Hardware Database with the key
286 <varname>ID_NET_NAME_FROM_DATABASE
</varname>.
291 <term><option>onboard
</option></term>
293 <para>The name is set based on information given by
294 the firmware for on-board devices, as exported by the
295 udev property
<varname>ID_NET_NAME_ONBOARD
</varname>.
296 See
<citerefentry><refentrytitle>systemd.net-naming-scheme
</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
301 <term><option>slot
</option></term>
303 <para>The name is set based on information given by
304 the firmware for hot-plug devices, as exported by the
305 udev property
<varname>ID_NET_NAME_SLOT
</varname>.
306 See
<citerefentry><refentrytitle>systemd.net-naming-scheme
</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
311 <term><option>path
</option></term>
313 <para>The name is set based on the device's physical
314 location, as exported by the udev property
315 <varname>ID_NET_NAME_PATH
</varname>.
316 See
<citerefentry><refentrytitle>systemd.net-naming-scheme
</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
321 <term><option>mac
</option></term>
323 <para>The name is set based on the device's persistent
324 MAC address, as exported by the udev property
325 <varname>ID_NET_NAME_MAC
</varname>.
326 See
<citerefentry><refentrytitle>systemd.net-naming-scheme
</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
331 <term><option>keep
</option></term>
333 <para>If the device already had a name given by userspace (as part of creation of the device
334 or a rename), keep it.
</para>
341 <term><varname>Name=
</varname></term>
343 <para>The interface name to use. This option has lower precedence than
344 <varname>NamePolicy=
</varname>, so for this setting to take effect,
<varname>NamePolicy=
</varname>
345 must either be unset, empty, disabled, or all policies configured there must fail. Also see the
346 example below with
<literal>Name=dmz0
</literal>.
</para>
348 <para>Note that specifying a name that the kernel might use for another
349 interface (for example
<literal>eth0
</literal>) is dangerous because the
350 name assignment done by udev will race with the assignment done by the
351 kernel, and only one interface may use the name. Depending on the order of
352 operations, either udev or the kernel will win, making the naming
353 unpredictable. It is best to use some different prefix, for example
354 <literal>internal0
</literal>/
<literal>external0
</literal> or
355 <literal>lan0
</literal>/
<literal>lan1
</literal>/
<literal>lan3
</literal>.
360 <term><varname>MTUBytes=
</varname></term>
362 <para>The maximum transmission unit in bytes to set for the
363 device. The usual suffixes K, M, G, are supported and are
364 understood to the base of
1024.
</para>
368 <term><varname>BitsPerSecond=
</varname></term>
370 <para>The speed to set for the device, the value is rounded
371 down to the nearest Mbps. The usual suffixes K, M, G, are
372 supported and are understood to the base of
1000.
</para>
376 <term><varname>Duplex=
</varname></term>
378 <para>The duplex mode to set for the device. The accepted values are
<option>half
</option> and
379 <option>full
</option>.
</para>
383 <term><varname>AutoNegotiation=
</varname></term>
385 <para>Takes a boolean. If set to yes, automatic negotiation of transmission parameters is enabled.
386 Autonegotiation is a procedure by which two connected ethernet devices choose
387 common transmission parameters, such as speed, duplex mode, and flow control.
388 When unset, the kernel's default will be used.
</para>
390 <para>Note that if autonegotiation is enabled, speed and duplex settings are
391 read-only. If autonegotation is disabled, speed and duplex settings are writable
392 if the driver supports multiple link modes.
</para>
396 <term><varname>WakeOnLan=
</varname></term>
398 <para>The Wake-on-LAN policy to set for the device. The
399 supported values are:
</para>
403 <term><option>phy
</option></term>
405 <para>Wake on PHY activity.
</para>
409 <term><option>unicast
</option></term>
411 <para>Wake on unicast messages.
</para>
415 <term><option>multicast
</option></term>
417 <para>Wake on multicast messages.
</para>
421 <term><option>broadcast
</option></term>
423 <para>Wake on broadcast messages.
</para>
427 <term><option>arp
</option></term>
429 <para>Wake on ARP.
</para>
433 <term><option>magic
</option></term>
435 <para>Wake on receipt of a magic packet.
440 <term><option>secureon
</option></term>
442 <para>Enable secureon(tm) password for MagicPacket(tm).
447 <term><option>off
</option></term>
449 <para>Never wake.
</para>
454 <para>Defaults to
<option>off
</option>.
</para>
458 <term><varname>Port=
</varname></term>
460 <para>The port option is used to select the device port. The
461 supported values are:
</para>
465 <term><option>tp
</option></term>
467 <para>An Ethernet interface using Twisted-Pair cable as the medium.
</para>
471 <term><option>aui
</option></term>
473 <para>Attachment Unit Interface (AUI). Normally used with hubs.
478 <term><option>bnc
</option></term>
480 <para>An Ethernet interface using BNC connectors and co-axial cable.
</para>
484 <term><option>mii
</option></term>
486 <para>An Ethernet interface using a Media Independent Interface (MII).
</para>
490 <term><option>fibre
</option></term>
492 <para>An Ethernet interface using Optical Fibre as the medium.
</para>
499 <term><varname>Advertise=
</varname></term>
501 <para>This sets what speeds and duplex modes of operation are advertised for auto-negotiation.
502 This implies
<literal>AutoNegotiation=yes
</literal>. The supported values are:
505 <title>Supported advertise values
</title>
507 <colspec colname='Advertise'
/>
508 <colspec colname='Speed'
/>
509 <colspec colname='Duplex Mode'
/>
512 <entry>Advertise
</entry>
513 <entry>Speed (Mbps)
</entry>
514 <entry>Duplex Mode
</entry>
517 <row><entry><option>10baset-half
</option></entry>
518 <entry>10</entry><entry>half
</entry></row>
520 <row><entry><option>10baset-full
</option></entry>
521 <entry>10</entry><entry>full
</entry></row>
523 <row><entry><option>100baset-half
</option></entry>
524 <entry>100</entry><entry>half
</entry></row>
526 <row><entry><option>100baset-full
</option></entry>
527 <entry>100</entry><entry>full
</entry></row>
529 <row><entry><option>1000baset-half
</option></entry>
530 <entry>1000</entry><entry>half
</entry></row>
532 <row><entry><option>1000baset-full
</option></entry>
533 <entry>1000</entry><entry>full
</entry></row>
535 <row><entry><option>10000baset-full
</option></entry>
536 <entry>10000</entry><entry>full
</entry></row>
538 <row><entry><option>2500basex-full
</option></entry>
539 <entry>2500</entry><entry>full
</entry></row>
541 <row><entry><option>1000basekx-full
</option></entry>
542 <entry>1000</entry><entry>full
</entry></row>
544 <row><entry><option>10000basekx4-full
</option></entry>
545 <entry>10000</entry><entry>full
</entry></row>
547 <row><entry><option>10000basekr-full
</option></entry>
548 <entry>10000</entry><entry>full
</entry></row>
550 <row><entry><option>10000baser-fec
</option></entry>
551 <entry>10000</entry><entry>full
</entry></row>
553 <row><entry><option>20000basemld2-full
</option></entry>
554 <entry>20000</entry><entry>full
</entry></row>
556 <row><entry><option>20000basekr2-full
</option></entry>
557 <entry>20000</entry><entry>full
</entry></row>
562 By default this is unset, i.e. all possible modes will be advertised.
563 This option may be specified more than once, in which case all specified speeds and modes are advertised.
564 If the empty string is assigned to this option, the list is reset, and all prior assignments have no effect.
569 <term><varname>TCPSegmentationOffload=
</varname></term>
571 <para>Takes a boolean. If set to true, the TCP Segmentation Offload (TSO) is enabled.
572 When unset, the kernel's default will be used.
</para>
576 <term><varname>TCP6SegmentationOffload=
</varname></term>
578 <para>Takes a boolean. If set to true, the TCP6 Segmentation Offload (tx-tcp6-segmentation) is enabled.
579 When unset, the kernel's default will be used.
</para>
583 <term><varname>GenericSegmentationOffload=
</varname></term>
585 <para>Takes a boolean. If set to true, the Generic Segmentation Offload (GSO) is enabled.
586 When unset, the kernel's default will be used.
</para>
590 <term><varname>GenericReceiveOffload=
</varname></term>
592 <para>Takes a boolean. If set to true, the Generic Receive Offload (GRO) is enabled.
593 When unset, the kernel's default will be used.
</para>
597 <term><varname>LargeReceiveOffload=
</varname></term>
599 <para>Takes a boolean. If set to true, the Large Receive Offload (LRO) is enabled.
600 When unset, the kernel's default will be used.
</para>
604 <term><varname>RxChannels=
</varname></term>
606 <para>Sets the number of receive channels (a number between
1 and
4294967295) .
</para>
610 <term><varname>TxChannels=
</varname></term>
612 <para>Sets the number of transmit channels (a number between
1 and
4294967295).
</para>
616 <term><varname>OtherChannels=
</varname></term>
618 <para>Sets the number of other channels (a number between
1 and
4294967295).
</para>
622 <term><varname>CombinedChannels=
</varname></term>
624 <para>Sets the number of combined set channels (a number between
1 and
4294967295).
</para>
628 <term><varname>RxBufferSize=
</varname></term>
630 <para>Takes a integer. Specifies the NIC receive ring buffer size. When unset, the kernel's default will be used.
</para>
634 <term><varname>TxBufferSize=
</varname></term>
636 <para>Takes a integer. Specifies the NIC transmit ring buffer size. When unset, the kernel's default will be used.
</para>
644 <title>Examples
</title>
647 <title>/usr/lib/systemd/network/
99-default.link
</title>
649 <para>The link file
<filename>99-default.link
</filename> that is
650 shipped with systemd defines the default naming policy for
653 <programlisting>[Link]
654 NamePolicy=kernel database onboard slot path
655 MACAddressPolicy=persistent
</programlisting>
659 <title>/etc/systemd/network/
10-dmz.link
</title>
661 <para>This example assigns the fixed name
<literal>dmz0
</literal> to the interface with the MAC address
662 00:a0:de:
63:
7a:e6:
</para>
664 <programlisting>[Match]
665 MACAddress=
00:a0:de:
63:
7a:e6
668 Name=dmz0
</programlisting>
670 <para><varname>NamePolicy=
</varname> is not set, so
<varname>Name=
</varname> takes effect. We use the
671 <literal>10-
</literal> prefix to order this file early in the list. Note that it needs to before
672 <literal>99-link
</literal>, i.e. it needs a numerical prefix, to have any effect at all.
</para>
676 <title>Debugging
<varname>NamePolicy=
</varname> assignments
</title>
678 <programlisting>$ sudo SYSTEMD_LOG_LEVEL=debug udevadm test-builtin net_setup_link /sys/class/net/hub0
680 Parsed configuration file /usr/lib/systemd/network/
99-default.link
681 Parsed configuration file /etc/systemd/network/
10-eth0.link
682 ID_NET_DRIVER=cdc_ether
683 Config file /etc/systemd/network/
10-eth0.link applies to device hub0
684 link_config: autonegotiation is unset or enabled, the speed and duplex are not writable.
685 hub0: Device has name_assign_type=
4
686 Using default interface naming scheme 'v240'.
687 hub0: Policies didn't yield a name, using specified Name=hub0.
688 ID_NET_LINK_FILE=/etc/systemd/network/
10-eth0.link
692 <para>Explicit
<varname>Name=
</varname> configuration wins in this case.
</para>
694 <programlisting>sudo SYSTEMD_LOG_LEVEL=debug udevadm test-builtin net_setup_link /sys/class/net/enp0s31f6
696 Parsed configuration file /usr/lib/systemd/network/
99-default.link
697 Parsed configuration file /etc/systemd/network/
10-eth0.link
698 Created link configuration context.
700 Config file /usr/lib/systemd/network/
99-default.link applies to device enp0s31f6
701 link_config: autonegotiation is unset or enabled, the speed and duplex are not writable.
702 enp0s31f6: Device has name_assign_type=
4
703 Using default interface naming scheme 'v240'.
704 enp0s31f6: Policy *keep*: keeping existing userspace name
705 enp0s31f6: Device has addr_assign_type=
0
706 enp0s31f6: MAC on the device already matches policy *persistent*
707 ID_NET_LINK_FILE=/usr/lib/systemd/network/
99-default.link
711 <para>In this case, the interface was already renamed, so the
<option>keep
</option> policy specified as
712 the first option in
<filename index=
"false">99-default.link
</filename> means that the existing name is
713 preserved. If
<option>keep
</option> was removed, or if were in boot before the renaming has happened,
714 we might get the following instead:
</para>
716 <programlisting>enp0s31f6: Policy *path* yields
"enp0s31f6".
717 enp0s31f6: Device has addr_assign_type=
0
718 enp0s31f6: MAC on the device already matches policy *persistent*
719 ID_NET_LINK_FILE=/usr/lib/systemd/network/
99-default.link
720 ID_NET_NAME=enp0s31f6
724 <para>Please note that the details of output are subject to change.
</para>
728 <title>/etc/systemd/network/
10-internet.link
</title>
730 <para>This example assigns the fixed name
731 <literal>internet0
</literal> to the interface with the device
732 path
<literal>pci-
0000:
00:
1a
.0-*
</literal>:
</para>
734 <programlisting>[Match]
735 Path=pci-
0000:
00:
1a
.0-*
738 Name=internet0
</programlisting>
742 <title>/etc/systemd/network/
25-wireless.link
</title>
744 <para>Here's an overly complex example that shows the use of a large number of [Match] and [Link] settings.
</para>
746 <programlisting>[Match]
747 MACAddress=
12:
34:
56:
78:
9a:bc
749 Path=pci-
0000:
02:
00.0-*
760 MACAddress=cb:a9:
87:
65:
43:
21</programlisting>
765 <title>See Also
</title>
768 <refentrytitle>systemd-udevd.service
</refentrytitle><manvolnum>8</manvolnum>
771 <refentrytitle>udevadm
</refentrytitle><manvolnum>8</manvolnum>
774 <refentrytitle>systemd.netdev
</refentrytitle><manvolnum>5</manvolnum>
777 <refentrytitle>systemd.network
</refentrytitle><manvolnum>5</manvolnum>