]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sysctl.d.xml
final v236 update (#7649)
[thirdparty/systemd.git] / man / sysctl.d.xml
CommitLineData
3802a3d3 1<?xml version="1.0"?> <!--*-nxml-*-->
12b42c76 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
c91faef3 3<!--
572eb058
ZJS
4 SPDX-License-Identifier: LGPL-2.1+
5
c91faef3
LP
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
5430f7f2
LP
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
c91faef3
LP
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
5430f7f2 18 Lesser General Public License for more details.
c91faef3 19
5430f7f2 20 You should have received a copy of the GNU Lesser General Public License
c91faef3
LP
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22-->
d3fae78f 23<refentry id="sysctl.d"
798d3a52
ZJS
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
3ba3a79d 62 <citerefentry project='man-pages'><refentrytitle>sysctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>
798d3a52
ZJS
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>
9407bc2d 128 <title>Apply settings available only when a certain module is loaded (method one)</title>
798d3a52
ZJS
129 <para><filename>/etc/udev/rules.d/99-bridge.rules</filename>:
130 </para>
131
9407bc2d
ZJS
132 <programlisting>ACTION=="add", SUBSYSTEM=="module", KERNEL=="br_netfilter", \
133 RUN+="/usr/lib/systemd/systemd-sysctl --prefix=/net/bridge"
71418295
ZJS
134</programlisting>
135
798d3a52
ZJS
136 <para><filename>/etc/sysctl.d/bridge.conf</filename>:
137 </para>
71418295 138
798d3a52 139 <programlisting>net.bridge.bridge-nf-call-ip6tables = 0
71418295
ZJS
140net.bridge.bridge-nf-call-iptables = 0
141net.bridge.bridge-nf-call-arptables = 0
142</programlisting>
9407bc2d
ZJS
143
144 <para>This method applies settings when the module is
b938cb90 145 loaded. Please note that, unless the <filename>br_netfilter</filename>
9407bc2d 146 module is loaded, bridged packets will not be filtered by
a8eaaee7
JE
147 Netfilter (starting with kernel 3.18), so simply not loading the
148 module is sufficient to avoid filtering.</para>
798d3a52 149 </example>
71418295 150
798d3a52 151 <example>
9407bc2d 152 <title>Apply settings available only when a certain module is loaded (method two)</title>
798d3a52
ZJS
153 <para><filename>/etc/modules-load.d/bridge.conf</filename>:
154 </para>
7284335a 155
9407bc2d 156 <programlisting>br_netfilter</programlisting>
7284335a 157
798d3a52
ZJS
158 <para><filename>/etc/sysctl.d/bridge.conf</filename>:
159 </para>
c91faef3 160
798d3a52 161 <programlisting>net.bridge.bridge-nf-call-ip6tables = 0
7284335a
ZJS
162net.bridge.bridge-nf-call-iptables = 0
163net.bridge.bridge-nf-call-arptables = 0
164</programlisting>
9407bc2d
ZJS
165
166 <para>This method forces the module to be always loaded. Please
b938cb90 167 note that, unless the <filename>br_netfilter</filename> module is
a8eaaee7 168 loaded, bridged packets will not be filtered with Netfilter
9407bc2d 169 (starting with kernel 3.18), so simply not loading the module is
a8eaaee7 170 sufficient to avoid filtering.</para>
798d3a52
ZJS
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>,
3ba3a79d
ZJS
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>
798d3a52
ZJS
183 </para>
184 </refsect1>
c91faef3
LP
185
186</refentry>