Updated: 11 October 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9
A kernel parameter set with sysctl can be lost at reboot for two reasons: it was only set at runtime, or another tool sets it again later in the boot. These steps apply to Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9.
Make a setting permanent
- Put it in its own file in
/etc/sysctl.d/, for example/etc/sysctl.d/99-custom.conf:net.ipv4.conf.all.forwarding = 0 - Load all files now:
sysctl --system. - Check the value:
sysctl net.ipv4.conf.all.forwarding.
Files are read in name order, and a later file wins. The 99- prefix makes yours load last.
If it still changes after reboot
- tuned (AlmaLinux/Rocky): a tuned profile can set sysctl values after boot. See the active profile with
tuned-adm active. Create a custom profile in/etc/tuned/myprofile/tuned.confwithinclude=virtual-guest(your current profile) and a[sysctl]section, thentuned-adm profile myprofile. - Docker, libvirt or VPN software turn IP forwarding on when they start. Stop them from managing it, or accept the change.
- Find which files set a value:
grep -r forwarding /etc/sysctl.conf /etc/sysctl.d /usr/lib/sysctl.d /run/sysctl.d.
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
