sysctl not sticking after reboot
If your system is using systemd's systemd-sysctl.service
and not sysctl
for the setting at boot time then things are a little different than sysctl
.
systemd-sysctl
sorts all of the configuration file names, ignoring the directory name, and then loads them in that order irrespective of the directory they were in. This means that if you put your setting in /etc/sysctl.d/10-mysysctl.conf
and there is another file called /usr/lib/sysctl.d/50-default.conf
setting the same variable, that will override your setting.
To ensure your setting isn't overridden you should put it in a config file with a name like /etc/sysctl.d/zzz-mysysctl.conf
.
Note: This behaviour was tested on Ubuntu 20.04.1 and openSUSE Leap 15.2
Create a file /etc/sysctl.d/local.conf
containing the values you want.
fs.suid_dumpable=0
net.ipv4.conf.all.log_martians=1
net.ipv4.conf.all.rp_filter=1
net.ipv4.conf.default.log_martians=1
Reboot.
The scripts load any *.conf files from several directories, in file name collation order. See the sysctl --system option in the man page for the search paths.
In particular, check that any values are not already defined in /etc/sysctl.conf
. Consider moving values you want to keep from it to sysctl.d
, then removing that file.