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