1SYSCTL.D(5) sysctl.d SYSCTL.D(5)
2
3
4
6 sysctl.d - Configure kernel parameters at boot
7
9 /etc/sysctl.d/*.conf
10
11 /run/sysctl.d/*.conf
12
13 /usr/lib/sysctl.d/*.conf
14
16 At boot, systemd-sysctl.service(8) reads configuration files from the
17 above directories to configure sysctl(8) kernel parameters.
18
20 The configuration files contain a list of variable assignments,
21 separated by newlines. Empty lines and lines whose first non-whitespace
22 character is "#" or ";" are ignored.
23
24 Note that either "/" or "." may be used as separators within sysctl
25 variable names. If the first separator is a slash, remaining slashes
26 and dots are left intact. If the first separator is a dot, dots and
27 slashes are interchanged. "kernel.domainname=foo" and
28 "kernel/domainname=foo" are equivalent and will cause "foo" to be
29 written to /proc/sys/kernel/domainname. Either
30 "net.ipv4.conf.enp3s0/200.forwarding" or
31 "net/ipv4/conf/enp3s0.200/forwarding" may be used to refer to
32 /proc/sys/net/ipv4/conf/enp3s0.200/forwarding.
33
34 Any access permission errors and attempts to write variables not
35 defined on the local system are logged, but do not cause the service to
36 fail. Moreover, if a variable assignment is prefixed with a single "-"
37 character, failure to set the variable will be logged, but will not
38 cause the service to fail. All other errors when setting variables
39 cause the service to return failure at the end (other variables are
40 still processed).
41
42 The settings configured with sysctl.d files will be applied early on
43 boot. The network interface-specific options will also be applied
44 individually for each network interface as it shows up in the system.
45 (More specifically, net.ipv4.conf.*, net.ipv6.conf.*, net.ipv4.neigh.*
46 and net.ipv6.neigh.*).
47
48 Many sysctl parameters only become available when certain kernel
49 modules are loaded. Modules are usually loaded on demand, e.g. when
50 certain hardware is plugged in or network brought up. This means that
51 systemd-sysctl.service(8) which runs during early boot will not
52 configure such parameters if they become available after it has run. To
53 set such parameters, it is recommended to add an udev(7) rule to set
54 those parameters when they become available. Alternatively, a slightly
55 simpler and less efficient option is to add the module to modules-
56 load.d(5), causing it to be loaded statically before sysctl settings
57 are applied (see example below).
58
60 Configuration files are read from directories in /etc/, /run/,
61 /usr/local/lib/, and /usr/lib/, in order of precedence. Each
62 configuration file in these configuration directories shall be named in
63 the style of filename.conf. Files in /etc/ override files with the same
64 name in /run/, /usr/local/lib/, and /usr/lib/. Files in /run/ override
65 files with the same name under /usr/.
66
67 Packages should install their configuration files in /usr/lib/
68 (distribution packages) or /usr/local/lib/ (local installs). Files in
69 /etc/ are reserved for the local administrator, who may use this logic
70 to override the configuration files installed by vendor packages. All
71 configuration files are sorted by their filename in lexicographic
72 order, regardless of which of the directories they reside in. If
73 multiple files specify the same option, the entry in the file with the
74 lexicographically latest name will take precedence. It is recommended
75 to prefix all filenames with a two-digit number and a dash, to simplify
76 the ordering of the files.
77
78 If the administrator wants to disable a configuration file supplied by
79 the vendor, the recommended way is to place a symlink to /dev/null in
80 the configuration directory in /etc/, with the same filename as the
81 vendor configuration file. If the vendor configuration file is included
82 in the initrd image, the image has to be regenerated.
83
85 Example 1. Set kernel YP domain name
86
87 /etc/sysctl.d/domain-name.conf:
88
89 kernel.domainname=example.com
90
91 Example 2. Apply settings available only when a certain module is
92 loaded (method one)
93
94 /etc/udev/rules.d/99-bridge.rules:
95
96 ACTION=="add", SUBSYSTEM=="module", KERNEL=="br_netfilter", \
97 RUN+="/usr/lib/systemd/systemd-sysctl --prefix=/net/bridge"
98
99 /etc/sysctl.d/bridge.conf:
100
101 net.bridge.bridge-nf-call-ip6tables = 0
102 net.bridge.bridge-nf-call-iptables = 0
103 net.bridge.bridge-nf-call-arptables = 0
104
105 This method applies settings when the module is loaded. Please note
106 that, unless the br_netfilter module is loaded, bridged packets will
107 not be filtered by Netfilter (starting with kernel 3.18), so simply not
108 loading the module is sufficient to avoid filtering.
109
110 Example 3. Apply settings available only when a certain module is
111 loaded (method two)
112
113 /etc/modules-load.d/bridge.conf:
114
115 br_netfilter
116
117 /etc/sysctl.d/bridge.conf:
118
119 net.bridge.bridge-nf-call-ip6tables = 0
120 net.bridge.bridge-nf-call-iptables = 0
121 net.bridge.bridge-nf-call-arptables = 0
122
123 This method forces the module to be always loaded. Please note that,
124 unless the br_netfilter module is loaded, bridged packets will not be
125 filtered with Netfilter (starting with kernel 3.18), so simply not
126 loading the module is sufficient to avoid filtering.
127
129 systemd(1), systemd-sysctl.service(8), systemd-delta(1), sysctl(8),
130 sysctl.conf(5), modprobe(8)
131
132
133
134systemd 243 SYSCTL.D(5)