chiark / gitweb /
net: support globbing and disjunction in Match logic
[elogind.git] / man / systemd.link.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <?xml-stylesheet type="text/xsl" href="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"?>
3 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
4   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5
6 <!--
7   This file is part of systemd.
8
9   Copyright 2014 Tom Gundersen
10
11   systemd is free software; you can redistribute it and/or modify it
12   under the terms of the GNU Lesser General Public License as published by
13   the Free Software Foundation; either version 2.1 of the License, or
14   (at your option) any later version.
15
16   systemd is distributed in the hope that it will be useful, but
17   WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19   Lesser General Public License for more details.
20
21   You should have received a copy of the GNU Lesser General Public License
22   along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 -->
24
25 <refentry id="systemd.link">
26   <refentryinfo>
27     <title>systemd.link</title>
28     <productname>systemd</productname>
29
30     <authorgroup>
31       <author>
32         <contrib>Developer</contrib>
33         <firstname>Tom</firstname>
34         <surname>Gundersen</surname>
35       </author>
36     </authorgroup>
37   </refentryinfo>
38
39   <refmeta>
40     <refentrytitle>systemd.link</refentrytitle>
41     <manvolnum>5</manvolnum>
42   </refmeta>
43
44   <refnamediv>
45     <refname>systemd.link</refname>
46     <refpurpose>Network device configuration</refpurpose>
47   </refnamediv>
48
49   <refsynopsisdiv>
50     <para><filename><replaceable>link</replaceable>.link</filename></para>
51   </refsynopsisdiv>
52
53   <refsect1>
54     <title>Description</title>
55
56     <para>Network link configuration is performed by the
57     <command>net_setup_link</command> udev builtin.</para>
58
59     <para>The link files are read from the files located in the system
60     network directory <filename>/usr/lib/systemd/network</filename>,
61     the volatile runtime network directory
62     <filename>/run/systemd/network</filename>, and the local
63     administration network directory
64     <filename>/etc/systemd/network</filename>. Link files must have
65     the extension <filename>.link</filename>; other extensions are
66     ignored. All link files are collectively sorted and processed in
67     lexical order, regardless of the directories in which they live.
68     However, files with identical filenames replace each other. Files
69     in <filename>/etc</filename> have the highest priority, files in
70     <filename>/run</filename> take precedence over files with the same
71     name in <filename>/usr/lib</filename>. This can be used to
72     override a system-supplied link file with a local file if needed;
73     a symlink in <filename>/etc</filename> with the same name as a
74     link file in <filename>/usr/lib</filename>, pointing to
75     <filename>/dev/null</filename>, disables the link file
76     entirely.</para>
77
78     <para>The link file contains a <literal>[Match]</literal> section,
79     which determines if a given link file may be applied to a given
80     device, as well as a <literal>[Link]</literal> section specifying
81     how the device should be configured. The first (in lexical order)
82     of the link files that matches a given device is applied. Note
83     that a default file <filename>99-default.link</filename> is
84     shipped by the system, any user-supplied
85     <filename>.link</filename> should hence have a lexically earlier
86     name to be considered at all.</para>
87   </refsect1>
88
89   <refsect1>
90     <title>[Match] Section Options</title>
91
92     <para>A link file is said to match a device if each of the entries
93     in the <literal>[Match]</literal> section matches, or if the
94     section is empty. The following keys are accepted:</para>
95
96     <variablelist class='network-directives'>
97       <varlistentry>
98         <term><varname>MACAddress=</varname></term>
99         <listitem>
100           <para>The hardware address.</para>
101         </listitem>
102       </varlistentry>
103       <varlistentry>
104         <term><varname>OriginalName=</varname></term>
105         <listitem>
106           <para>A whitespace-separated list of shell-style globs matching
107           the device name, as exposed by the udev property
108           "INTERFACE". This can not be used to match on names that have
109           already been changed from userspace. Caution is advised when matching on
110           kernel-assigned names, as they are known to be unstable
111           between reboots.</para>
112         </listitem>
113       </varlistentry>
114       <varlistentry>
115         <term><varname>Path=</varname></term>
116         <listitem>
117           <para>A whitespace-separated list of shell-style globs matching
118           the persistent path, as exposed by the udev property
119           <literal>ID_PATH</literal>.</para>
120         </listitem>
121       </varlistentry>
122       <varlistentry>
123         <term><varname>Driver=</varname></term>
124         <listitem>
125           <para>A whitespace-separated list of shell-style globs matching
126           the driver currently bound to the device,
127           as exposed by the udev property <literal>DRIVER</literal>
128           of its parent device, or if that is not set, the
129           driver as exposed by <literal>ethtool -i</literal>
130           of the device itself.</para>
131         </listitem>
132       </varlistentry>
133       <varlistentry>
134         <term><varname>Type=</varname></term>
135         <listitem>
136           <para>A whitespace-separated list of shell-style globs matching
137           the device type, as exposed by the udev
138           property <literal>DEVTYPE</literal>.</para>
139         </listitem>
140       </varlistentry>
141       <varlistentry>
142         <term><varname>Host=</varname></term>
143         <listitem>
144           <para>Matches against the hostname or machine
145           ID of the host. See <literal>ConditionHost=</literal> in
146           <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
147           for details.</para>
148         </listitem>
149       </varlistentry>
150       <varlistentry>
151         <term><varname>Virtualization=</varname></term>
152         <listitem>
153           <para>Checks whether the system is executed in
154           a virtualized environment and optionally test
155           whether it is a specific implementation. See
156           <literal>ConditionVirtualization=</literal> in
157           <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
158           for details.</para>
159         </listitem>
160       </varlistentry>
161       <varlistentry>
162         <term><varname>KernelCommandLine=</varname></term>
163         <listitem>
164           <para>Checks whether a specific kernel command line option
165           is set (or if prefixed with the exclamation mark unset). See
166           <literal>ConditionKernelCommandLine=</literal> in
167           <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
168           for details.</para>
169         </listitem>
170       </varlistentry>
171       <varlistentry>
172         <term><varname>Architecture=</varname></term>
173         <listitem>
174           <para>Checks whether the system is running on a specific
175           architecture. See <literal>ConditionArchitecture=</literal>
176           in
177           <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
178           for details.</para>
179         </listitem>
180       </varlistentry>
181     </variablelist>
182
183   </refsect1>
184
185   <refsect1>
186     <title>[Link] Section Options</title>
187
188     <para>The <literal>[Link]</literal> section accepts the following
189     keys:</para>
190
191     <variablelist class='network-directives'>
192       <varlistentry>
193         <term><varname>Description=</varname></term>
194         <listitem>
195           <para>A description of the device.</para>
196         </listitem>
197       </varlistentry>
198       <varlistentry>
199         <term><varname>Alias=</varname></term>
200         <listitem>
201           <para>The <literal>ifalias</literal> is set to this
202           value.</para>
203         </listitem>
204       </varlistentry>
205       <varlistentry>
206         <term><varname>MACAddressPolicy=</varname></term>
207         <listitem>
208           <para>The policy by which the MAC address should be set. The
209           available policies are:
210           </para>
211
212           <variablelist>
213             <varlistentry>
214               <term><literal>persistent</literal></term>
215               <listitem>
216                 <para>If the hardware has a persistent MAC address, as
217                 most hardware should, and if it is used by the kernel,
218                 nothing is done. Otherwise, a new MAC address is
219                 generated which is guaranteed to be the same on every
220                 boot for the given machine and the given device, but
221                 which is otherwise random. This feature depends on ID_NET_NAME_*
222                 properties existing for the link, on hardware where these
223                 properties are not set the generation of a persistent MAC address
224                 will fail.</para>
225               </listitem>
226             </varlistentry>
227             <varlistentry>
228               <term><literal>random</literal></term>
229               <listitem>
230                 <para>If the kernel is using a random MAC address,
231                 nothing is done. Otherwise, a new address is randomly
232                 generated each time the device appears, typically at
233                 boot.</para>
234               </listitem>
235             </varlistentry>
236           </variablelist>
237         </listitem>
238       </varlistentry>
239       <varlistentry>
240         <term><varname>MACAddress=</varname></term>
241         <listitem>
242           <para>The MAC address to use, if no
243           <literal>MACAddressPolicy=</literal>
244           is specified.</para>
245         </listitem>
246       </varlistentry>
247       <varlistentry>
248         <term><varname>NamePolicy=</varname></term>
249         <listitem>
250           <para>An ordered, space-separated list of policies by which
251           the interface name should be set.
252           <literal>NamePolicy</literal> may be disabled by specifying
253           <literal>net.ifnames=0</literal> on the kernel command line.
254           Each of the policies may fail, and the first successful one
255           is used. The name is not set directly, but is exported to
256           udev as the property <literal>ID_NET_NAME</literal>, which
257           is, by default, used by a udev rule to set
258           <literal>NAME</literal>. If the name has already been set by
259           userspace, no renaming is performed. The available policies
260           are:</para>
261
262           <variablelist>
263             <varlistentry>
264               <term><literal>kernel</literal></term>
265               <listitem>
266                 <para>If the kernel claims that the name it has set
267                 for a device is predictable, then no renaming is
268                 performed.</para>
269               </listitem>
270             </varlistentry>
271             <varlistentry>
272               <term><literal>database</literal></term>
273               <listitem>
274                 <para>The name is set based on entries in the udev's
275                 Hardware Database with the key
276                 <literal>ID_NET_NAME_FROM_DATABASE</literal>.
277                 </para>
278               </listitem>
279             </varlistentry>
280             <varlistentry>
281               <term><literal>onboard</literal></term>
282               <listitem>
283                 <para>The name is set based on information given by
284                 the firmware for on-board devices, as exported by the
285                 udev property <literal>ID_NET_NAME_ONBOARD</literal>.
286                 </para>
287               </listitem>
288             </varlistentry>
289             <varlistentry>
290               <term><literal>slot</literal></term>
291               <listitem>
292                 <para>The name is set based on information given by
293                 the firmware for hot-plug devices, as exported by the
294                 udev property <literal>ID_NET_NAME_SLOT</literal>.
295                 </para>
296               </listitem>
297             </varlistentry>
298             <varlistentry>
299               <term><literal>path</literal></term>
300               <listitem>
301                 <para>The name is set based on the device's physical
302                 location, as exported by the udev property
303                 <literal>ID_NET_NAME_PATH</literal>.</para>
304               </listitem>
305             </varlistentry>
306             <varlistentry>
307               <term><literal>mac</literal></term>
308               <listitem>
309                 <para>The name is set based on the device's persistent
310                 MAC address, as exported by the udev property
311                 <literal>ID_NET_NAME_MAC</literal>.</para>
312               </listitem>
313             </varlistentry>
314           </variablelist>
315         </listitem>
316       </varlistentry>
317       <varlistentry>
318         <term><varname>Name=</varname></term>
319         <listitem>
320           <para>The interface name to use in case all the
321           policies specified in
322           <varname>NamePolicy=</varname> fail, or in case
323           <varname>NamePolicy=</varname> is missing or
324           disabled.</para>
325         </listitem>
326       </varlistentry>
327       <varlistentry>
328         <term><varname>MTUBytes=</varname></term>
329         <listitem>
330           <para>The maximum transmission unit in bytes to set for the
331           device. The usual suffixes K, M, G, are supported and are
332           understood to the base of 1024.</para>
333         </listitem>
334       </varlistentry>
335       <varlistentry>
336         <term><varname>BitsPerSecond=</varname></term>
337         <listitem>
338           <para>The speed to set for the device, the value is rounded
339           down to the nearest Mbps. The usual suffixes K, M, G, are
340           supported and are understood to the base of 1000.</para>
341         </listitem>
342       </varlistentry>
343       <varlistentry>
344         <term><varname>Duplex=</varname></term>
345         <listitem>
346           <para>The duplex mode to set for the device. The accepted
347           values are <literal>half</literal> and
348           <literal>full</literal>.</para>
349         </listitem>
350       </varlistentry>
351       <varlistentry>
352         <term><varname>WakeOnLan=</varname></term>
353         <listitem>
354           <para>The Wake-on-LAN policy to set for the device. The
355           supported values are:</para>
356
357           <variablelist>
358             <varlistentry>
359               <term><literal>phy</literal></term>
360               <listitem>
361                 <para>Wake on PHY activity.</para>
362               </listitem>
363             </varlistentry>
364             <varlistentry>
365               <term><literal>magic</literal></term>
366               <listitem>
367                 <para>Wake on receipt of a magic packet.
368                 </para>
369               </listitem>
370             </varlistentry>
371             <varlistentry>
372               <term><literal>off</literal></term>
373               <listitem>
374                 <para>Never wake.</para>
375               </listitem>
376             </varlistentry>
377           </variablelist>
378         </listitem>
379       </varlistentry>
380     </variablelist>
381   </refsect1>
382
383   <refsect1>
384     <title>Example</title>
385     <example>
386       <title>/etc/systemd/network/wireless.link</title>
387
388       <programlisting>[Match]
389 MACAddress=12:34:56:78:9a:bc
390 Driver=brcmsmac
391 Path=pci-0000:02:00.0-*
392 Type=wlan
393 Virtualization=no
394 Host=my-laptop
395 Architecture=x86-64
396
397 [Link]
398 Name=wireless0
399 MTUBytes=1450
400 BitsPerSecond=10M
401 WakeOnLan=magic
402 MACAddress=cb:a9:87:65:43:21</programlisting>
403     </example>
404   </refsect1>
405
406   <refsect1>
407     <title>See Also</title>
408     <para>
409       <citerefentry>
410         <refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum>
411       </citerefentry>,
412       <citerefentry>
413         <refentrytitle>udevadm</refentrytitle><manvolnum>8</manvolnum>
414       </citerefentry>,
415       <citerefentry>
416         <refentrytitle>systemd.netdev</refentrytitle><manvolnum>5</manvolnum>
417       </citerefentry>,
418       <citerefentry>
419         <refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum>
420       </citerefentry>
421     </para>
422   </refsect1>
423
424 </refentry>