Score:2

Can I change the default sysctl values in grub?

it flag

When using kernels older than 5.1, if a user creates a network namespace, it starts with the default sysctl values. Even if the root namespaces changed those values with sysctl, the new network namespaces will still use the default values.For example, proc/sys/net/ipv6/conf/all/forwarding is always 0 because that's the default value.

If I understand correctly, those are default values set by the kernel and I was wondering if it is possible to change those via GRUB_CMDLINE_LINUX or any other way. Note that I don't want to access the network namespace and change the parameter via sysctl (or echo /proc/sys/net....), I'd like to change the default value

Score:2
cl flag
A.B

The feature you are looking for is available only since kernel 5.8, as described in this UL SE Q/A: How to set sysctl using kernel command line parameter?:

sysctl.*= [KNL]

      Set a sysctl parameter, right before loading the init
      process, as if the value was written to the respective
      /proc/sys/... file. Both '.' and '/' are recognized as
      separators. Unrecognized parameters and invalid values
      are reported in the kernel log. Sysctls registered
      later by a loaded module cannot be set this way.
      Example: sysctl.vm.swappiness=40

So combined with devconf_inherit_init_net found by OP in a previous Q/A, starting from kernel 5.8, but not before and thus not before 5.1 either, adding through GRUB these two kernel parameters:

sysctl.net.core.devconf_inherit_init_net=1 sysctl.net.ipv6.conf.all.forwarding=1

will achieve the intended goal.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.