Overview
The kernel is the brains of a Linux system. Securing it through sysctl parameters can provide additional hardening against various attacks and improve overall system security.Why Sysctl Hardening?
Kernel hardening helps protect against:- Spoofing attacks
- Denial of Service (DOS) attacks
- Network-based exploits
- Local privilege escalation
- Information disclosure
Important Disclaimer
These settings are compiled from multiple reputable sources. Most of them are for general kernel hardening and performance, while others protect against spoofing and DOS attacks. Test each setting thoroughly before deploying to production.Documentation for these settings references the Linux 2.2 kernel. Settings may have changed in newer kernels. Always test in a non-production environment first.
Testing Sysctl Changes
Before making any kernel sysctl change permanent, test it with the sysctl command:There are no spaces in
key=value, including before and after the equals sign.Making Changes Permanent
Once you have tested a setting and verified it works without breaking your server, make it permanent by adding the values to/etc/sysctl.conf:
If sysctl has trouble writing any settings,
sysctl -w or sysctl -p will write an error to stderr. You can use this to quickly find invalid settings: