]>
Commit | Line | Data |
---|---|---|
3802a3d3 | 1 | <?xml version="1.0"?> <!--*-nxml-*--> |
3a54a157 | 2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
eea10b26 | 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
db9ecf05 | 4 | <!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
d3fae78f | 5 | <refentry id="sysctl.d" |
798d3a52 ZJS |
6 | xmlns:xi="http://www.w3.org/2001/XInclude"> |
7 | ||
8 | <refentryinfo> | |
9 | <title>sysctl.d</title> | |
10 | <productname>systemd</productname> | |
798d3a52 ZJS |
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> | |
73e97bb0 ZJS |
24 | <para><simplelist> |
25 | <member><filename>/etc/sysctl.d/*.conf</filename></member> | |
26 | <member><filename>/run/sysctl.d/*.conf</filename></member> | |
27 | <member><filename>/usr/lib/sysctl.d/*.conf</filename></member> | |
28 | </simplelist></para> | |
02d89f9a ZJS |
29 | |
30 | <programlisting>key.name.under.proc.sys = some value | |
31 | key/name/under/proc/sys = some value | |
32 | key/middle.part.with.dots/foo = 123 | |
33 | key.middle/part/with/dots.foo = 123 | |
34 | -key.that.will.not.fail = value | |
e0f42479 ZJS |
35 | key.pattern.*.with.glob = whatever |
36 | -key.pattern.excluded.with.glob | |
f52b9131 | 37 | key.pattern.overridden.with.glob = custom |
02d89f9a | 38 | </programlisting> |
798d3a52 ZJS |
39 | </refsynopsisdiv> |
40 | ||
41 | <refsect1> | |
42 | <title>Description</title> | |
43 | ||
44 | <para>At boot, | |
45 | <citerefentry><refentrytitle>systemd-sysctl.service</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
46 | reads configuration files from the above directories to configure | |
3ba3a79d | 47 | <citerefentry project='man-pages'><refentrytitle>sysctl</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
798d3a52 ZJS |
48 | kernel parameters.</para> |
49 | </refsect1> | |
50 | ||
51 | <refsect1> | |
52 | <title>Configuration Format</title> | |
53 | ||
54 | <para>The configuration files contain a list of variable | |
55 | assignments, separated by newlines. Empty lines and lines whose | |
56 | first non-whitespace character is <literal>#</literal> or | |
57 | <literal>;</literal> are ignored.</para> | |
58 | ||
e0f42479 ZJS |
59 | <para>Note that either <literal>/</literal> or <literal>.</literal> may be used as separators within |
60 | sysctl variable names. If the first separator is a slash, remaining slashes and dots are left intact. If | |
61 | the first separator is a dot, dots and slashes are interchanged. | |
62 | <literal>kernel.domainname=foo</literal> and <literal>kernel/domainname=foo</literal> are equivalent and | |
63 | will cause <literal>foo</literal> to be written to | |
798d3a52 ZJS |
64 | <filename>/proc/sys/kernel/domainname</filename>. Either |
65 | <literal>net.ipv4.conf.enp3s0/200.forwarding</literal> or | |
e0f42479 ZJS |
66 | <literal>net/ipv4/conf/enp3s0.200/forwarding</literal> may be used to refer to |
67 | <filename>/proc/sys/net/ipv4/conf/enp3s0.200/forwarding</filename>. A glob | |
b7a47345 | 68 | <citerefentry project='man-pages'><refentrytitle>glob</refentrytitle><manvolnum>7</manvolnum></citerefentry> pattern may be |
e0f42479 ZJS |
69 | used to write the same value to all matching keys. Keys for which an explicit pattern exists will be |
70 | excluded from any glob matching. In addition, a key may be explicitly excluded from being set by any | |
71 | matching glob patterns by specifying the key name prefixed with a <literal>-</literal> character and not | |
72 | followed by <literal>=</literal>, see SYNOPSIS.</para> | |
798d3a52 | 73 | |
fa2111bd | 74 | <para>Any access permission errors and attempts to write variables not present on the local system are |
32520ff3 ZJS |
75 | logged at debug level and do not cause the service to fail. Other types of errors when setting variables |
76 | are logged with higher priority and cause the service to return failure at the end (after processing | |
77 | other variables). As an exception, if a variable assignment is prefixed with a single | |
78 | <literal>-</literal> character, failure to set the variable for any reason will be logged at debug level | |
79 | and will not cause the service to fail.</para> | |
e08be649 | 80 | |
e0f42479 ZJS |
81 | <para>The settings configured with <filename>sysctl.d</filename> files will be applied early on boot. The |
82 | network interface-specific options will also be applied individually for each network interface as it | |
83 | shows up in the system. (More specifically, <filename>net.ipv4.conf.*</filename>, | |
84 | <filename>net.ipv6.conf.*</filename>, <filename>net.ipv4.neigh.*</filename> and | |
798d3a52 ZJS |
85 | <filename>net.ipv6.neigh.*</filename>).</para> |
86 | ||
87 | <para>Many sysctl parameters only become available when certain | |
88 | kernel modules are loaded. Modules are usually loaded on demand, | |
89 | e.g. when certain hardware is plugged in or network brought up. | |
90 | This means that | |
91 | <citerefentry><refentrytitle>systemd-sysctl.service</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
92 | which runs during early boot will not configure such parameters if | |
93 | they become available after it has run. To set such parameters, it | |
94 | is recommended to add an | |
95 | <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry> | |
96 | rule to set those parameters when they become available. | |
97 | Alternatively, a slightly simpler and less efficient option is to | |
98 | add the module to | |
99 | <citerefentry><refentrytitle>modules-load.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
100 | causing it to be loaded statically before sysctl settings are | |
101 | applied (see example below).</para> | |
102 | </refsect1> | |
103 | ||
104 | <xi:include href="standard-conf.xml" xpointer="confd" /> | |
105 | ||
106 | <refsect1> | |
107 | <title>Examples</title> | |
108 | <example> | |
109 | <title>Set kernel YP domain name</title> | |
110 | <para><filename>/etc/sysctl.d/domain-name.conf</filename>: | |
111 | </para> | |
112 | ||
113 | <programlisting>kernel.domainname=example.com</programlisting> | |
114 | </example> | |
115 | ||
116 | <example> | |
9407bc2d | 117 | <title>Apply settings available only when a certain module is loaded (method one)</title> |
798d3a52 ZJS |
118 | <para><filename>/etc/udev/rules.d/99-bridge.rules</filename>: |
119 | </para> | |
120 | ||
9407bc2d ZJS |
121 | <programlisting>ACTION=="add", SUBSYSTEM=="module", KERNEL=="br_netfilter", \ |
122 | RUN+="/usr/lib/systemd/systemd-sysctl --prefix=/net/bridge" | |
71418295 ZJS |
123 | </programlisting> |
124 | ||
798d3a52 ZJS |
125 | <para><filename>/etc/sysctl.d/bridge.conf</filename>: |
126 | </para> | |
71418295 | 127 | |
798d3a52 | 128 | <programlisting>net.bridge.bridge-nf-call-ip6tables = 0 |
71418295 ZJS |
129 | net.bridge.bridge-nf-call-iptables = 0 |
130 | net.bridge.bridge-nf-call-arptables = 0 | |
131 | </programlisting> | |
9407bc2d ZJS |
132 | |
133 | <para>This method applies settings when the module is | |
b938cb90 | 134 | loaded. Please note that, unless the <filename>br_netfilter</filename> |
9407bc2d | 135 | module is loaded, bridged packets will not be filtered by |
a8eaaee7 JE |
136 | Netfilter (starting with kernel 3.18), so simply not loading the |
137 | module is sufficient to avoid filtering.</para> | |
798d3a52 | 138 | </example> |
71418295 | 139 | |
798d3a52 | 140 | <example> |
9407bc2d | 141 | <title>Apply settings available only when a certain module is loaded (method two)</title> |
798d3a52 ZJS |
142 | <para><filename>/etc/modules-load.d/bridge.conf</filename>: |
143 | </para> | |
7284335a | 144 | |
9407bc2d | 145 | <programlisting>br_netfilter</programlisting> |
7284335a | 146 | |
798d3a52 ZJS |
147 | <para><filename>/etc/sysctl.d/bridge.conf</filename>: |
148 | </para> | |
c91faef3 | 149 | |
798d3a52 | 150 | <programlisting>net.bridge.bridge-nf-call-ip6tables = 0 |
7284335a ZJS |
151 | net.bridge.bridge-nf-call-iptables = 0 |
152 | net.bridge.bridge-nf-call-arptables = 0 | |
153 | </programlisting> | |
9407bc2d ZJS |
154 | |
155 | <para>This method forces the module to be always loaded. Please | |
b938cb90 | 156 | note that, unless the <filename>br_netfilter</filename> module is |
a8eaaee7 | 157 | loaded, bridged packets will not be filtered with Netfilter |
9407bc2d | 158 | (starting with kernel 3.18), so simply not loading the module is |
a8eaaee7 | 159 | sufficient to avoid filtering.</para> |
798d3a52 | 160 | </example> |
e0f42479 ZJS |
161 | |
162 | <example> | |
163 | <title>Set network routing properties for all interfaces</title> | |
7b9289b1 | 164 | <para><filename>/etc/sysctl.d/20-rp_filter.conf</filename>:</para> |
e0f42479 ZJS |
165 | |
166 | <programlisting>net.ipv4.conf.default.rp_filter = 2 | |
167 | net.ipv4.conf.*.rp_filter = 2 | |
168 | -net.ipv4.conf.all.rp_filter | |
169 | net.ipv4.conf.hub0.rp_filter = 1 | |
170 | </programlisting> | |
171 | ||
172 | <para>The <option>rp_filter</option> key will be set to "2" for all interfaces, except "hub0". We set | |
173 | <filename>net.ipv4.conf.default.rp_filter</filename> first, so any interfaces which are added | |
174 | <emphasis>later</emphasis> will get this value (this also covers any interfaces detected while we're | |
175 | running). The glob matches any interfaces which were detected <emphasis>earlier</emphasis>. The glob | |
176 | will also match <filename>net.ipv4.conf.all.rp_filter</filename>, which we don't want to set at all, so | |
177 | it is explicitly excluded. And "hub0" is excluded from the glob because it has an explicit setting. | |
178 | </para> | |
179 | </example> | |
180 | ||
798d3a52 ZJS |
181 | </refsect1> |
182 | ||
183 | <refsect1> | |
184 | <title>See Also</title> | |
13a69c12 DT |
185 | <para><simplelist type="inline"> |
186 | <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> | |
187 | <member><citerefentry><refentrytitle>systemd-sysctl.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> | |
188 | <member><citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> | |
189 | <member><citerefentry project='man-pages'><refentrytitle>sysctl</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> | |
190 | <member><citerefentry project='man-pages'><refentrytitle>sysctl.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> | |
191 | <member><citerefentry project='man-pages'><refentrytitle>modprobe</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> | |
192 | </simplelist></para> | |
798d3a52 | 193 | </refsect1> |
c91faef3 LP |
194 | |
195 | </refentry> |