Essential Linux Performance & Security Tuning: Sysctl Settings Explained
This guide explains how to boost Linux server performance and harden security by tuning disk, network, memory, and file‑descriptor parameters with sysctl, ulimit, and iptables commands, providing practical examples and explanations for each setting.
Linux distributions use conservative defaults to ensure compatibility, but many settings can be tuned for better performance and security.
Disk Subsystem Optimization
Disable file access time logging by adding noatime to the fourth column in /etc/fstab, reducing unnecessary disk writes.
Network Tuning
Adjust TCP keepalive and backlog parameters to free resources faster:
net.ipv4.tcp_keepalive_time = 7200 net.ipv4.tcp_keepalive_intvl = 75 net.ipv4.tcp_keepalive_probes = 9 net.core.netdev_max_backlog = 3000 net.ipv4.tcp_max_syn_backlog = 1024 net.ipv4.tcp_synack_retries = 5 net.ipv4.tcp_retries2 = 15Enable SYN cookies to mitigate SYN flood attacks:
net.ipv4.tcp_syncookies = 1Security‑related Sysctl Settings
net.ipv4.conf.all.accept_source_route = 0 net.ipv4.conf.all.accept_redirects = 0 net.ipv4.conf.all.secure_redirects = 1 net.ipv4.conf.all.send_redirects = 0 net.ipv4.icmp_echo_ignore_broadcasts = 1 net.ipv4.icmp_echo_ignore_all = 1 net.ipv4.icmp_ignore_bogus_error_responses = 1TCP Connection Management
Reuse TIME‑WAIT sockets and shorten their lifetimes:
net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_fin_timeout = 30Memory and Buffer Settings
net.ipv4.core.wmem_max = 8388608 net.ipv4.core.rmem_max = 8388608 net.ipv4.tcp_rmem = "4096 87380 8388608" net.ipv4.tcp_wmem = "4096 87380 8388608"File Descriptor Limits
Increase per‑process limits with ulimit or by editing /etc/security/limits.conf: ulimit -u 10000 # max processes ulimit -n 4096 # max open files
* soft nofile 8192 * hard nofile 20480Firewall Rules
iptables -A INPUT -p tcp --syn -m limit --limit 1/s -j ACCEPT iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPTThese adjustments collectively improve Linux server throughput, reduce resource waste, and harden the system against common network attacks.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
