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