chiark / gitweb /
man: document automatic networkd IP range allocation
[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
214                                                 <para>If the specified
215                                                 address is 0.0.0.0
216                                                 (for IPv4) or [::]
217                                                 (for IPv6) a new
218                                                 address range of the
219                                                 requested size is
220                                                 automatically
221                                                 allocated from a
222                                                 system-wide pool of
223                                                 unused ranges. The
224                                                 allocated range is
225                                                 checked against all
226                                                 current network
227                                                 interfaces and all
228                                                 known network
229                                                 configuration files to
230                                                 avoid IP range
231                                                 conflicts. The default
232                                                 system-wide pool
233                                                 consists of
234                                                 192.168.0.0/16,
235                                                 172.16.0.0/12 and
236                                                 10.0.0.0/8 for IPv4,
237                                                 and [fc00::] for
238                                                 IPv6. This
239                                                 functionality is
240                                                 useful to manage a
241                                                 large number of
242                                                 dynamically created
243                                                 network interfaces
244                                                 with the same network
245                                                 configuration and
246                                                 automatic address
247                                                 range
248                                                 assignment.</para>
249
250                                         </listitem>
251                                 </varlistentry>
252                                 <varlistentry>
253                                         <term><varname>Gateway=</varname></term>
254                                         <listitem>
255                                                 <para>The gateway address, which must be in the format described in
256                                                 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
257                                                 This is a short-hand for a [Route] section only containing a Gateway
258                                                 key. This option may be specified more than once.</para>
259                                         </listitem>
260                                 </varlistentry>
261                                 <varlistentry>
262                                         <term><varname>DNS=</varname></term>
263                                         <listitem>
264                                                 <para>A DNS server address, which must be in the format described in
265                                                 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
266                                                 This option may be specified more than once.</para>
267                                         </listitem>
268                                 </varlistentry>
269                                 <varlistentry>
270                                         <term><varname>Bridge=</varname></term>
271                                         <listitem>
272                                                 <para>The name of the bridge to add the link to.</para>
273                                         </listitem>
274                                 </varlistentry>
275                                 <varlistentry>
276                                         <term><varname>Bond=</varname></term>
277                                         <listitem>
278                                                 <para>The name of the bond to add the link to.</para>
279                                         </listitem>
280                                 </varlistentry>
281                                 <varlistentry>
282                                         <term><varname>VLAN=</varname></term>
283                                         <listitem>
284                                                 <para>The name of a VLAN to create on the link. This option
285                                                 may be specified more than once.</para>
286                                         </listitem>
287                                 </varlistentry>
288                                 <varlistentry>
289                                         <term><varname>MACVLAN=</varname></term>
290                                         <listitem>
291                                                 <para>The name of a MACVLAN to create on the link. This option
292                                                 may be specified more than once.</para>
293                                         </listitem>
294                                 </varlistentry>
295                         </variablelist>
296
297                         <para>An <literal>[Address]</literal> section accepts the following keys.
298                         Specify several <literal>[Address]</literal> sections to configure several
299                         addresses.</para>
300
301                         <variablelist class='network-directives'>
302                                 <varlistentry>
303                                         <term><varname>Address=</varname></term>
304                                         <listitem>
305                                                 <para>As in the <literal>[Network]</literal> section. This key is mandatory.</para>
306                                         </listitem>
307                                 </varlistentry>
308                                 <varlistentry>
309                                         <term><varname>Broadcast=</varname></term>
310                                         <listitem>
311                                                 <para>The broadcast address, which must be in the format described in
312                                                 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
313                                                 This key only applies to IPv4 addresses. If it is not given, it is
314                                                 derived from the <literal>Address</literal> key.</para>
315                                         </listitem>
316                                 </varlistentry>
317                                 <varlistentry>
318                                         <term><varname>Label=</varname></term>
319                                         <listitem>
320                                                 <para>An address label.</para>
321                                         </listitem>
322                                 </varlistentry>
323                         </variablelist>
324
325                         <para>The <literal>[Route]</literal> section accepts the following keys. Specify
326                         several <literal>[Route]</literal> sections to configure several routes.</para>
327
328                         <variablelist class='network-directives'>
329                                 <varlistentry>
330                                         <term><varname>Gateway=</varname></term>
331                                         <listitem>
332                                                 <para>As in the <literal>[Network]</literal> section. This key is mandatory.</para>
333                                         </listitem>
334                                 </varlistentry>
335                                 <varlistentry>
336                                         <term><varname>Destination=</varname></term>
337                                         <listitem>
338                                                 <para>The destination prefix of the route. Possibly followed by a slash and the
339                                                 prefixlength. If ommitted, a full-length host route is assumed.</para>
340                                         </listitem>
341                                 </varlistentry>
342                         </variablelist>
343
344                         <para>The <literal>[DHCPv4]</literal> section accepts the following keys:</para>
345
346                         <variablelist class='network-directives'>
347                                 <varlistentry>
348                                         <term><varname>UseDNS=</varname></term>
349                                         <listitem>
350                                                 <para>When true (the default), the DNS servers received from the DHCP server will
351                                                 be used and take precedence over any statically configured ones.</para>
352                                         </listitem>
353                                 </varlistentry>
354                                 <varlistentry>
355                                         <term><varname>UseMTU=</varname></term>
356                                         <listitem>
357                                                 <para>When true, the interface maximum transmission unit from the DHCP server will
358                                                 be used on the current link. Defaults to false.</para>
359                                         </listitem>
360                                 </varlistentry>
361                                 <varlistentry>
362                                         <term><varname>UseHostname=</varname></term>
363                                         <listitem>
364                                                 <para>When true (the default), the hostname received from the DHCP server
365                                                 will be used as the transient hostname.</para>
366                                         </listitem>
367                                 </varlistentry>
368                                 <varlistentry>
369                                         <term><varname>CriticalConnection=</varname></term>
370                                         <listitem>
371                                                 <para>When true, the connection will never be torn down even if the DHCP lease
372                                                 expires. This is contrary to the DHCP specification, but may be the best choice
373                                                 if, say, the root filesystem relies on this connection. Defaults to false.</para>
374                                         </listitem>
375                                 </varlistentry>
376                        </variablelist>
377
378         </refsect1>
379
380         <refsect1>
381                 <title>Example</title>
382                 <example>
383                         <title>/etc/systemd/network/50-static.network</title>
384
385                         <programlisting>[Match]
386 Name=enp2s0
387
388 [Network]
389 Address=192.168.0.15/24
390 Gateway=192.168.0.1</programlisting>
391                 </example>
392
393                 <example>
394                         <title>/etc/systemd/network/80-dhcp.network</title>
395
396                         <programlisting>[Match]
397 Name=en*
398
399 [Network]
400 DHCP=yes</programlisting>
401                 </example>
402
403                 <example>
404                         <title>/etc/systemd/network/bridge-static.network</title>
405
406                         <programlisting>[Match]
407 Name=bridge0
408
409 [Network]
410 Address=192.168.0.15/24
411 Gateway=192.168.0.1
412 DNS=192.168.0.1</programlisting>
413                 </example>
414
415                 <example>
416                         <title>/etc/systemd/network/bridge-slave-interface.network</title>
417
418                         <programlisting>[Match]
419 Name=enp2s0
420
421 [Network]
422 Bridge=bridge0</programlisting>
423                 </example>
424         </refsect1>
425
426         <refsect1>
427                 <title>See Also</title>
428                 <para>
429                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
430                         <citerefentry><refentrytitle>systemd-networkd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
431                         <citerefentry><refentrytitle>systemd.netdev</refentrytitle><manvolnum>5</manvolnum></citerefentry>
432                 </para>
433         </refsect1>
434
435 </refentry>