chiark / gitweb /
48e33ac4d43bba9c7d164c3bf331dadf77bded27
[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>IPv4LL=</varname></term>
193                                         <listitem>
194                                                 <para>A boolean. When true, enables IPv4 link-local support.
195                                                 If <literal>DHCP=</literal> is also true, acquiring DHCP address
196                                                 will deprecate previously acquired IPv4 link-local address or
197                                                 stop acquiring process if one has not been acquired before.
198                                                 </para>
199                                         </listitem>
200                                 </varlistentry>
201                                 <varlistentry>
202                                         <term><varname>Address=</varname></term>
203                                         <listitem>
204                                                 <para>A static IPv4 or IPv6 address and its prefix length,
205                                                 separated by a <literal>/</literal> character. Specify this
206                                                 key more than once to configure several addresses.
207                                                 The format of the address must be as described in
208                                                 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
209                                                 This is a short-hand for an [Address] section only containing
210                                                 an Address key (see below). This option may be specified
211                                                 more than once.
212                                                 </para>
213                                         </listitem>
214                                 </varlistentry>
215                                 <varlistentry>
216                                         <term><varname>Gateway=</varname></term>
217                                         <listitem>
218                                                 <para>The gateway address, which must be in the format described in
219                                                 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
220                                                 This is a short-hand for a [Route] section only containing a Gateway
221                                                 key. This option may be specified more than once.</para>
222                                         </listitem>
223                                 </varlistentry>
224                                 <varlistentry>
225                                         <term><varname>DNS=</varname></term>
226                                         <listitem>
227                                                 <para>A DNS server address, which must be in the format described in
228                                                 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
229                                                 This option may be specified more than once.</para>
230                                         </listitem>
231                                 </varlistentry>
232                                 <varlistentry>
233                                         <term><varname>Bridge=</varname></term>
234                                         <listitem>
235                                                 <para>The name of the bridge to add the link to.</para>
236                                         </listitem>
237                                 </varlistentry>
238                                 <varlistentry>
239                                         <term><varname>Bond=</varname></term>
240                                         <listitem>
241                                                 <para>The name of the bond to add the link to.</para>
242                                         </listitem>
243                                 </varlistentry>
244                                 <varlistentry>
245                                         <term><varname>VLAN=</varname></term>
246                                         <listitem>
247                                                 <para>The name of a VLAN to create on the link. This option
248                                                 may be specified more than once.</para>
249                                         </listitem>
250                                 </varlistentry>
251                                 <varlistentry>
252                                         <term><varname>MACVLAN=</varname></term>
253                                         <listitem>
254                                                 <para>The name of a MACVLAN to create on the link. This option
255                                                 may be specified more than once.</para>
256                                         </listitem>
257                                 </varlistentry>
258                         </variablelist>
259
260                         <para>An <literal>[Address]</literal> section accepts the following keys.
261                         Specify several <literal>[Address]</literal> sections to configure several
262                         addresses.</para>
263
264                         <variablelist class='network-directives'>
265                                 <varlistentry>
266                                         <term><varname>Address=</varname></term>
267                                         <listitem>
268                                                 <para>As in the <literal>[Network]</literal> section. This key is mandatory.</para>
269                                         </listitem>
270                                 </varlistentry>
271                                 <varlistentry>
272                                         <term><varname>Broadcast=</varname></term>
273                                         <listitem>
274                                                 <para>The broadcast address, which must be in the format described in
275                                                 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>
276                                                 . This key only applies to IPv4 addresses. If it is not given, it is
277                                                 derived from the <literal>Address</literal> key.</para>
278                                         </listitem>
279                                 </varlistentry>
280                                 <varlistentry>
281                                         <term><varname>Label=</varname></term>
282                                         <listitem>
283                                                 <para>An address label.</para>
284                                         </listitem>
285                                 </varlistentry>
286                         </variablelist>
287
288                         <para>The <literal>[Route]</literal> section accepts the following keys. Specify
289                         several <literal>[Route]</literal> sections to configure several routes.</para>
290
291                         <variablelist class='network-directives'>
292                                 <varlistentry>
293                                         <term><varname>Gateway=</varname></term>
294                                         <listitem>
295                                                 <para>As in the <literal>[Network]</literal> section. This key is mandatory.</para>
296                                         </listitem>
297                                 </varlistentry>
298                                 <varlistentry>
299                                         <term><varname>Destination=</varname></term>
300                                         <listitem>
301                                                 <para>The destination prefix of the route. Possibly followed by a slash and the
302                                                 prefixlength, if ommitted a full-length host route is assumed.</para>
303                                         </listitem>
304                                 </varlistentry>
305                         </variablelist>
306
307                         <para>The <literal>[DHCPv4]</literal> section accepts the following keys:</para>
308
309                         <variablelist class='network-directives'>
310                                 <varlistentry>
311                                         <term><varname>UseDNS=</varname></term>
312                                         <listitem>
313                                                 <para>When true (the default), the DNS servers received from the DHCP server will
314                                                 be used and take precedence over any statically configured ones.</para>
315                                         </listitem>
316                                 </varlistentry>
317                                 <varlistentry>
318                                         <term><varname>UseMTU=</varname></term>
319                                         <listitem>
320                                                 <para>When true, the interface maximum transmission unit from the DHCP server will
321                                                 be used on the current link. Defaults to false.</para>
322                                         </listitem>
323                                 </varlistentry>
324                                 <varlistentry>
325                                         <term><varname>UseHostname=</varname></term>
326                                         <listitem>
327                                                 <para>When true (the default), the hostname received from the DHCP server
328                                                 will be used as the transient hostname.</para>
329                                         </listitem>
330                                 </varlistentry>
331                                 <varlistentry>
332                                         <term><varname>CriticalConnection=</varname></term>
333                                         <listitem>
334                                                 <para>When true, the connection will never be torn down even if the DHCP lease
335                                                 expires. This is contrary to the DHCP specification, but may be the best choice
336                                                 if, say, the root filesystem relies on this connection. Defaults to false.</para>
337                                         </listitem>
338                                 </varlistentry>
339                        </variablelist>
340
341         </refsect1>
342
343         <refsect1>
344                 <title>Example</title>
345                 <example>
346                         <title>/etc/systemd/network/50-static.network</title>
347
348                         <programlisting>[Match]
349 Name=enp2s0
350
351 [Network]
352 Address=192.168.0.15/24
353 Gateway=192.168.0.1</programlisting>
354                 </example>
355
356                 <example>
357                         <title>/etc/systemd/network/80-dhcp.network</title>
358
359                         <programlisting>[Match]
360 Name=en*
361
362 [Network]
363 DHCP=yes</programlisting>
364                 </example>
365
366                 <example>
367                         <title>/etc/systemd/network/bridge-static.network</title>
368
369                         <programlisting>[Match]
370 Name=bridge0
371
372 [Network]
373 Address=192.168.0.15/24
374 Gateway=192.168.0.1
375 DNS=192.168.0.1</programlisting>
376                 </example>
377
378                 <example>
379                         <title>/etc/systemd/network/bridge-slave-interface.network</title>
380
381                         <programlisting>[Match]
382 Name=enp2s0
383
384 [Network]
385 Bridge=bridge0</programlisting>
386                 </example>
387         </refsect1>
388
389         <refsect1>
390                 <title>See Also</title>
391                 <para>
392                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
393                         <citerefentry><refentrytitle>systemd-networkd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
394                         <citerefentry><refentrytitle>systemd.netdev</refentrytitle><manvolnum>5</manvolnum></citerefentry>
395                 </para>
396         </refsect1>
397
398 </refentry>