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>
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>
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>
91 <variablelist class='network-directives'>
93 <term><varname>MACAddress=</varname></term>
95 <para>The hardware address.</para>
99 <term><varname>Path=</varname></term>
101 <para>The persistent path, as exposed by the udev
102 property <literal>ID_PATH</literal>. May contain shell
107 <term><varname>Driver=</varname></term>
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>
117 <term><varname>Type=</varname></term>
119 <para>The device type, as exposed by the udev property
120 <literal>DEVTYPE</literal>.</para>
124 <term><varname>Name=</varname></term>
126 <para>The device name, as exposed by the udev property
127 <literal>INTERFACE</literal>. May contain shell style
132 <term><varname>Host=</varname></term>
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>
142 <term><varname>Virtualization=</varname></term>
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>
153 <term><varname>KernelCommandLine=</varname></term>
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>
164 <term><varname>Architecture=</varname></term>
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>
175 <para>The <literal>[Network]</literal> section accepts the following keys:</para>
177 <variablelist class='network-directives'>
179 <term><varname>Description=</varname></term>
181 <para>A description of the device. This is only used for
182 presentation purposes.</para>
186 <term><varname>DHCP=</varname></term>
188 <para>A boolean. When true, enables basic DHCPv4 support.</para>
192 <term><varname>IPv4LL=</varname></term>
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.
201 <term><varname>Address=</varname></term>
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 an Address key (see below).
213 <term><varname>Gateway=</varname></term>
215 <para>The gateway address, which must be in the format described in
216 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>
217 . This is a short-hand for a [Route] section only containing a Gateway key.</para>
221 <term><varname>DNS=</varname></term>
223 <para>A DNS server address, which must be in the format described in
224 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>
229 <term><varname>Bridge=</varname></term>
231 <para>The name of the bridge to add the link to.</para>
235 <term><varname>Bond=</varname></term>
237 <para>The name of the bond to add the link to.</para>
241 <term><varname>VLAN=</varname></term>
243 <para>The name of a VLAN to create on the link. This option
244 may be specified more than once.</para>
248 <term><varname>MACVLAN=</varname></term>
250 <para>The name of a MACVLAN to create on the link. This option
251 may be specified more than once.</para>
256 <para>An <literal>[Address]</literal> section accepts the following keys.
257 Specify several <literal>[Address]</literal> sections to configure several
260 <variablelist class='network-directives'>
262 <term><varname>Address=</varname></term>
264 <para>As in the <literal>[Network]</literal> section. This key is mandatory.</para>
268 <term><varname>Broadcast=</varname></term>
270 <para>The broadcast address, which must be in the format described in
271 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>
272 . This key only applies to IPv4 addresses. If it is not given, it is
273 derived from the <literal>Address</literal> key.</para>
277 <term><varname>Label=</varname></term>
279 <para>An address label.</para>
284 <para>The <literal>[Route]</literal> section accepts the following keys. Specify
285 several <literal>[Route]</literal> sections to configure several routes.</para>
287 <variablelist class='network-directives'>
289 <term><varname>Gateway=</varname></term>
291 <para>As in the <literal>[Network]</literal> section. This key is mandatory.</para>
295 <term><varname>Destination=</varname></term>
297 <para>The destination prefix of the route. Possibly followed by a slash and the
298 prefixlength, if ommitted a full-length host route is assumed.</para>
303 <para>The <literal>[DHCPv4]</literal> section accepts the following keys:</para>
305 <variablelist class='network-directives'>
307 <term><varname>UseDNS=</varname></term>
309 <para>When true (the default), the DNS servers received from the DHCP server will
310 be used and take precedence over any statically configured ones.</para>
314 <term><varname>UseMTU=</varname></term>
316 <para>When true, the interface maximum transmission unit from the DHCP server will
317 be used on the current link. Defaults to false.</para>
321 <term><varname>UseHostname=</varname></term>
323 <para>When true (the default), the hostname received from the DHCP server
324 will be used as the transient hostname.</para>
328 <term><varname>CriticalConnection=</varname></term>
330 <para>When true, the connection will never be torn down even if the DHCP lease
331 expires. This is contrary to the DHCP specification, but may be the best choice
332 if, say, the root filesystem relies on this connection. Defaults to false.</para>
340 <title>Example</title>
342 <title>/etc/systemd/network/50-static.network</title>
344 <programlisting>[Match]
348 Address=192.168.0.15/24
349 Gateway=192.168.0.1</programlisting>
353 <title>/etc/systemd/network/80-dhcp.network</title>
355 <programlisting>[Match]
359 DHCP=yes</programlisting>
365 <title>See Also</title>
367 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
368 <citerefentry><refentrytitle>systemd-networkd</refentrytitle><manvolnum>8</manvolnum></citerefentry>