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>[Link] Section Options</title>
185 <para> The <literal>[Link]</literal> section accepts the following keys:</para>
187 <variablelist class='network-directives'>
189 <term><varname>MACAddress=</varname></term>
191 <para>The hardware address.</para>
195 <term><varname>MTUBytes=</varname></term>
197 <para>The maximum transmission unit in bytes to
198 set for the device. The usual suffixes K, M, G,
199 are supported and are understood to the base of
207 <title>[Network] Section Options</title>
209 <para>The <literal>[Network]</literal> section accepts the following keys:</para>
211 <variablelist class='network-directives'>
213 <term><varname>Description=</varname></term>
215 <para>A description of the device. This is only used for
216 presentation purposes.</para>
220 <term><varname>DHCP=</varname></term>
222 <para>Enables DHCPv4 and/or DHCPv6 support. Accepts
223 <literal>both</literal>, <literal>none</literal>,
224 <literal>v4</literal> or <literal>v6</literal>.</para>
228 <term><varname>DHCPServer=</varname></term>
230 <para>A boolean. Enables a basic DHCPv4 server on the
231 device. Mostly useful for handing out leases to container
236 <term><varname>IPv4LL=</varname></term>
238 <para>A boolean. When true, enables IPv4 link-local support.
243 <term><varname>IPv4LLRoute=</varname></term>
245 <para>A boolean. When true, sets up the route needed for
246 non-IPv4LL hosts to communicate with IPv4LL-only hosts. Defaults
252 <term><varname>LLMNR=</varname></term>
254 <para>A boolean or <literal>resolve</literal>. When true, enables
255 Link-Local Multicast Name Resolution on the link, when set to
256 <literal>resolve</literal> only resolution is enabled, but not
257 announcement. Defaults to true.</para>
261 <term><varname>LLDP=</varname></term>
263 <para>A boolean. When true, enables LLDP link receive support.
268 <term><varname>Address=</varname></term>
270 <para>A static IPv4 or IPv6 address and its prefix length,
271 separated by a <literal>/</literal> character. Specify this
272 key more than once to configure several addresses.
273 The format of the address must be as described in
274 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
275 This is a short-hand for an [Address] section only containing
276 an Address key (see below). This option may be specified
280 <para>If the specified
295 configuration files to
297 conflicts. The default
310 with the same network
319 <term><varname>Gateway=</varname></term>
321 <para>The gateway address, which must be in the format described in
322 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
323 This is a short-hand for a [Route] section only containing a Gateway
324 key. This option may be specified more than once.</para>
328 <term><varname>DNS=</varname></term>
330 <para>A DNS server address, which must be in the format described in
331 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
332 This option may be specified more than once.</para>
336 <term><varname>Domains=</varname></term>
338 <para>The domains used for DNS resolution over this link.</para>
342 <term><varname>NTP=</varname></term>
344 <para>An NTP server address. This option may be specified more than once.</para>
348 <term><varname>Bridge=</varname></term>
350 <para>The name of the bridge to add the link to.</para>
354 <term><varname>Bond=</varname></term>
356 <para>The name of the bond to add the link to.</para>
360 <term><varname>VLAN=</varname></term>
362 <para>The name of a VLAN to create on the link. This option
363 may be specified more than once.</para>
367 <term><varname>MACVLAN=</varname></term>
369 <para>The name of a MACVLAN to create on the link. This option
370 may be specified more than once.</para>
374 <term><varname>VXLAN=</varname></term>
376 <para>The name of a VXLAN to create on the link. This option
377 may be specified more than once.</para>
381 <term><varname>Tunnel=</varname></term>
383 <para>The name of a Tunnel to create on the link. This option
384 may be specified more than once.</para>
392 <title>[Address] Section Options</title>
394 <para>An <literal>[Address]</literal> section accepts the following keys.
395 Specify several <literal>[Address]</literal> sections to configure several
398 <variablelist class='network-directives'>
400 <term><varname>Address=</varname></term>
402 <para>As in the <literal>[Network]</literal> section. This key is mandatory.</para>
406 <term><varname>Peer=</varname></term>
408 <para>The peer address in a point-to-point connection. Accepts the same format as
409 the <literal>Address</literal> key.</para>
413 <term><varname>Broadcast=</varname></term>
415 <para>The broadcast address, which must be in the format described in
416 <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
417 This key only applies to IPv4 addresses. If it is not given, it is
418 derived from the <literal>Address</literal> key.</para>
422 <term><varname>Label=</varname></term>
424 <para>An address label.</para>
431 <title>[Route] Section Options</title>
432 <para>The <literal>[Route]</literal> section accepts the following keys. Specify
433 several <literal>[Route]</literal> sections to configure several routes.</para>
435 <variablelist class='network-directives'>
437 <term><varname>Gateway=</varname></term>
439 <para>As in the <literal>[Network]</literal> section.</para>
443 <term><varname>Destination=</varname></term>
445 <para>The destination prefix of the route. Possibly followed by a slash and the
446 prefixlength. If omitted, a full-length host route is assumed.</para>
450 <term><varname>Source=</varname></term>
452 <para>The source prefix of the route. Possibly followed by a slash and the
453 prefixlength. If omitted, a full-length host route is assumed.</para>
457 <term><varname>Metric=</varname></term>
459 <para>The metric of the route. An unsigned integer</para>
466 <title>[DHCP] Section Options</title>
467 <para>The <literal>[DHCP]</literal> section accepts the following keys:</para>
469 <variablelist class='network-directives'>
471 <term><varname>UseDNS=</varname></term>
473 <para>When true (the default), the DNS servers received from the DHCP server will
474 be used and take precedence over any statically configured ones.</para>
478 <term><varname>UseMTU=</varname></term>
480 <para>When true, the interface maximum transmission unit from the DHCP server will
481 be used on the current link. Defaults to false.</para>
485 <term><varname>SendHostname=</varname></term>
487 <para>When true (the default), the machine's hostname will be sent to the DHCP
492 <term><varname>UseHostname=</varname></term>
494 <para>When true (the default), the hostname received from the DHCP server
495 will be used as the transient hostname.</para>
499 <term><varname>UseDomains=</varname></term>
501 <para>When true (not the default), the domain name received from the DHCP server
502 will be used for DNS resolution over this link.</para>
506 <term><varname>UseRoutes=</varname></term>
508 <para>When true (the default), the static routes will be requested from the DHCP server
509 and added to the routing table with metric of 1024.</para>
513 <term><varname>CriticalConnection=</varname></term>
515 <para>When true, the connection will never be torn down even if the DHCP lease
516 expires. This is contrary to the DHCP specification, but may be the best choice
517 if, say, the root filesystem relies on this connection. Defaults to false.</para>
521 <term><varname>VendorClassIdentifier=</varname></term>
523 <para>The vendor class identifier used to identify vendor type and configuration.</para>
527 <term><varname>RequestBroadcast=</varname></term>
529 <para>Request the server to use broadcast messages before the IP address has been
530 configured. This is necessary for devices that cannot receive RAW packets, or that
531 cannot receive packets at all before an IP address has been configured. On the other
532 hand, this must not be enabled on networks where broadcasts are filtered out.</para>
536 <term><varname>RouteMetric=</varname></term>
538 <para>Set the routing metric for routes specified by the DHCP server.</para>
546 <title>[Bridge] Section Options</title>
547 <para>The <literal>[Bridge]</literal> section accepts the following keys.</para>
548 <variablelist class='network-directives'>
550 <term><varname>Cost=</varname></term>
552 <para>Each port in a bridge may have different speed. Cost is used to decide which link to use. Faster interfaces should have lower costs</para>
559 <title>[BridgeFDB] Section Options</title>
560 <para>The <literal>[BridgeFDB]</literal> section manages the forwarding database table of a port and accepts the following keys. Specify
561 several <literal>[BridgeFDB]</literal> sections to configure several static MAC table entries.</para>
563 <variablelist class='network-directives'>
565 <term><varname>MACAddress=</varname></term>
567 <para>As in the <literal>[Network]</literal> section. This key is mandatory.</para>
571 <term><varname>VLANId=</varname></term>
573 <para>The VLAN Id for the new static MAC table entry.
574 If omitted, no VLAN Id info is appended to the new static MAC table entry.</para>
581 <title>Example</title>
583 <title>/etc/systemd/network/50-static.network</title>
585 <programlisting>[Match]
589 Address=192.168.0.15/24
590 Gateway=192.168.0.1</programlisting>
594 <title>/etc/systemd/network/80-dhcp.network</title>
596 <programlisting>[Match]
600 DHCP=both</programlisting>
604 <title>/etc/systemd/network/bridge-static.network</title>
606 <programlisting>[Match]
610 Address=192.168.0.15/24
612 DNS=192.168.0.1</programlisting>
616 <title>/etc/systemd/network/bridge-slave-interface.network</title>
618 <programlisting>[Match]
622 Bridge=bridge0</programlisting>
625 <title>/etc/systemd/network/ipip.network</title>
627 <programlisting>[Match]
631 Tunnel=ipip-tun</programlisting>
635 <title>/etc/systemd/network/sit.network</title>
637 <programlisting>[Match]
641 Tunnel=sit-tun</programlisting>
645 <title>/etc/systemd/network/gre.network</title>
647 <programlisting>[Match]
651 Tunnel=gre-tun</programlisting>
655 <title>/etc/systemd/network/vti.network</title>
657 <programlisting>[Match]
661 Tunnel=vti-tun</programlisting>
666 <title>See Also</title>
668 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
669 <citerefentry><refentrytitle>systemd-networkd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
670 <citerefentry><refentrytitle>systemd.netdev</refentrytitle><manvolnum>5</manvolnum></citerefentry>