]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sysctl.d.xml
travis: add more ASan options
[thirdparty/systemd.git] / man / sysctl.d.xml
1 <?xml version="1.0"?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
5 <refentry id="sysctl.d"
6 xmlns:xi="http://www.w3.org/2001/XInclude">
7
8 <refentryinfo>
9 <title>sysctl.d</title>
10 <productname>systemd</productname>
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>sysctl.d</refentrytitle>
15 <manvolnum>5</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>sysctl.d</refname>
20 <refpurpose>Configure kernel parameters at boot</refpurpose>
21 </refnamediv>
22
23 <refsynopsisdiv>
24 <para><filename>/etc/sysctl.d/*.conf</filename></para>
25 <para><filename>/run/sysctl.d/*.conf</filename></para>
26 <para><filename>/usr/lib/sysctl.d/*.conf</filename></para>
27 </refsynopsisdiv>
28
29 <refsect1>
30 <title>Description</title>
31
32 <para>At boot,
33 <citerefentry><refentrytitle>systemd-sysctl.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
34 reads configuration files from the above directories to configure
35 <citerefentry project='man-pages'><refentrytitle>sysctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>
36 kernel parameters.</para>
37 </refsect1>
38
39 <refsect1>
40 <title>Configuration Format</title>
41
42 <para>The configuration files contain a list of variable
43 assignments, separated by newlines. Empty lines and lines whose
44 first non-whitespace character is <literal>#</literal> or
45 <literal>;</literal> are ignored.</para>
46
47 <para>Note that either <literal>/</literal> or
48 <literal>.</literal> may be used as separators within sysctl
49 variable names. If the first separator is a slash, remaining
50 slashes and dots are left intact. If the first separator is a dot,
51 dots and slashes are interchanged.
52 <literal>kernel.domainname=foo</literal> and
53 <literal>kernel/domainname=foo</literal> are equivalent and will
54 cause <literal>foo</literal> to be written to
55 <filename>/proc/sys/kernel/domainname</filename>. Either
56 <literal>net.ipv4.conf.enp3s0/200.forwarding</literal> or
57 <literal>net/ipv4/conf/enp3s0.200/forwarding</literal> may be used
58 to refer to
59 <filename>/proc/sys/net/ipv4/conf/enp3s0.200/forwarding</filename>.
60 </para>
61
62 <para>The settings configured with <filename>sysctl.d</filename>
63 files will be applied early on boot. The network
64 interface-specific options will also be applied individually for
65 each network interface as it shows up in the system. (More
66 specifically, <filename>net.ipv4.conf.*</filename>,
67 <filename>net.ipv6.conf.*</filename>,
68 <filename>net.ipv4.neigh.*</filename> and
69 <filename>net.ipv6.neigh.*</filename>).</para>
70
71 <para>Many sysctl parameters only become available when certain
72 kernel modules are loaded. Modules are usually loaded on demand,
73 e.g. when certain hardware is plugged in or network brought up.
74 This means that
75 <citerefentry><refentrytitle>systemd-sysctl.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
76 which runs during early boot will not configure such parameters if
77 they become available after it has run. To set such parameters, it
78 is recommended to add an
79 <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry>
80 rule to set those parameters when they become available.
81 Alternatively, a slightly simpler and less efficient option is to
82 add the module to
83 <citerefentry><refentrytitle>modules-load.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
84 causing it to be loaded statically before sysctl settings are
85 applied (see example below).</para>
86 </refsect1>
87
88 <xi:include href="standard-conf.xml" xpointer="confd" />
89
90 <refsect1>
91 <title>Examples</title>
92 <example>
93 <title>Set kernel YP domain name</title>
94 <para><filename>/etc/sysctl.d/domain-name.conf</filename>:
95 </para>
96
97 <programlisting>kernel.domainname=example.com</programlisting>
98 </example>
99
100 <example>
101 <title>Apply settings available only when a certain module is loaded (method one)</title>
102 <para><filename>/etc/udev/rules.d/99-bridge.rules</filename>:
103 </para>
104
105 <programlisting>ACTION=="add", SUBSYSTEM=="module", KERNEL=="br_netfilter", \
106 RUN+="/usr/lib/systemd/systemd-sysctl --prefix=/net/bridge"
107 </programlisting>
108
109 <para><filename>/etc/sysctl.d/bridge.conf</filename>:
110 </para>
111
112 <programlisting>net.bridge.bridge-nf-call-ip6tables = 0
113 net.bridge.bridge-nf-call-iptables = 0
114 net.bridge.bridge-nf-call-arptables = 0
115 </programlisting>
116
117 <para>This method applies settings when the module is
118 loaded. Please note that, unless the <filename>br_netfilter</filename>
119 module is loaded, bridged packets will not be filtered by
120 Netfilter (starting with kernel 3.18), so simply not loading the
121 module is sufficient to avoid filtering.</para>
122 </example>
123
124 <example>
125 <title>Apply settings available only when a certain module is loaded (method two)</title>
126 <para><filename>/etc/modules-load.d/bridge.conf</filename>:
127 </para>
128
129 <programlisting>br_netfilter</programlisting>
130
131 <para><filename>/etc/sysctl.d/bridge.conf</filename>:
132 </para>
133
134 <programlisting>net.bridge.bridge-nf-call-ip6tables = 0
135 net.bridge.bridge-nf-call-iptables = 0
136 net.bridge.bridge-nf-call-arptables = 0
137 </programlisting>
138
139 <para>This method forces the module to be always loaded. Please
140 note that, unless the <filename>br_netfilter</filename> module is
141 loaded, bridged packets will not be filtered with Netfilter
142 (starting with kernel 3.18), so simply not loading the module is
143 sufficient to avoid filtering.</para>
144 </example>
145 </refsect1>
146
147 <refsect1>
148 <title>See Also</title>
149 <para>
150 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
151 <citerefentry><refentrytitle>systemd-sysctl.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
152 <citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
153 <citerefentry project='man-pages'><refentrytitle>sysctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
154 <citerefentry project='man-pages'><refentrytitle>sysctl.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
155 <citerefentry project='man-pages'><refentrytitle>modprobe</refentrytitle><manvolnum>8</manvolnum></citerefentry>
156 </para>
157 </refsect1>
158
159 </refentry>