Persistent sysctl configuration

Hi,

Is it possible to make sysctl adjustments and have them persist on reboots? I’ve tried the usual way of adding them to /etc/sysctl.conf or /etc/sysctl.d/xxxx.conf. Even though my changes to these files are indeed persistent, these files don’t seem te be applied on boot time; my changes won’t appear in sysctl -a.

Thanks!
Robbert

What console are you using?

http://docs.rancher.com/os/configuration/custom-console/#console-persistence

I’m using debian-console, but as I said, the sysctl configuration files are persisting. However, they are not applied on boot.

I write the /etc/sysctl.conf (644 perms) file and relevant settings via cloud-config on installation.

I also write the /opt/rancher/bin/start.sh (744 perms) script in at the same time, with this content:

#!/bin/sh
sysctl -p
exit

Works a treat.

thanks so much for this :slight_smile:, the cloud.config can be changed later at location /var/lib/rancher/cloud-config.yml

You’re welcome.

I’ve noticed in v1.0.1 at least it’s now this file: /var/lib/rancher/conf/cloud-config.d/user_config.yml.

Writing /etc/sysctl.conf from the cloud-config works fine (and is a good central place to put it), but that’s not really the problem; the contents of this file are already persistent.

The problem is that, unlike other Linux systems, they are not applied on boot. Applying them yourself with sysctl -p from start.sh is a great workaround (thanks @sjiveson), however, in my opinion this is something RancherOS should do automatically.

Even more, the suggested solution does not really work for me, because the sysctls are applied a bit late in the boot process. On other Linux systems where sysctl.conf is applied automatically, this is done in a very early stage, before any other init scripts are run. On RancherOS, it runs before “user docker”, which is great, but pretty much after everything else. A sysctl that disables IPv6 auto configuration, for example, will be applied after auto configuration is already done, making it useless here.

I guess there’s currently no way to do this; I’ll make sure to submit an issue to GitHub repo.

I agree this should be natively supported in RancherOS. We can add this to the cloud config something like:

#cloud-config
rancher:
  sysctl:
    net.ipv4.conf.default.rp_filter: 1

See https://github.com/rancher/os/issues/908. Values as object properties is even nicer, I’ll add it.