Config in /etc/sysctl.d/*.conf
net.ipv4.tcp_syncookies = 1 # SYN flood protection
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.all.rp_filter = 1 # reverse path filtering (anti-spoofing)
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
kernel.randomize_va_space = 2 # full ASLR
kernel.dmesg_restrict = 1 # restrict dmesg
kernel.yama.ptrace_scope = 1 # restrict ptrace
kernel.kptr_restrict = 2 # hide kernel pointers
References:
Audit exposure: systemd-analyze security <service>
Key directives:
ProtectSystem=strict # everything read-only except /dev, /proc, /sys
PrivateTmp=yes # isolated /tmp namespace
NoNewPrivileges=true # no privilege escalation
CapabilityBoundingSet= # restrict Linux capabilities
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
PrivateDevices=yes
RestrictNamespaces=yes
RestrictSUIDSGID=true
IPAddressAllow= # network access control
References:
Kernel-level syscall, file access, auth auditing. Rules in /etc/audit/audit.rules.
Best practice repos:
Expect 10-15% CPU overhead with security-centric config.
| Feature | SELinux | AppArmor |
|---|---|---|
| Model | Labels (inode-based) | Path-based |
| Distros | RHEL, CentOS, Fedora | Debian, Ubuntu |
| Depth | Deeper, system-wide | Simpler, application-focused |
| Weakness | Steep learning curve | Hard links bypass paths |
Both must be in enforcing mode in production. Choose based on distro.
Create baseline snapshots of checksums/permissions/timestamps, detect changes.
References:
CIS: Level 1 (most environments) and Level 2 (high-security). Fresh Ubuntu scores 50s-60s; after Level 1 hardening, 70s-80s.
Lynis: 2000+ config checks, prioritized recommendations.
Core: disable password auth, disable root login, Ed25519 keys, idle timeout, fail2ban.
2025 updates: sntrup761x25519-sha512 in KexAlgorithms, ED25519 host keys prioritized.