| 1 |
'\" t |
| 2 |
.TH "SYSCTL\&.D" "5" "" "systemd 261~rc3" "sysctl.d" |
| 3 |
.\" ----------------------------------------------------------------- |
| 4 |
.\" * Define some portability stuff |
| 5 |
.\" ----------------------------------------------------------------- |
| 6 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 7 |
.\" http://bugs.debian.org/507673 |
| 8 |
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html |
| 9 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 10 |
.ie \n(.g .ds Aq \(aq |
| 11 |
.el .ds Aq ' |
| 12 |
.\" ----------------------------------------------------------------- |
| 13 |
.\" * set default formatting |
| 14 |
.\" ----------------------------------------------------------------- |
| 15 |
.\" disable hyphenation |
| 16 |
.nh |
| 17 |
.\" disable justification (adjust text to left margin only) |
| 18 |
.ad l |
| 19 |
.\" ----------------------------------------------------------------- |
| 20 |
.\" * MAIN CONTENT STARTS HERE * |
| 21 |
.\" ----------------------------------------------------------------- |
| 22 |
.SH "NAME" |
| 23 |
sysctl.d \- Configure kernel parameters at boot |
| 24 |
.SH "SYNOPSIS" |
| 25 |
.PP |
| 26 |
.RS 4 |
| 27 |
/etc/sysctl\&.d/*\&.conf |
| 28 |
.RE |
| 29 |
.RS 4 |
| 30 |
/run/sysctl\&.d/*\&.conf |
| 31 |
.RE |
| 32 |
.RS 4 |
| 33 |
/usr/local/lib/sysctl\&.d/*\&.conf |
| 34 |
.RE |
| 35 |
.RS 4 |
| 36 |
/usr/lib/sysctl\&.d/*\&.conf |
| 37 |
.RE |
| 38 |
.sp |
| 39 |
.nf |
| 40 |
key\&.name\&.under\&.proc\&.sys = some value |
| 41 |
key/name/under/proc/sys = some value |
| 42 |
key/middle\&.part\&.with\&.dots/foo = 123 |
| 43 |
key\&.middle/part/with/dots\&.foo = 123 |
| 44 |
\-key\&.that\&.will\&.not\&.fail = value |
| 45 |
key\&.pattern\&.*\&.with\&.glob = whatever |
| 46 |
\-key\&.pattern\&.excluded\&.with\&.glob |
| 47 |
key\&.pattern\&.overridden\&.with\&.glob = custom |
| 48 |
.fi |
| 49 |
.SH "DESCRIPTION" |
| 50 |
.PP |
| 51 |
At boot, |
| 52 |
\fBsystemd-sysctl.service\fR(8) |
| 53 |
reads configuration files from the above directories to configure |
| 54 |
\fBsysctl\fR(8) |
| 55 |
kernel parameters\&. |
| 56 |
.SH "CONFIGURATION FORMAT" |
| 57 |
.PP |
| 58 |
The configuration files contain a list of variable assignments, separated by newlines\&. Empty lines and lines whose first non\-whitespace character is |
| 59 |
"#" |
| 60 |
or |
| 61 |
";" |
| 62 |
are ignored\&. |
| 63 |
.PP |
| 64 |
Note that either |
| 65 |
"/" |
| 66 |
or |
| 67 |
"\&." |
| 68 |
may be used as separators within sysctl variable names\&. If the first separator is a slash, remaining slashes and dots are left intact\&. If the first separator is a dot, dots and slashes are interchanged\&. |
| 69 |
"kernel\&.domainname=foo" |
| 70 |
and |
| 71 |
"kernel/domainname=foo" |
| 72 |
are equivalent and will cause |
| 73 |
"foo" |
| 74 |
to be written to |
| 75 |
/proc/sys/kernel/domainname\&. Either |
| 76 |
"net\&.ipv4\&.conf\&.enp3s0/200\&.forwarding" |
| 77 |
or |
| 78 |
"net/ipv4/conf/enp3s0\&.200/forwarding" |
| 79 |
may be used to refer to |
| 80 |
/proc/sys/net/ipv4/conf/enp3s0\&.200/forwarding\&. A glob |
| 81 |
\fBglob\fR(7) |
| 82 |
pattern may be used to write the same value to all matching keys\&. Keys for which an explicit pattern exists will be excluded from any glob matching\&. In addition, a key may be explicitly excluded from being set by any matching glob patterns by specifying the key name prefixed with a |
| 83 |
"\-" |
| 84 |
character and not followed by |
| 85 |
"=", see SYNOPSIS\&. |
| 86 |
.PP |
| 87 |
Any access permission errors and attempts to write variables not present on the local system are logged at debug level and do not cause the service to fail\&. Other types of errors when setting variables are logged with higher priority and cause the service to return failure at the end (after processing other variables)\&. As an exception, if a variable assignment is prefixed with a single |
| 88 |
"\-" |
| 89 |
character, failure to set the variable for any reason will be logged at debug level and will not cause the service to fail\&. |
| 90 |
.PP |
| 91 |
The settings configured with |
| 92 |
sysctl\&.d |
| 93 |
files will be applied early on boot\&. The network interface\-specific options will also be applied individually for each network interface as it shows up in the system\&. (More specifically, |
| 94 |
net\&.ipv4\&.conf\&.*, |
| 95 |
net\&.ipv6\&.conf\&.*, |
| 96 |
net\&.ipv4\&.neigh\&.* |
| 97 |
and |
| 98 |
net\&.ipv6\&.neigh\&.*)\&. |
| 99 |
.PP |
| 100 |
Many sysctl parameters only become available when certain kernel modules are loaded\&. Modules are usually loaded on demand, e\&.g\&. when certain hardware is plugged in or network brought up\&. This means that |
| 101 |
\fBsystemd-sysctl.service\fR(8) |
| 102 |
which runs during early boot will not configure such parameters if they become available after it has run\&. To set such parameters, it is recommended to add an |
| 103 |
\fBudev\fR(7) |
| 104 |
rule to set those parameters when they become available\&. Alternatively, a slightly simpler and less efficient option is to add the module to |
| 105 |
\fBmodules-load.d\fR(5), causing it to be loaded statically before sysctl settings are applied (see example below)\&. |
| 106 |
.SH "CONFIGURATION DIRECTORIES AND PRECEDENCE" |
| 107 |
.PP |
| 108 |
Configuration files are read from directories in |
| 109 |
/etc/, |
| 110 |
/run/, |
| 111 |
/usr/local/lib/, and |
| 112 |
/usr/lib/, in order of precedence, as listed in the SYNOPSIS section above\&. Files must have the |
| 113 |
"\&.conf" |
| 114 |
extension\&. Files in |
| 115 |
/etc/ |
| 116 |
override files with the same name in |
| 117 |
/run/, |
| 118 |
/usr/local/lib/, and |
| 119 |
/usr/lib/\&. Files in |
| 120 |
/run/ |
| 121 |
override files with the same name under |
| 122 |
/usr/\&. |
| 123 |
.PP |
| 124 |
All configuration files are sorted by their filename in lexicographic order, regardless of which of the directories they reside in\&. If multiple files specify the same option, the entry in the file with the lexicographically latest name will take precedence\&. Thus, the configuration in a certain file may either be replaced completely (by placing a file with the same name in a directory with higher priority), or individual settings might be changed (by specifying additional settings in a file with a different name that is ordered later)\&. |
| 125 |
.PP |
| 126 |
Packages should install their configuration files in |
| 127 |
/usr/lib/ |
| 128 |
(distribution packages) or |
| 129 |
/usr/local/lib/ |
| 130 |
(local installs) |
| 131 |
\&\s-2\u[1]\d\s+2\&. Files in |
| 132 |
/etc/ |
| 133 |
are reserved for the local administrator, who may use this logic to override the configuration files installed by vendor packages\&. |
| 134 |
.PP |
| 135 |
It is recommended to prefix all filenames with a two\-digit number and a dash to simplify the ordering\&. It is recommended to use the range 10\-40 for configuration files in |
| 136 |
/usr/ |
| 137 |
and the range 60\-90 for configuration files in |
| 138 |
/etc/ |
| 139 |
and |
| 140 |
/run/, to make sure that local and transient configuration files will always take priority over configuration files shipped by the OS vendor\&. |
| 141 |
.PP |
| 142 |
If the administrator wants to disable a configuration file supplied by the vendor, the recommended way is to place a symlink to |
| 143 |
/dev/null |
| 144 |
in the configuration directory in |
| 145 |
/etc/, with the same filename as the vendor configuration file\&. If the vendor configuration file is included in the initrd image, the image has to be regenerated\&. |
| 146 |
.SH "EXAMPLES" |
| 147 |
.PP |
| 148 |
\fBExample\ \&1.\ \&Set kernel YP domain name\fR |
| 149 |
.PP |
| 150 |
/etc/sysctl\&.d/domain\-name\&.conf: |
| 151 |
.sp |
| 152 |
.if n \{\ |
| 153 |
.RS 4 |
| 154 |
.\} |
| 155 |
.nf |
| 156 |
kernel\&.domainname=example\&.com |
| 157 |
.fi |
| 158 |
.if n \{\ |
| 159 |
.RE |
| 160 |
.\} |
| 161 |
.PP |
| 162 |
\fBExample\ \&2.\ \&Apply settings available only when a certain module is loaded (method one)\fR |
| 163 |
.PP |
| 164 |
/etc/udev/rules\&.d/99\-bridge\&.rules: |
| 165 |
.sp |
| 166 |
.if n \{\ |
| 167 |
.RS 4 |
| 168 |
.\} |
| 169 |
.nf |
| 170 |
ACTION=="add", SUBSYSTEM=="module", KERNEL=="br_netfilter", \e |
| 171 |
RUN+="/usr/lib/systemd/systemd\-sysctl \-\-prefix=/net/bridge" |
| 172 |
.fi |
| 173 |
.if n \{\ |
| 174 |
.RE |
| 175 |
.\} |
| 176 |
.PP |
| 177 |
/etc/sysctl\&.d/bridge\&.conf: |
| 178 |
.sp |
| 179 |
.if n \{\ |
| 180 |
.RS 4 |
| 181 |
.\} |
| 182 |
.nf |
| 183 |
net\&.bridge\&.bridge\-nf\-call\-ip6tables = 0 |
| 184 |
net\&.bridge\&.bridge\-nf\-call\-iptables = 0 |
| 185 |
net\&.bridge\&.bridge\-nf\-call\-arptables = 0 |
| 186 |
.fi |
| 187 |
.if n \{\ |
| 188 |
.RE |
| 189 |
.\} |
| 190 |
.PP |
| 191 |
This method applies settings when the module is loaded\&. Please note that, unless the |
| 192 |
br_netfilter |
| 193 |
module is loaded, bridged packets will not be filtered by Netfilter (starting with kernel 3\&.18), so simply not loading the module is sufficient to avoid filtering\&. |
| 194 |
.PP |
| 195 |
\fBExample\ \&3.\ \&Apply settings available only when a certain module is loaded (method two)\fR |
| 196 |
.PP |
| 197 |
/etc/modules\-load\&.d/bridge\&.conf: |
| 198 |
.sp |
| 199 |
.if n \{\ |
| 200 |
.RS 4 |
| 201 |
.\} |
| 202 |
.nf |
| 203 |
br_netfilter |
| 204 |
.fi |
| 205 |
.if n \{\ |
| 206 |
.RE |
| 207 |
.\} |
| 208 |
.PP |
| 209 |
/etc/sysctl\&.d/bridge\&.conf: |
| 210 |
.sp |
| 211 |
.if n \{\ |
| 212 |
.RS 4 |
| 213 |
.\} |
| 214 |
.nf |
| 215 |
net\&.bridge\&.bridge\-nf\-call\-ip6tables = 0 |
| 216 |
net\&.bridge\&.bridge\-nf\-call\-iptables = 0 |
| 217 |
net\&.bridge\&.bridge\-nf\-call\-arptables = 0 |
| 218 |
.fi |
| 219 |
.if n \{\ |
| 220 |
.RE |
| 221 |
.\} |
| 222 |
.PP |
| 223 |
This method forces the module to be always loaded\&. Please note that, unless the |
| 224 |
br_netfilter |
| 225 |
module is loaded, bridged packets will not be filtered with Netfilter (starting with kernel 3\&.18), so simply not loading the module is sufficient to avoid filtering\&. |
| 226 |
.PP |
| 227 |
\fBExample\ \&4.\ \&Set network routing properties for all interfaces\fR |
| 228 |
.PP |
| 229 |
/etc/sysctl\&.d/20\-rp_filter\&.conf: |
| 230 |
.sp |
| 231 |
.if n \{\ |
| 232 |
.RS 4 |
| 233 |
.\} |
| 234 |
.nf |
| 235 |
net\&.ipv4\&.conf\&.default\&.rp_filter = 2 |
| 236 |
net\&.ipv4\&.conf\&.*\&.rp_filter = 2 |
| 237 |
\-net\&.ipv4\&.conf\&.all\&.rp_filter |
| 238 |
net\&.ipv4\&.conf\&.hub0\&.rp_filter = 1 |
| 239 |
.fi |
| 240 |
.if n \{\ |
| 241 |
.RE |
| 242 |
.\} |
| 243 |
.PP |
| 244 |
The |
| 245 |
\fBrp_filter\fR |
| 246 |
key will be set to "2" for all interfaces, except "hub0"\&. We set |
| 247 |
net\&.ipv4\&.conf\&.default\&.rp_filter |
| 248 |
first, so any interfaces which are added |
| 249 |
\fIlater\fR |
| 250 |
will get this value (this also covers any interfaces detected while we\*(Aqre running)\&. The glob matches any interfaces which were detected |
| 251 |
\fIearlier\fR\&. The glob will also match |
| 252 |
net\&.ipv4\&.conf\&.all\&.rp_filter, which we do not want to set at all, so it is explicitly excluded\&. And "hub0" is excluded from the glob because it has an explicit setting\&. |
| 253 |
.SH "SEE ALSO" |
| 254 |
.PP |
| 255 |
\fBsystemd\fR(1), \fBsystemd-sysctl.service\fR(8), \fBsystemd-delta\fR(1), \fBsysctl\fR(8), \fBsysctl.conf\fR(5), \fBmodprobe\fR(8) |
| 256 |
.SH "NOTES" |
| 257 |
.IP " 1." 4 |
| 258 |
💣💥🧨💥💥💣 Please note that those configuration files must be available at all times. If |
| 259 |
/usr/local/ |
| 260 |
is a separate partition, it may not be available during early boot, and must not be used for configuration. |
| 261 |
|