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">
6 This file is part of systemd.
8 Copyright 2013 Tom Gundersen
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.
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.
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/>.
24 <refentry id="systemd.network" conditional='ENABLE_NETWORKD'>
27 <title>systemd.network</title>
28 <productname>systemd</productname>
32 <contrib>Developer</contrib>
33 <firstname>Tom</firstname>
34 <surname>Gundersen</surname>
35 <email>teg@jklm.no</email>
41 <refentrytitle>systemd.network</refentrytitle>
42 <manvolnum>5</manvolnum>
46 <refname>systemd.network</refname>
47 <refpurpose>Network configuration</refpurpose>
51 <para><filename><replaceable>network</replaceable>.network</filename></para>
55 <title>Description</title>
57 <para>Network setup is performed by
58 <citerefentry><refentrytitle>systemd-networkd</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
61 <para>Network files must have the extension <filename>.network</filename>;
62 other extensions are ignored. Networks are applied to links whenever the links
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>
84 <title>[Match] Section Options</title>
86 <para>The network file contains a <literal>[Match]</literal> section,
87 which determines if a given network file may be applied to a given device;
88 and a <literal>[Network]</literal> section specifying how the device should
89 be configured. The first (in lexical order) of the network files that
90 matches a given device is applied.</para>
92 <para>A network file is said to match a device if each of the entries in the
93 <literal>[Match]</literal> section matches, or if the section is empty.
94 The following keys are accepted:</para>
96 <variablelist class='network-directives'>
98 <term><varname>MACAddress=</varname></term>
100 <para>The hardware address.</para>
104 <term><varname>Path=</varname></term>
106 <para>The persistent path, as exposed by the udev
107 property <literal>ID_PATH</literal>. May contain shell
112 <term><varname>Driver=</varname></term>
114 <para>The driver currently bound to the device, as
115 exposed by the udev property <literal>DRIVER</literal>
116 of its parent device, or if that is not set the driver
117 as exposed by <literal>ethtool -i</literal> of the
118 device itself.</para>
122 <term><varname>Type=</varname></term>
124 <para>The device type, as exposed by the udev property
125 <literal>DEVTYPE</literal>.</para>
129 <term><varname>Name=</varname></term>
131 <para>The device name, as exposed by the udev property
132 <literal>INTERFACE</literal>. May contain shell style
137 <term><varname>Host=</varname></term>
139 <para>Matches against the hostname or machine ID of the
140 host. See <literal>ConditionHost=</literal> in
141 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
147 <term><varname>Virtualization=</varname></term>
149 <para>Checks whether the system is executed in a virtualized
150 environment and optionally test whether it is a specific
151 implementation. See <literal>ConditionVirtualization=</literal> in
152 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
158 <term><varname>KernelCommandLine=</varname></term>
160 <para>Checks whether a specific kernel command line option is
161 set (or if prefixed with the exclamation mark unset). See
162 <literal>ConditionKernelCommandLine=</literal> in
163 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
169 <term><varname>Architecture=</varname></term>
171 <para>Checks whether the system is running on a specific
172 architecture. See <literal>ConditionArchitecture=</literal> in
173 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
183 <title>[Network] Section Options</title>
185 <para>The <literal>[Network]</literal> section accepts the following keys:</para>
187 <variablelist class='network-directives'>
189 <term><varname>Description=</varname></term>
191 <para>A description of the device. This is only used for
192 presentation purposes.</para>
196 <term><varname>DHCP=</varname></term>
198 <para>Enables DHCPv4 and/or DHCPv6 support. Accepts
199 <literal>both</literal>, <literal>none</literal>,
200 <literal>v4</literal> or <literal>v6</literal>.</para>
204 <term><varname>DHCPServer=</varname></term>
206 <para>A boolean. Enables a basic DHCPv4 server on the
207 device. Mostly useful for handing out leases to container
212 <term><varname>IPv4LL=</varname></term>
214 <para>A boolean. When true, enables IPv4 link-local support.
215 If <literal>DHCP=</literal> is also true, acquiring DHCP address
216 will deprecate previously acquired IPv4 link-local address or
217 stop acquiring process if one has not been acquired before.
222 <term><varname>Address=</varname></term>
224 <para>A static IPv4 or IPv6 address and its prefix length,
225 separated by a <literal>/</literal> character. Specify this
226 key more than once to configure several addresses.
227 The format of the address must be as described in
228 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
229 This is a short-hand for an [Address] section only containing
230 an Address key (see below). This option may be specified
234 <para>If the specified
249 configuration files to
251 conflicts. The default
264 with the same network
273 <term><varname>Gateway=</varname></term>
275 <para>The gateway address, which must be in the format described in
276 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
277 This is a short-hand for a [Route] section only containing a Gateway
278 key. This option may be specified more than once.</para>
282 <term><varname>DNS=</varname></term>
284 <para>A DNS server address, which must be in the format described in
285 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
286 This option may be specified more than once.</para>
289 <!-- TODO: document NTP= option when it is actually used somewhere -->
291 <term><varname>Bridge=</varname></term>
293 <para>The name of the bridge to add the link to.</para>
297 <term><varname>Bond=</varname></term>
299 <para>The name of the bond to add the link to.</para>
303 <term><varname>VLAN=</varname></term>
305 <para>The name of a VLAN to create on the link. This option
306 may be specified more than once.</para>
310 <term><varname>MACVLAN=</varname></term>
312 <para>The name of a MACVLAN to create on the link. This option
313 may be specified more than once.</para>
317 <term><varname>VXLAN=</varname></term>
319 <para>The name of a VXLAN to create on the link. This option
320 may be specified more than once.</para>
324 <term><varname>Tunnel=</varname></term>
326 <para>The name of a Tunnel to create on the link. This option
327 may be specified more than once.</para>
335 <title>[Address] Section Options</title>
337 <para>An <literal>[Address]</literal> section accepts the following keys.
338 Specify several <literal>[Address]</literal> sections to configure several
341 <variablelist class='network-directives'>
343 <term><varname>Address=</varname></term>
345 <para>As in the <literal>[Network]</literal> section. This key is mandatory.</para>
349 <term><varname>Broadcast=</varname></term>
351 <para>The broadcast address, which must be in the format described in
352 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
353 This key only applies to IPv4 addresses. If it is not given, it is
354 derived from the <literal>Address</literal> key.</para>
358 <term><varname>Label=</varname></term>
360 <para>An address label.</para>
367 <title>[Route] Section Options</title>
368 <para>The <literal>[Route]</literal> section accepts the following keys. Specify
369 several <literal>[Route]</literal> sections to configure several routes.</para>
371 <variablelist class='network-directives'>
373 <term><varname>Gateway=</varname></term>
375 <para>As in the <literal>[Network]</literal> section. This key is mandatory.</para>
379 <term><varname>Destination=</varname></term>
381 <para>The destination prefix of the route. Possibly followed by a slash and the
382 prefixlength. If ommitted, a full-length host route is assumed.</para>
389 <title>[DHCP] Section Options</title>
390 <para>The <literal>[DHCP]</literal> section accepts the following keys:</para>
392 <variablelist class='network-directives'>
394 <term><varname>UseDNS=</varname></term>
396 <para>When true (the default), the DNS servers received from the DHCP server will
397 be used and take precedence over any statically configured ones.</para>
401 <term><varname>UseMTU=</varname></term>
403 <para>When true, the interface maximum transmission unit from the DHCP server will
404 be used on the current link. Defaults to false.</para>
408 <term><varname>SendHostname=</varname></term>
410 <para>When true (the default), the machine's hostname will be sent to the DHCP
415 <term><varname>UseHostname=</varname></term>
417 <para>When true (the default), the hostname received from the DHCP server
418 will be used as the transient hostname.</para>
422 <term><varname>UseRoutes=</varname></term>
424 <para>When true (the default), the static routes will be requested from the DHCP server
425 and added to the routing table with metric of 1024.</para>
429 <term><varname>CriticalConnection=</varname></term>
431 <para>When true, the connection will never be torn down even if the DHCP lease
432 expires. This is contrary to the DHCP specification, but may be the best choice
433 if, say, the root filesystem relies on this connection. Defaults to false.</para>
441 <title>Example</title>
443 <title>/etc/systemd/network/50-static.network</title>
445 <programlisting>[Match]
449 Address=192.168.0.15/24
450 Gateway=192.168.0.1</programlisting>
454 <title>/etc/systemd/network/80-dhcp.network</title>
456 <programlisting>[Match]
460 DHCP=yes</programlisting>
464 <title>/etc/systemd/network/bridge-static.network</title>
466 <programlisting>[Match]
470 Address=192.168.0.15/24
472 DNS=192.168.0.1</programlisting>
476 <title>/etc/systemd/network/bridge-slave-interface.network</title>
478 <programlisting>[Match]
482 Bridge=bridge0</programlisting>
485 <title>/etc/systemd/network/ipip.network</title>
487 <programlisting>[Match]
491 Tunnel=ipip-tun</programlisting>
495 <title>/etc/systemd/network/sit.network</title>
497 <programlisting>[Match]
501 Tunnel=sit-tun</programlisting>
505 <title>/etc/systemd/network/gre.network</title>
507 <programlisting>[Match]
511 Tunnel=gre-tun</programlisting>
515 <title>/etc/systemd/network/vti.network</title>
517 <programlisting>[Match]
521 Tunnel=vti-tun</programlisting>
526 <title>See Also</title>
528 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
529 <citerefentry><refentrytitle>systemd-networkd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
530 <citerefentry><refentrytitle>systemd.netdev</refentrytitle><manvolnum>5</manvolnum></citerefentry>