chiark / gitweb /
Add man page and references to it.
[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
62     <filename>.network</filename>; other extensions are ignored.
63     Networks are applied to links whenever the links appear.</para>
64
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
82     entirely.</para>
83
84   </refsect1>
85
86   <refsect1>
87     <title>[Match] Section Options</title>
88
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
94       is applied.</para>
95
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>
99
100       <variablelist class='network-directives'>
101         <varlistentry>
102           <term><varname>MACAddress=</varname></term>
103           <listitem>
104             <para>The hardware address.</para>
105           </listitem>
106         </varlistentry>
107         <varlistentry>
108           <term><varname>Path=</varname></term>
109           <listitem>
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>
113           </listitem>
114         </varlistentry>
115         <varlistentry>
116           <term><varname>Driver=</varname></term>
117           <listitem>
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>
124           </listitem>
125         </varlistentry>
126         <varlistentry>
127           <term><varname>Type=</varname></term>
128           <listitem>
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>
132           </listitem>
133         </varlistentry>
134         <varlistentry>
135           <term><varname>Name=</varname></term>
136           <listitem>
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>
140           </listitem>
141         </varlistentry>
142         <varlistentry>
143           <term><varname>Host=</varname></term>
144           <listitem>
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>
148             for details.
149             </para>
150           </listitem>
151         </varlistentry>
152         <varlistentry>
153           <term><varname>Virtualization=</varname></term>
154           <listitem>
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>
159             for details.
160             </para>
161           </listitem>
162         </varlistentry>
163         <varlistentry>
164           <term><varname>KernelCommandLine=</varname></term>
165           <listitem>
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>
170             for details.
171             </para>
172           </listitem>
173         </varlistentry>
174         <varlistentry>
175           <term><varname>Architecture=</varname></term>
176           <listitem>
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>
180             for details.
181             </para>
182           </listitem>
183         </varlistentry>
184       </variablelist>
185
186   </refsect1>
187
188   <refsect1>
189     <title>[Link] Section Options</title>
190
191     <para> The <literal>[Link]</literal> section accepts the following keys:</para>
192
193     <variablelist class='network-directives'>
194       <varlistentry>
195         <term><varname>MACAddress=</varname></term>
196         <listitem>
197           <para>The hardware address.</para>
198         </listitem>
199       </varlistentry>
200       <varlistentry>
201         <term><varname>MTUBytes=</varname></term>
202         <listitem>
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>
206         </listitem>
207       </varlistentry>
208     </variablelist>
209   </refsect1>
210
211   <refsect1>
212     <title>[Network] Section Options</title>
213
214       <para>The <literal>[Network]</literal> section accepts the following keys:</para>
215
216       <variablelist class='network-directives'>
217         <varlistentry>
218           <term><varname>Description=</varname></term>
219           <listitem>
220             <para>A description of the device. This is only used for
221             presentation purposes.</para>
222           </listitem>
223         </varlistentry>
224         <varlistentry>
225           <term><varname>DHCP=</varname></term>
226           <listitem>
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>
230           </listitem>
231         </varlistentry>
232         <varlistentry>
233           <term><varname>DHCPServer=</varname></term>
234           <listitem>
235             <para>A boolean. Enables a basic DHCPv4 server on the
236             device. Mostly useful for handing out leases to container
237             instances.</para>
238           </listitem>
239         </varlistentry>
240         <varlistentry>
241           <term><varname>LinkLocalAddressing=</varname></term>
242           <listitem>
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>
247           </listitem>
248         </varlistentry>
249         <varlistentry>
250           <term><varname>IPv4LLRoute=</varname></term>
251           <listitem>
252             <para>A boolean. When true, sets up the route needed for
253             non-IPv4LL hosts to communicate with IPv4LL-only hosts. Defaults
254             to false.
255             </para>
256           </listitem>
257         </varlistentry>
258         <varlistentry>
259           <term><varname>IPv6Token=</varname></term>
260           <listitem>
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>
264           </listitem>
265         </varlistentry>
266         <varlistentry>
267           <term><varname>LLMNR=</varname></term>
268           <listitem>
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>
273           </listitem>
274         </varlistentry>
275         <varlistentry>
276           <term><varname>LLDP=</varname></term>
277           <listitem>
278             <para>A boolean. When true, enables LLDP link receive support.
279             </para>
280           </listitem>
281         </varlistentry>
282         <varlistentry>
283           <term><varname>Address=</varname></term>
284           <listitem>
285             <para>A static IPv4 or IPv6 address and its prefix length,
286             separated by a <literal>/</literal> character. Specify
287             this key more than once to configure several addresses.
288             The format of the address must be as described in
289             <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
290             This is a short-hand for an [Address] section only
291             containing an Address key (see below). This option may be
292             specified more than once.
293             </para>
294
295             <para>If the specified address is 0.0.0.0 (for IPv4) or
296             [::] (for IPv6), a new address range of the requested size
297             is automatically allocated from a system-wide pool of
298             unused ranges. The allocated range is checked against all
299             current network interfaces and all known network
300             configuration files to avoid address range conflicts. The
301             default system-wide pool consists of 192.168.0.0/16,
302             172.16.0.0/12 and 10.0.0.0/8 for IPv4, and fc00::/7 for
303             IPv6. This functionality is useful to manage a large
304             number of dynamically created network interfaces with the
305             same network configuration and automatic address range
306             assignment.</para>
307
308           </listitem>
309         </varlistentry>
310         <varlistentry>
311           <term><varname>Gateway=</varname></term>
312           <listitem>
313             <para>The gateway address, which must be in the format
314             described in
315             <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
316             This is a short-hand for a [Route] section only containing
317             a Gateway key. This option may be specified more than
318             once.</para>
319           </listitem>
320         </varlistentry>
321         <varlistentry>
322           <term><varname>DNS=</varname></term>
323           <listitem>
324             <para>A DNS server address, which must be in the format
325             described in
326             <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
327             This option may be specified more than once.</para>
328           </listitem>
329         </varlistentry>
330         <varlistentry>
331           <term><varname>Domains=</varname></term>
332           <listitem>
333             <para>The domains used for DNS resolution over this link.</para>
334           </listitem>
335         </varlistentry>
336         <varlistentry>
337           <term><varname>NTP=</varname></term>
338           <listitem>
339             <para>An NTP server address. This option may be specified more than once.</para>
340           </listitem>
341         </varlistentry>
342         <varlistentry>
343           <term><varname>IPForward=</varname></term>
344           <listitem><para>Configures IP forwarding for the network
345           interface. If enabled incoming packets on the network
346           interface will be forwarded to other interfaces according to
347           the routing table. Takes either a boolean argument, or the
348           values <literal>ipv4</literal> or <literal>ipv6</literal>,
349           which only enables IP forwarding for the specified address
350           family.</para></listitem>
351         </varlistentry>
352         <varlistentry>
353           <term><varname>IPMasquerade=</varname></term>
354           <listitem><para>Configures IP masquerading for the network
355           interface. If enabled packets forwarded from the network
356           interface will be appear as coming from the local host.
357           Takes a boolean argument. Implies
358           <varname>IPForward=yes</varname>.</para></listitem>
359         </varlistentry>
360         <varlistentry>
361           <term><varname>Bridge=</varname></term>
362           <listitem>
363             <para>The name of the bridge to add the link to.</para>
364           </listitem>
365         </varlistentry>
366         <varlistentry>
367           <term><varname>Bond=</varname></term>
368           <listitem>
369             <para>The name of the bond to add the link to.</para>
370           </listitem>
371         </varlistentry>
372         <varlistentry>
373           <term><varname>VLAN=</varname></term>
374           <listitem>
375             <para>The name of a VLAN to create on the link. This
376             option may be specified more than once.</para>
377           </listitem>
378         </varlistentry>
379         <varlistentry>
380           <term><varname>MACVLAN=</varname></term>
381           <listitem>
382             <para>The name of a MACVLAN to create on the link. This
383             option may be specified more than once.</para>
384           </listitem>
385         </varlistentry>
386         <varlistentry>
387           <term><varname>VXLAN=</varname></term>
388           <listitem>
389             <para>The name of a VXLAN to create on the link. This
390             option may be specified more than once.</para>
391           </listitem>
392         </varlistentry>
393         <varlistentry>
394           <term><varname>Tunnel=</varname></term>
395           <listitem>
396             <para>The name of a Tunnel to create on the link. This
397             option may be specified more than once.</para>
398           </listitem>
399         </varlistentry>
400       </variablelist>
401
402   </refsect1>
403
404   <refsect1>
405     <title>[Address] Section Options</title>
406
407       <para>An <literal>[Address]</literal> section accepts the
408       following keys. Specify several <literal>[Address]</literal>
409       sections to configure several addresses.</para>
410
411       <variablelist class='network-directives'>
412         <varlistentry>
413           <term><varname>Address=</varname></term>
414           <listitem>
415             <para>As in the <literal>[Network]</literal> section. This
416             key is mandatory.</para>
417           </listitem>
418         </varlistentry>
419         <varlistentry>
420           <term><varname>Peer=</varname></term>
421           <listitem>
422             <para>The peer address in a point-to-point connection.
423             Accepts the same format as the <literal>Address</literal>
424             key.</para>
425           </listitem>
426         </varlistentry>
427         <varlistentry>
428           <term><varname>Broadcast=</varname></term>
429           <listitem>
430             <para>The broadcast address, which must be in the format
431             described in
432             <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
433             This key only applies to IPv4 addresses. If it is not
434             given, it is derived from the <literal>Address</literal>
435             key.</para>
436           </listitem>
437         </varlistentry>
438         <varlistentry>
439           <term><varname>Label=</varname></term>
440           <listitem>
441             <para>An address label.</para>
442           </listitem>
443         </varlistentry>
444       </variablelist>
445   </refsect1>
446
447   <refsect1>
448     <title>[Route] Section Options</title>
449       <para>The <literal>[Route]</literal> section accepts the
450       following keys. Specify several <literal>[Route]</literal>
451       sections to configure several routes.</para>
452
453       <variablelist class='network-directives'>
454         <varlistentry>
455           <term><varname>Gateway=</varname></term>
456           <listitem>
457             <para>As in the <literal>[Network]</literal> section.</para>
458           </listitem>
459         </varlistentry>
460         <varlistentry>
461           <term><varname>Destination=</varname></term>
462           <listitem>
463             <para>The destination prefix of the route. Possibly
464             followed by a slash and the prefixlength. If omitted, a
465             full-length host route is assumed.</para>
466           </listitem>
467         </varlistentry>
468         <varlistentry>
469           <term><varname>Source=</varname></term>
470           <listitem>
471             <para>The source prefix of the route. Possibly followed by
472             a slash and the prefixlength. If omitted, a full-length
473             host route is assumed.</para>
474           </listitem>
475         </varlistentry>
476         <varlistentry>
477           <term><varname>Metric=</varname></term>
478           <listitem>
479             <para>The metric of the route. An unsigned integer</para>
480           </listitem>
481         </varlistentry>
482         <varlistentry>
483           <term><varname>Scope=</varname></term>
484           <listitem>
485             <para>The scope of the route. One of the values <literal>global</literal>,
486             <literal>link</literal> or <literal>host</literal>. Defaults to
487             <literal>global</literal>.</para>
488           </listitem>
489         </varlistentry>
490       </variablelist>
491   </refsect1>
492
493   <refsect1>
494     <title>[DHCP] Section Options</title>
495       <para>The <literal>[DHCP]</literal> section accepts the following keys:</para>
496
497       <variablelist class='network-directives'>
498         <varlistentry>
499           <term><varname>UseDNS=</varname></term>
500           <listitem>
501             <para>When true (the default), the DNS servers received
502             from the DHCP server will be used and take precedence over
503             any statically configured ones.</para>
504           </listitem>
505         </varlistentry>
506         <varlistentry>
507           <term><varname>UseMTU=</varname></term>
508           <listitem>
509             <para>When true, the interface maximum transmission unit
510             from the DHCP server will be used on the current link.
511             Defaults to false.</para>
512           </listitem>
513         </varlistentry>
514         <varlistentry>
515           <term><varname>SendHostname=</varname></term>
516           <listitem>
517             <para>When true (the default), the machine's hostname will be sent to the DHCP
518             server</para>
519           </listitem>
520         </varlistentry>
521         <varlistentry>
522           <term><varname>UseHostname=</varname></term>
523           <listitem>
524             <para>When true (the default), the hostname received from
525             the DHCP server will be used as the transient
526             hostname.</para>
527           </listitem>
528         </varlistentry>
529         <varlistentry>
530           <term><varname>UseDomains=</varname></term>
531           <listitem>
532             <para>When true (not the default), the domain name
533             received from the DHCP server will be used for DNS
534             resolution over this link.</para>
535           </listitem>
536         </varlistentry>
537         <varlistentry>
538           <term><varname>UseRoutes=</varname></term>
539           <listitem>
540             <para>When true (the default), the static routes will be
541             requested from the DHCP server and added to the routing
542             table with metric of 1024.</para>
543           </listitem>
544         </varlistentry>
545         <varlistentry>
546           <term><varname>CriticalConnection=</varname></term>
547           <listitem>
548             <para>When true, the connection will never be torn down
549             even if the DHCP lease expires. This is contrary to the
550             DHCP specification, but may be the best choice if, say,
551             the root filesystem relies on this connection. Defaults to
552             false.</para>
553           </listitem>
554         </varlistentry>
555         <varlistentry>
556           <term><varname>VendorClassIdentifier=</varname></term>
557           <listitem>
558             <para>The vendor class identifier used to identify vendor
559             type and configuration.</para>
560           </listitem>
561         </varlistentry>
562         <varlistentry>
563           <term><varname>RequestBroadcast=</varname></term>
564           <listitem>
565             <para>Request the server to use broadcast messages before
566             the IP address has been configured. This is necessary for
567             devices that cannot receive RAW packets, or that cannot
568             receive packets at all before an IP address has been
569             configured. On the other hand, this must not be enabled on
570             networks where broadcasts are filtered out.</para>
571           </listitem>
572         </varlistentry>
573         <varlistentry>
574           <term><varname>RouteMetric=</varname></term>
575           <listitem>
576             <para>Set the routing metric for routes specified by the
577             DHCP server.</para>
578           </listitem>
579         </varlistentry>
580            </variablelist>
581
582   </refsect1>
583
584   <refsect1>
585     <title>[Bridge] Section Options</title>
586       <para>The <literal>[Bridge]</literal> section accepts the
587       following keys.</para>
588       <variablelist class='network-directives'>
589         <varlistentry>
590           <term><varname>Cost=</varname></term>
591           <listitem>
592             <para>Each port in a bridge may have different speed. Cost
593             is used to decide which link to use. Faster interfaces
594             should have lower costs</para>
595           </listitem>
596         </varlistentry>
597       </variablelist>
598   </refsect1>
599
600   <refsect1>
601     <title>[BridgeFDB] Section Options</title>
602       <para>The <literal>[BridgeFDB]</literal> section manages the
603       forwarding database table of a port and accepts the following
604       keys. Specify several <literal>[BridgeFDB]</literal> sections to
605       configure several static MAC table entries.</para>
606
607       <variablelist class='network-directives'>
608         <varlistentry>
609           <term><varname>MACAddress=</varname></term>
610           <listitem>
611             <para>As in the <literal>[Network]</literal> section. This
612             key is mandatory.</para>
613           </listitem>
614         </varlistentry>
615         <varlistentry>
616           <term><varname>VLANId=</varname></term>
617           <listitem>
618             <para>The VLAN Id for the new static MAC table entry. If
619             omitted, no VLAN Id info is appended to the new static MAC
620             table entry.</para>
621           </listitem>
622         </varlistentry>
623       </variablelist>
624   </refsect1>
625
626   <refsect1>
627     <title>Example</title>
628     <example>
629       <title>/etc/systemd/network/50-static.network</title>
630
631       <programlisting>[Match]
632 Name=enp2s0
633
634 [Network]
635 Address=192.168.0.15/24
636 Gateway=192.168.0.1</programlisting>
637     </example>
638
639     <example>
640       <title>/etc/systemd/network/80-dhcp.network</title>
641
642       <programlisting>[Match]
643 Name=en*
644
645 [Network]
646 DHCP=both</programlisting>
647     </example>
648
649     <example>
650       <title>/etc/systemd/network/bridge-static.network</title>
651
652       <programlisting>[Match]
653 Name=bridge0
654
655 [Network]
656 Address=192.168.0.15/24
657 Gateway=192.168.0.1
658 DNS=192.168.0.1</programlisting>
659     </example>
660
661     <example>
662       <title>/etc/systemd/network/bridge-slave-interface.network</title>
663
664       <programlisting>[Match]
665 Name=enp2s0
666
667 [Network]
668 Bridge=bridge0</programlisting>
669     </example>
670     <example>
671       <title>/etc/systemd/network/ipip.network</title>
672
673       <programlisting>[Match]
674 Name=em1
675
676 [Network]
677 Tunnel=ipip-tun</programlisting>
678     </example>
679
680     <example>
681       <title>/etc/systemd/network/sit.network</title>
682
683       <programlisting>[Match]
684 Name=em1
685
686 [Network]
687 Tunnel=sit-tun</programlisting>
688     </example>
689
690     <example>
691       <title>/etc/systemd/network/gre.network</title>
692
693       <programlisting>[Match]
694 Name=em1
695
696 [Network]
697 Tunnel=gre-tun</programlisting>
698     </example>
699
700     <example>
701       <title>/etc/systemd/network/vti.network</title>
702
703       <programlisting>[Match]
704 Name=em1
705
706 [Network]
707 Tunnel=vti-tun</programlisting>
708     </example>
709   </refsect1>
710
711   <refsect1>
712     <title>See Also</title>
713     <para>
714       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
715       <citerefentry><refentrytitle>systemd-networkd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
716       <citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
717       <citerefentry><refentrytitle>systemd.netdev</refentrytitle><manvolnum>5</manvolnum></citerefentry>
718     </para>
719   </refsect1>
720
721 </refentry>