systems:media_server:secure_the_server:harden_linux_kernel_configuration_parameters
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
systems:media_server:secure_the_server:harden_linux_kernel_configuration_parameters [2025/05/31 11:54] – created peter | systems:media_server:secure_the_server:harden_linux_kernel_configuration_parameters [2025/05/31 16:07] (current) – peter | ||
---|---|---|---|
Line 3: | Line 3: | ||
The Linux kernel is flexible, and the way it works can be modified on the fly by dynamically changing some of its parameters using the **sysctl** command. | The Linux kernel is flexible, and the way it works can be modified on the fly by dynamically changing some of its parameters using the **sysctl** command. | ||
- | * **sysctl** | + | * **sysctl** allows the viewing |
- | * Changes take effect immediately, | + | |
* The parameters available are those listed under /proc/sys/. | * The parameters available are those listed under /proc/sys/. | ||
+ | * Changes take effect immediately. | ||
+ | * The related **/ | ||
<WRAP alert> | <WRAP alert> | ||
**IMPORTANT NOTE: | **IMPORTANT NOTE: | ||
</ | </ | ||
- | |||
---- | ---- | ||
- | ====== Make a backup of the existing / | + | ===== Make a backup of the existing / |
<code bash> | <code bash> | ||
Line 22: | Line 22: | ||
---- | ---- | ||
- | ====== Modify the sysctl file ====== | + | ===== Modify the sysctl file ===== |
- | <code bash> | + | Add the following entries to the bottom of the **/ |
- | sudo vi / | + | |
- | </ | + | |
- | + | ||
- | Remove the hash sign in front of certain command lines to stop some spoofing attacks and enhance other security measures: | + | |
<file bash / | <file bash / | ||
- | net.ipv4.conf.default.rp_filter=1 | + | ... |
- | net.ipv4.conf.all.rp_filter=1 | + | ... |
- | net.ipv4.tcp_syncookies=1 | + | # Network Security |
- | net.ipv4.icmp_echo_ignore_broadcasts = 1 | + | |
- | net.ipv4.icmp_ignore_bogus_error_responses = 1 | + | |
- | net.ipv4.conf.all.accept_redirects = 0 | + | |
net.ipv4.conf.all.send_redirects = 0 | net.ipv4.conf.all.send_redirects = 0 | ||
+ | net.ipv4.conf.default.send_redirects = 0 | ||
+ | net.ipv4.conf.all.accept_redirects = 0 | ||
+ | net.ipv4.conf.default.accept_redirects = 0 | ||
+ | net.ipv4.conf.all.secure_redirects = 0 | ||
+ | net.ipv4.conf.default.secure_redirects = 0 | ||
net.ipv4.conf.all.accept_source_route = 0 | net.ipv4.conf.all.accept_source_route = 0 | ||
+ | net.ipv4.conf.default.accept_source_route = 0 | ||
+ | net.ipv4.conf.all.log_martians = 1 | ||
+ | net.ipv4.conf.default.log_martians = 1 | ||
+ | net.ipv4.icmp_echo_ignore_broadcasts = 1 | ||
+ | net.ipv4.icmp_ignore_bogus_error_responses = 1 | ||
+ | net.ipv4.conf.all.rp_filter = 1 | ||
+ | net.ipv4.conf.default.rp_filter = 1 | ||
+ | net.ipv4.tcp_syncookies = 1 | ||
+ | net.ipv4.tcp_max_syn_backlog = 2048 | ||
+ | net.ipv4.tcp_synack_retries = 2 | ||
+ | net.ipv4.tcp_syn_retries = 5 | ||
+ | # IPv6 Security (if enabled) | ||
net.ipv6.conf.all.accept_redirects = 0 | net.ipv6.conf.all.accept_redirects = 0 | ||
+ | net.ipv6.conf.default.accept_redirects = 0 | ||
net.ipv6.conf.all.accept_source_route = 0 | net.ipv6.conf.all.accept_source_route = 0 | ||
+ | net.ipv6.conf.default.accept_source_route = 0 | ||
+ | |||
+ | # Process Security | ||
+ | kernel.randomize_va_space = 2 | ||
+ | kernel.kptr_restrict = 2 | ||
+ | kernel.dmesg_restrict = 1 | ||
+ | kernel.perf_event_paranoid = 3 | ||
+ | kernel.yama.ptrace_scope = 2 | ||
+ | kernel.panic_on_oops = 1 | ||
+ | kernel.panic = 60 | ||
+ | kernel.sysrq = 0 | ||
+ | |||
+ | |||
+ | # File System Security | ||
+ | fs.protected_hardlinks = 1 | ||
+ | fs.protected_symlinks = 1 | ||
+ | fs.suid_dumpable = 0 | ||
+ | fs.protected_fifos = 2 | ||
+ | fs.protected_regular = 2 | ||
+ | |||
+ | # Additional Security Measures | ||
+ | # | ||
+ | # | ||
+ | kernel.core_uses_pid = 1 | ||
+ | kernel.panic_on_unrecovered_nmi = 1 | ||
+ | kernel.panic_on_io_nmi = 1 | ||
+ | kernel.unprivileged_bpf_disabled = 1 | ||
+ | net.core.bpf_jit_harden = 2 | ||
</ | </ | ||
Line 48: | Line 87: | ||
---- | ---- | ||
- | ====== Activate the kernel settings that have been modified | + | ===== Activate the kernel settings that have been modified ===== |
This reloads the sysctl parameters: | This reloads the sysctl parameters: | ||
Line 56: | Line 95: | ||
</ | </ | ||
+ | ---- |
systems/media_server/secure_the_server/harden_linux_kernel_configuration_parameters.1748692467.txt.gz · Last modified: 2025/05/31 11:54 by peter