chiark / gitweb /
networkd: add basic support for MACVLANs
[elogind.git] / man / systemd.network.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3         "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6   This file is part of systemd.
7
8   Copyright 2013 Tom Gundersen
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="systemd.network" conditional='ENABLE_NETWORKD'>
25
26         <refentryinfo>
27                 <title>systemd.network</title>
28                 <productname>systemd</productname>
29
30                 <authorgroup>
31                         <author>
32                                 <contrib>Developer</contrib>
33                                 <firstname>Tom</firstname>
34                                 <surname>Gundersen</surname>
35                                 <email>teg@jklm.no</email>
36                         </author>
37                 </authorgroup>
38         </refentryinfo>
39
40         <refmeta>
41                 <refentrytitle>systemd.network</refentrytitle>
42                 <manvolnum>5</manvolnum>
43         </refmeta>
44
45         <refnamediv>
46                 <refname>systemd.network</refname>
47                 <refpurpose>Network configuration</refpurpose>
48         </refnamediv>
49
50         <refsynopsisdiv>
51                 <para><filename><replaceable>network</replaceable>.network</filename></para>
52         </refsynopsisdiv>
53
54         <refsect1>
55                 <title>Description</title>
56
57                 <para>Network setup is performed by
58                 <citerefentry><refentrytitle>systemd-networkd</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
59                 </para>
60
61                 <para>Network files must have the extension <filename>.network</filename>;
62                 other extensions are ignored. Networks are applied to links whenever the links
63                 appear.</para>
64
65                 <para>The <filename>.network</filename> files are read from the files located in the
66                 system network directory <filename>/usr/lib/systemd/network</filename>,
67                 the volatile runtime network directory
68                 <filename>/run/systemd/network</filename> and the local administration
69                 network directory <filename>/etc/systemd/network</filename>.
70                 All configuration files are collectively sorted and processed in lexical order,
71                 regardless of the directories in which they live. However, files with
72                 identical filenames replace each other. Files in
73                 <filename>/etc</filename> have the highest priority, files in
74                 <filename>/run</filename> take precedence over files with the same
75                 name in <filename>/usr/lib</filename>. This can be used to override a
76                 system-supplied configuration file with a local file if needed; a symlink in
77                 <filename>/etc</filename> with the same name as a configuration file in
78                 <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>,
79                 disables the configuration file entirely.</para>
80
81                         <para>The network file contains a <literal>[Match]</literal> section,
82                         which determines if a given network file may be applied to a given device;
83                         and a <literal>[Network]</literal> section specifying how the device should
84                         be configured. The first (in lexical order) of the network files that
85                         matches a given device is applied.</para>
86
87                         <para>A network file is said to match a device if each of the entries in the
88                         <literal>[Match]</literal> section matches, or if the section is empty.
89                         The following keys are accepted:</para>
90
91                         <variablelist class='network-directives'>
92                                 <varlistentry>
93                                         <term><varname>MACAddress=</varname></term>
94                                         <listitem>
95                                                 <para>The hardware address.</para>
96                                         </listitem>
97                                 </varlistentry>
98                                 <varlistentry>
99                                         <term><varname>Path=</varname></term>
100                                         <listitem>
101                                                 <para>The persistent path, as exposed by the udev
102                                                 property <literal>ID_PATH</literal>. May contain shell
103                                                 style globs.</para>
104                                         </listitem>
105                                 </varlistentry>
106                                 <varlistentry>
107                                         <term><varname>Driver=</varname></term>
108                                         <listitem>
109                                                 <para>The driver currently bound to the device, as
110                                                 exposed by the udev property <literal>DRIVER</literal>
111                                                 of its parent device, or if that is not set the driver
112                                                 as exposed by <literal>ethtool -i</literal> of the
113                                                 device itself.</para>
114                                         </listitem>
115                                 </varlistentry>
116                                 <varlistentry>
117                                         <term><varname>Type=</varname></term>
118                                         <listitem>
119                                                 <para>The device type, as exposed by the udev property
120                                                 <literal>DEVTYPE</literal>.</para>
121                                         </listitem>
122                                 </varlistentry>
123                                 <varlistentry>
124                                         <term><varname>Name=</varname></term>
125                                         <listitem>
126                                                 <para>The device name, as exposed by the udev property
127                                                 <literal>INTERFACE</literal>. May contain shell style
128                                                 globs.</para>
129                                         </listitem>
130                                 </varlistentry>
131                                 <varlistentry>
132                                         <term><varname>Host=</varname></term>
133                                         <listitem>
134                                                 <para>Matches against the hostname or machine ID of the
135                                                 host. See <literal>ConditionHost=</literal> in
136                                                 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
137                                                 for details.
138                                                 </para>
139                                         </listitem>
140                                 </varlistentry>
141                                 <varlistentry>
142                                         <term><varname>Virtualization=</varname></term>
143                                         <listitem>
144                                                 <para>Checks whether the system is executed in a virtualized
145                                                 environment and optionally test whether it is a specific
146                                                 implementation. See <literal>ConditionVirtualization=</literal> in
147                                                 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
148                                                 for details.
149                                                 </para>
150                                         </listitem>
151                                 </varlistentry>
152                                 <varlistentry>
153                                         <term><varname>KernelCommandLine=</varname></term>
154                                         <listitem>
155                                                 <para>Checks whether a specific kernel command line option is
156                                                 set (or if prefixed with the exclamation mark unset). See
157                                                 <literal>ConditionKernelCommandLine=</literal> in
158                                                 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
159                                                 for details.
160                                                 </para>
161                                         </listitem>
162                                 </varlistentry>
163                                 <varlistentry>
164                                         <term><varname>Architecture=</varname></term>
165                                         <listitem>
166                                                 <para>Checks whether the system is running on a specific
167                                                 architecture. See <literal>ConditionArchitecture=</literal> in
168                                                 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
169                                                 for details.
170                                                 </para>
171                                         </listitem>
172                                 </varlistentry>
173                         </variablelist>
174
175                         <para>The <literal>[Network]</literal> section accepts the following keys:</para>
176
177                         <variablelist class='network-directives'>
178                                 <varlistentry>
179                                         <term><varname>Description=</varname></term>
180                                         <listitem>
181                                                 <para>A description of the device. This is only used for
182                                                 presentation purposes.</para>
183                                         </listitem>
184                                 </varlistentry>
185                                 <varlistentry>
186                                         <term><varname>DHCP=</varname></term>
187                                         <listitem>
188                                                 <para>A boolean. When true, enables basic DHCPv4 support.</para>
189                                         </listitem>
190                                 </varlistentry>
191                                 <varlistentry>
192                                         <term><varname>Address=</varname></term>
193                                         <listitem>
194                                                 <para>A static IPv4 or IPv6 address and its prefix length,
195                                                 separated by a <literal>/</literal> character. Specify this
196                                                 key more than once to configure several addresses.
197                                                 The format of the address must be as described in
198                                                 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>
199                                                 . This is a short-hand for an [Address] section only containing an Address key (see below).
200                                                 </para>
201                                         </listitem>
202                                 </varlistentry>
203                                 <varlistentry>
204                                         <term><varname>Gateway=</varname></term>
205                                         <listitem>
206                                                 <para>The gateway address, which must be in the format described in
207                                                 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>
208                                                 . This is a short-hand for a [Route] section only containing a Gateway key.</para>
209                                         </listitem>
210                                 </varlistentry>
211                                 <varlistentry>
212                                         <term><varname>DNS=</varname></term>
213                                         <listitem>
214                                                 <para>A DNS server address, which must be in the format described in
215                                                 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>
216                                                 .</para>
217                                         </listitem>
218                                 </varlistentry>
219                                 <varlistentry>
220                                         <term><varname>Bridge=</varname></term>
221                                         <listitem>
222                                                 <para>The name of the bridge to add the link to.</para>
223                                         </listitem>
224                                 </varlistentry>
225                                 <varlistentry>
226                                         <term><varname>Bond=</varname></term>
227                                         <listitem>
228                                                 <para>The name of the bond to add the link to.</para>
229                                         </listitem>
230                                 </varlistentry>
231                                 <varlistentry>
232                                         <term><varname>VLAN=</varname></term>
233                                         <listitem>
234                                                 <para>The name of a VLAN to create on the link. This option
235                                                 may be specified more than once.</para>
236                                         </listitem>
237                                 </varlistentry>
238                                 <varlistentry>
239                                         <term><varname>MACVLAN=</varname></term>
240                                         <listitem>
241                                                 <para>The name of a MACVLAN to create on the link. This option
242                                                 may be specified more than once.</para>
243                                         </listitem>
244                                 </varlistentry>
245                         </variablelist>
246
247                         <para>An <literal>[Address]</literal> section accepts the following keys.
248                         Specify several <literal>[Address]</literal> sections to configure several
249                         addresses.</para>
250
251                         <variablelist class='network-directives'>
252                                 <varlistentry>
253                                         <term><varname>Address=</varname></term>
254                                         <listitem>
255                                                 <para>As in the <literal>[Network]</literal> section. This key is mandatory.</para>
256                                         </listitem>
257                                 </varlistentry>
258                                 <varlistentry>
259                                         <term><varname>Broadcast=</varname></term>
260                                         <listitem>
261                                                 <para>The broadcast address, which must be in the format described in
262                                                 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>
263                                                 . This key only applies to IPv4 addresses. If it is not given, it is
264                                                 derived from the <literal>Address</literal> key.</para>
265                                         </listitem>
266                                 </varlistentry>
267                                 <varlistentry>
268                                         <term><varname>Label=</varname></term>
269                                         <listitem>
270                                                 <para>An address label.</para>
271                                         </listitem>
272                                 </varlistentry>
273                         </variablelist>
274
275                         <para>The <literal>[Route]</literal> section accepts the following keys. Specify
276                         several <literal>[Route]</literal> sections to configure several routes.</para>
277
278                         <variablelist class='network-directives'>
279                                 <varlistentry>
280                                         <term><varname>Gateway=</varname></term>
281                                         <listitem>
282                                                 <para>As in the <literal>[Network]</literal> section. This key is mandatory.</para>
283                                         </listitem>
284                                 </varlistentry>
285                                 <varlistentry>
286                                         <term><varname>Destination=</varname></term>
287                                         <listitem>
288                                                 <para>The destination prefix of the route. Possibly followed by a slash and the
289                                                 prefixlength, if ommitted a full-length host route is assumed.</para>
290                                         </listitem>
291                                 </varlistentry>
292                         </variablelist>
293
294                         <para>The <literal>[DHCPv4]</literal> section accepts the following keys:</para>
295
296                         <variablelist class='network-directives'>
297                                 <varlistentry>
298                                         <term><varname>UseDNS=</varname></term>
299                                         <listitem>
300                                                 <para>When true (the default), the DNS servers received from the DHCP server will
301                                                 be used and take precedence over any statically configured ones.</para>
302                                         </listitem>
303                                 </varlistentry>
304                                 <varlistentry>
305                                         <term><varname>UseMTU=</varname></term>
306                                         <listitem>
307                                                 <para>When true, the interface maximum transmission unit from the DHCP server will
308                                                 be used on the current link. Defaults to false.</para>
309                                         </listitem>
310                                 </varlistentry>
311                                 <varlistentry>
312                                         <term><varname>UseHostname=</varname></term>
313                                         <listitem>
314                                                 <para>When true (the default), the hostname received from the DHCP server
315                                                 will be used as the transient hostname.</para>
316                                         </listitem>
317                                 </varlistentry>
318                                 <varlistentry>
319                                         <term><varname>CriticalConnection=</varname></term>
320                                         <listitem>
321                                                 <para>When true, the connection will never be torn down even if the DHCP lease
322                                                 expires. This is contrary to the DHCP specification, but may be the best choice
323                                                 if, say, the root filesystem relies on this connection. Defaults to false.</para>
324                                         </listitem>
325                                 </varlistentry>
326                        </variablelist>
327
328         </refsect1>
329
330         <refsect1>
331                 <title>Example</title>
332                 <example>
333                         <title>/etc/systemd/network/50-static.network</title>
334
335                         <programlisting>[Match]
336 Name=enp2s0
337
338 [Network]
339 Address=192.168.0.15/24
340 Gateway=192.168.0.1</programlisting>
341                 </example>
342
343                 <example>
344                         <title>/etc/systemd/network/80-dhcp.network</title>
345
346                         <programlisting>[Match]
347 Name=en*
348
349 [Network]
350 DHCP=yes</programlisting>
351                 </example>
352
353         </refsect1>
354
355         <refsect1>
356                 <title>See Also</title>
357                 <para>
358                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
359                         <citerefentry><refentrytitle>systemd-networkd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
360                 </para>
361         </refsect1>
362
363 </refentry>