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 = 7200net.ipv4.tcp_keepalive_intvl = 75net.ipv4.tcp_keepalive_probes = 9net.core.netdev_max_backlog = 3000net.ipv4.tcp_max_syn_backlog = 1024net.ipv4.tcp_synack_retries = 5net.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 = 0net.ipv4.conf.all.accept_redirects = 0net.ipv4.conf.all.secure_redirects = 1net.ipv4.conf.all.send_redirects = 0net.ipv4.icmp_echo_ignore_broadcasts = 1net.ipv4.icmp_echo_ignore_all = 1net.ipv4.icmp_ignore_bogus_error_responses = 1TCP Connection Management
Reuse TIME‑WAIT sockets and shorten their lifetimes:
net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_fin_timeout = 30Memory and Buffer Settings
net.ipv4.core.wmem_max = 8388608net.ipv4.core.rmem_max = 8388608net.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 ACCEPTiptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPTiptables -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.
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.
