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
62 <filename>.network</filename>; other extensions are ignored.
63 Networks are applied to links whenever the links appear.</para>
65 <para>The <filename>.network</filename> files are read from the
66 files located in the system network directory
67 <filename>/usr/lib/systemd/network</filename>, the volatile
68 runtime network directory
69 <filename>/run/systemd/network</filename> and the local
70 administration network directory
71 <filename>/etc/systemd/network</filename>. All configuration files
72 are collectively sorted and processed in lexical order, regardless
73 of the directories in which they live. However, files with
74 identical filenames replace each other. Files in
75 <filename>/etc</filename> have the highest priority, files in
76 <filename>/run</filename> take precedence over files with the same
77 name in <filename>/usr/lib</filename>. This can be used to
78 override a system-supplied configuration file with a local file if
79 needed; a symlink in <filename>/etc</filename> with the same name
80 as a configuration file in <filename>/usr/lib</filename>, pointing
81 to <filename>/dev/null</filename>, disables the configuration file
87 <title>[Match] Section Options</title>
89 <para>The network file contains a <literal>[Match]</literal>
90 section, which determines if a given network file may be applied
91 to a given device; and a <literal>[Network]</literal> section
92 specifying how the device should be configured. The first (in
93 lexical order) of the network files that matches a given device
96 <para>A network file is said to match a device if each of the
97 entries in the <literal>[Match]</literal> section matches, or if
98 the section is empty. The following keys are accepted:</para>
100 <variablelist class='network-directives'>
102 <term><varname>MACAddress=</varname></term>
104 <para>The hardware address.</para>
108 <term><varname>Path=</varname></term>
110 <para>A whitespace-separated list of shell-style globs
111 matching the persistent path, as exposed by the udev
112 property <literal>ID_PATH</literal>.</para>
116 <term><varname>Driver=</varname></term>
118 <para>A whitespace-separated list of shell-style globs
119 matching the driver currently bound to the device, as
120 exposed by the udev property <literal>DRIVER</literal>
121 of its parent device, or if that is not set the driver
122 as exposed by <literal>ethtool -i</literal> of the
123 device itself.</para>
127 <term><varname>Type=</varname></term>
129 <para>A whitespace-separated list of shell-style globs
130 matching the device type, as exposed by the udev property
131 <literal>DEVTYPE</literal>.</para>
135 <term><varname>Name=</varname></term>
137 <para>A whitespace-separated list of shell-style globs
138 matching the device name, as exposed by the udev property
139 <literal>INTERFACE</literal>.</para>
143 <term><varname>Host=</varname></term>
145 <para>Matches against the hostname or machine ID of the
146 host. See <literal>ConditionHost=</literal> in
147 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
153 <term><varname>Virtualization=</varname></term>
155 <para>Checks whether the system is executed in a virtualized
156 environment and optionally test whether it is a specific
157 implementation. See <literal>ConditionVirtualization=</literal> in
158 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
164 <term><varname>KernelCommandLine=</varname></term>
166 <para>Checks whether a specific kernel command line option is
167 set (or if prefixed with the exclamation mark unset). See
168 <literal>ConditionKernelCommandLine=</literal> in
169 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
175 <term><varname>Architecture=</varname></term>
177 <para>Checks whether the system is running on a specific
178 architecture. See <literal>ConditionArchitecture=</literal> in
179 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
189 <title>[Link] Section Options</title>
191 <para> The <literal>[Link]</literal> section accepts the following keys:</para>
193 <variablelist class='network-directives'>
195 <term><varname>MACAddress=</varname></term>
197 <para>The hardware address.</para>
201 <term><varname>MTUBytes=</varname></term>
203 <para>The maximum transmission unit in bytes to set for the
204 device. The usual suffixes K, M, G, are supported and are
205 understood to the base of 1024.</para>
212 <title>[Network] Section Options</title>
214 <para>The <literal>[Network]</literal> section accepts the following keys:</para>
216 <variablelist class='network-directives'>
218 <term><varname>Description=</varname></term>
220 <para>A description of the device. This is only used for
221 presentation purposes.</para>
225 <term><varname>DHCP=</varname></term>
227 <para>Enables DHCPv4 and/or DHCPv6 support. Accepts
228 <literal>yes</literal>, <literal>no</literal>,
229 <literal>ipv4</literal>, or <literal>ipv6</literal>.</para>
233 <term><varname>DHCPServer=</varname></term>
235 <para>A boolean. Enables a basic DHCPv4 server on the
236 device. Mostly useful for handing out leases to container
241 <term><varname>LinkLocalAddressing=</varname></term>
243 <para>Enables link-local address autoconfiguration. Accepts
244 <literal>yes</literal>, <literal>no</literal>,
245 <literal>ipv4</literal>, or <literal>ipv6</literal>. Defaults to
246 <literal>ipv6</literal>.</para>
250 <term><varname>IPv4LLRoute=</varname></term>
252 <para>A boolean. When true, sets up the route needed for
253 non-IPv4LL hosts to communicate with IPv4LL-only hosts. Defaults
259 <term><varname>IPv6Token=</varname></term>
261 <para>An IPv6 address with the top 64 bits unset. When set, indicates the
262 64 bits interface part of SLAAC IPv6 addresses for this link. By default
263 it is autogenerated.</para>
267 <term><varname>LLMNR=</varname></term>
269 <para>A boolean or <literal>resolve</literal>. When true, enables
270 Link-Local Multicast Name Resolution on the link, when set to
271 <literal>resolve</literal> only resolution is enabled, but not
272 announcement. Defaults to true.</para>
276 <term><varname>LLDP=</varname></term>
278 <para>A boolean. When true, enables LLDP link receive support.
283 <term><varname>BindCarrier=</varname></term>
285 <para>A port or a list of ports. When set, controls the
286 behaviour of the current interface. When all ports in the list
287 are in an operational down state, the current interface is brought
288 down. When at least one port has carrier, the current interface
294 <term><varname>Address=</varname></term>
296 <para>A static IPv4 or IPv6 address and its prefix length,
297 separated by a <literal>/</literal> character. Specify
298 this key more than once to configure several addresses.
299 The format of the address must be as described in
300 <citerefentry project='man-pages'><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
301 This is a short-hand for an [Address] section only
302 containing an Address key (see below). This option may be
303 specified more than once.
306 <para>If the specified address is 0.0.0.0 (for IPv4) or
307 [::] (for IPv6), a new address range of the requested size
308 is automatically allocated from a system-wide pool of
309 unused ranges. The allocated range is checked against all
310 current network interfaces and all known network
311 configuration files to avoid address range conflicts. The
312 default system-wide pool consists of 192.168.0.0/16,
313 172.16.0.0/12 and 10.0.0.0/8 for IPv4, and fc00::/7 for
314 IPv6. This functionality is useful to manage a large
315 number of dynamically created network interfaces with the
316 same network configuration and automatic address range
322 <term><varname>Gateway=</varname></term>
324 <para>The gateway address, which must be in the format
326 <citerefentry project='man-pages'><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
327 This is a short-hand for a [Route] section only containing
328 a Gateway key. This option may be specified more than
333 <term><varname>DNS=</varname></term>
335 <para>A DNS server address, which must be in the format
337 <citerefentry project='man-pages'><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
338 This option may be specified more than once.</para>
342 <term><varname>Domains=</varname></term>
344 <para>The domains used for DNS resolution over this link.</para>
348 <term><varname>NTP=</varname></term>
350 <para>An NTP server address. This option may be specified more than once.</para>
354 <term><varname>IPForward=</varname></term>
355 <listitem><para>Configures IP forwarding for the network
356 interface. If enabled incoming packets on the network
357 interface will be forwarded to other interfaces according to
358 the routing table. Takes either a boolean argument, or the
359 values <literal>ipv4</literal> or <literal>ipv6</literal>,
360 which only enables IP forwarding for the specified address
361 family.</para></listitem>
364 <term><varname>IPMasquerade=</varname></term>
365 <listitem><para>Configures IP masquerading for the network
366 interface. If enabled packets forwarded from the network
367 interface will be appear as coming from the local host.
368 Takes a boolean argument. Implies
369 <varname>IPForward=yes</varname>.</para></listitem>
372 <term><varname>Bridge=</varname></term>
374 <para>The name of the bridge to add the link to.</para>
378 <term><varname>Bond=</varname></term>
380 <para>The name of the bond to add the link to.</para>
384 <term><varname>VLAN=</varname></term>
386 <para>The name of a VLAN to create on the link. This
387 option may be specified more than once.</para>
391 <term><varname>MACVLAN=</varname></term>
393 <para>The name of a MACVLAN to create on the link. This
394 option may be specified more than once.</para>
398 <term><varname>VXLAN=</varname></term>
400 <para>The name of a VXLAN to create on the link. This
401 option may be specified more than once.</para>
405 <term><varname>Tunnel=</varname></term>
407 <para>The name of a Tunnel to create on the link. This
408 option may be specified more than once.</para>
416 <title>[Address] Section Options</title>
418 <para>An <literal>[Address]</literal> section accepts the
419 following keys. Specify several <literal>[Address]</literal>
420 sections to configure several addresses.</para>
422 <variablelist class='network-directives'>
424 <term><varname>Address=</varname></term>
426 <para>As in the <literal>[Network]</literal> section. This
427 key is mandatory.</para>
431 <term><varname>Peer=</varname></term>
433 <para>The peer address in a point-to-point connection.
434 Accepts the same format as the <literal>Address</literal>
439 <term><varname>Broadcast=</varname></term>
441 <para>The broadcast address, which must be in the format
443 <citerefentry project='man-pages'><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
444 This key only applies to IPv4 addresses. If it is not
445 given, it is derived from the <literal>Address</literal>
450 <term><varname>Label=</varname></term>
452 <para>An address label.</para>
459 <title>[Route] Section Options</title>
460 <para>The <literal>[Route]</literal> section accepts the
461 following keys. Specify several <literal>[Route]</literal>
462 sections to configure several routes.</para>
464 <variablelist class='network-directives'>
466 <term><varname>Gateway=</varname></term>
468 <para>As in the <literal>[Network]</literal> section.</para>
472 <term><varname>Destination=</varname></term>
474 <para>The destination prefix of the route. Possibly
475 followed by a slash and the prefixlength. If omitted, a
476 full-length host route is assumed.</para>
480 <term><varname>Source=</varname></term>
482 <para>The source prefix of the route. Possibly followed by
483 a slash and the prefixlength. If omitted, a full-length
484 host route is assumed.</para>
488 <term><varname>Metric=</varname></term>
490 <para>The metric of the route. An unsigned integer</para>
494 <term><varname>Scope=</varname></term>
496 <para>The scope of the route. One of the values <literal>global</literal>,
497 <literal>link</literal> or <literal>host</literal>. Defaults to
498 <literal>global</literal>.</para>
505 <title>[DHCP] Section Options</title>
506 <para>The <literal>[DHCP]</literal> section accepts the following keys:</para>
508 <variablelist class='network-directives'>
510 <term><varname>UseDNS=</varname></term>
512 <para>When true (the default), the DNS servers received
513 from the DHCP server will be used and take precedence over
514 any statically configured ones.</para>
518 <term><varname>UseNTP=</varname></term>
520 <para>When true (the default), the NTP servers received
521 from the DHCP server will be used by systemd-timesyncd
522 and take precedence over any statically configured ones.</para>
526 <term><varname>UseMTU=</varname></term>
528 <para>When true, the interface maximum transmission unit
529 from the DHCP server will be used on the current link.
530 Defaults to false.</para>
534 <term><varname>SendHostname=</varname></term>
536 <para>When true (the default), the machine's hostname will be sent to the DHCP
541 <term><varname>UseHostname=</varname></term>
543 <para>When true (the default), the hostname received from
544 the DHCP server will be used as the transient
549 <term><varname>UseDomains=</varname></term>
551 <para>When true (not the default), the domain name
552 received from the DHCP server will be used for DNS
553 resolution over this link.</para>
557 <term><varname>UseRoutes=</varname></term>
559 <para>When true (the default), the static routes will be
560 requested from the DHCP server and added to the routing
561 table with metric of 1024.</para>
565 <term><varname>CriticalConnection=</varname></term>
567 <para>When true, the connection will never be torn down
568 even if the DHCP lease expires. This is contrary to the
569 DHCP specification, but may be the best choice if, say,
570 the root filesystem relies on this connection. Defaults to
575 <term><varname>ClientIdentifier=</varname></term>
577 <para>DHCP client identifier to use. Either <literal>mac</literal>
578 to use the MAC address of the link or <literal>duid</literal>
579 (the default) to use a RFC4361-compliant Client ID.</para>
583 <term><varname>VendorClassIdentifier=</varname></term>
585 <para>The vendor class identifier used to identify vendor
586 type and configuration.</para>
590 <term><varname>RequestBroadcast=</varname></term>
592 <para>Request the server to use broadcast messages before
593 the IP address has been configured. This is necessary for
594 devices that cannot receive RAW packets, or that cannot
595 receive packets at all before an IP address has been
596 configured. On the other hand, this must not be enabled on
597 networks where broadcasts are filtered out.</para>
601 <term><varname>RouteMetric=</varname></term>
603 <para>Set the routing metric for routes specified by the
612 <title>[Bridge] Section Options</title>
613 <para>The <literal>[Bridge]</literal> section accepts the
614 following keys.</para>
615 <variablelist class='network-directives'>
617 <term><varname>Cost=</varname></term>
619 <para>Each port in a bridge may have different speed. Cost
620 is used to decide which link to use. Faster interfaces
621 should have lower costs</para>
628 <title>[BridgeFDB] Section Options</title>
629 <para>The <literal>[BridgeFDB]</literal> section manages the
630 forwarding database table of a port and accepts the following
631 keys. Specify several <literal>[BridgeFDB]</literal> sections to
632 configure several static MAC table entries.</para>
634 <variablelist class='network-directives'>
636 <term><varname>MACAddress=</varname></term>
638 <para>As in the <literal>[Network]</literal> section. This
639 key is mandatory.</para>
643 <term><varname>VLANId=</varname></term>
645 <para>The VLAN Id for the new static MAC table entry. If
646 omitted, no VLAN Id info is appended to the new static MAC
654 <title>Example</title>
656 <title>/etc/systemd/network/50-static.network</title>
658 <programlisting>[Match]
662 Address=192.168.0.15/24
663 Gateway=192.168.0.1</programlisting>
667 <title>/etc/systemd/network/80-dhcp.network</title>
669 <programlisting>[Match]
673 DHCP=yes</programlisting>
677 <title>/etc/systemd/network/bridge-static.network</title>
679 <programlisting>[Match]
683 Address=192.168.0.15/24
685 DNS=192.168.0.1</programlisting>
689 <title>/etc/systemd/network/bridge-slave-interface.network</title>
691 <programlisting>[Match]
695 Bridge=bridge0</programlisting>
698 <title>/etc/systemd/network/ipip.network</title>
700 <programlisting>[Match]
704 Tunnel=ipip-tun</programlisting>
708 <title>/etc/systemd/network/sit.network</title>
710 <programlisting>[Match]
714 Tunnel=sit-tun</programlisting>
718 <title>/etc/systemd/network/gre.network</title>
720 <programlisting>[Match]
724 Tunnel=gre-tun</programlisting>
728 <title>/etc/systemd/network/vti.network</title>
730 <programlisting>[Match]
734 Tunnel=vti-tun</programlisting>
739 <title>See Also</title>
741 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
742 <citerefentry><refentrytitle>systemd-networkd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
743 <citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
744 <citerefentry><refentrytitle>systemd.netdev</refentrytitle><manvolnum>5</manvolnum></citerefentry>