Last active
February 11, 2025 23:21
-
-
Save hidonet/c000b84d476dc3653dc9d82f313fe5ca to your computer and use it in GitHub Desktop.
sysctl.conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Kernel sysctl configuration file for Linux | |
# | |
# Version 1.14 - 2019-04-05 | |
# Michiel Klaver - IT Professional | |
# http://klaver.it/linux/ for the latest version - http://klaver.it/bsd/ for a BSD variant | |
# | |
# This file should be saved as /etc/sysctl.conf and can be activated using the command: | |
# sysctl -e -p /etc/sysctl.conf | |
# | |
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and sysctl.conf(5) for more details. | |
# | |
# Tested with: Ubuntu 14.04 LTS kernel version 3.13 | |
# Debian 7 kernel version 3.2 | |
# CentOS 7 kernel version 3.10 | |
# | |
# Intended use for dedicated server systems at high-speed networks with loads of RAM and bandwidth available | |
# Optimised and tuned for high-performance web/ftp/mail/dns servers with high connection-rates | |
# DO NOT USE at busy networks or xDSL/Cable connections where packetloss can be expected | |
# ---------- | |
# Credits: | |
# http://www.enigma.id.au/linux_tuning.txt | |
# http://www.securityfocus.com/infocus/1729 | |
# http://fasterdata.es.net/TCP-tuning/linux.html | |
# http://fedorahosted.org/ktune/browser/sysctl.ktune | |
# http://www.cymru.com/Documents/ip-stack-tuning.html | |
# http://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt | |
# http://www.frozentux.net/ipsysctl-tutorial/chunkyhtml/index.html | |
# http://knol.google.com/k/linux-performance-tuning-and-measurement | |
# http://www.cyberciti.biz/faq/linux-kernel-tuning-virtual-memory-subsystem/ | |
# http://www.redbooks.ibm.com/abstracts/REDP4285.html | |
# http://www.speedguide.net/read_articles.php?id=121 | |
# http://lartc.org/howto/lartc.kernel.obscure.html | |
# http://en.wikipedia.org/wiki/Sysctl | |
# https://blog.cloudflare.com/http-2-prioritization-with-nginx/ | |
### | |
### GENERAL SYSTEM SECURITY OPTIONS ### | |
### | |
# Controls the System Request debugging functionality of the kernel | |
kernel.sysrq = 0 | |
# Controls whether core dumps will append the PID to the core filename. | |
# Useful for debugging multi-threaded applications. | |
kernel.core_uses_pid = 1 | |
# Allow for more PIDs | |
kernel.pid_max = 65535 | |
# The contents of /proc/<pid>/maps and smaps files are only visible to | |
# readers that are allowed to ptrace() the process | |
kernel.maps_protect = 1 | |
# Enable ExecShield protection | |
kernel.exec-shield = 1 | |
kernel.randomize_va_space = 2 | |
# Controls the maximum size of a message, in bytes | |
kernel.msgmnb = 65535 | |
# Controls the default maximum size of a message queue | |
kernel.msgmax = 65535 | |
# Restrict core dumps | |
fs.suid_dumpable = 0 | |
# Hide exposed kernel pointers | |
kernel.kptr_restrict = 1 | |
### | |
### IMPROVE SYSTEM MEMORY MANAGEMENT ### | |
### | |
# Increase size of file handles and inode cache | |
fs.file-max = 1000000 | |
# Do less swapping | |
vm.swappiness = 10 | |
vm.dirty_ratio = 30 | |
vm.dirty_background_ratio = 5 | |
# Specifies the minimum virtual address that a process is allowed to mmap | |
vm.mmap_min_addr = 4096 | |
# 50% overcommitment of available memory | |
vm.overcommit_ratio = 50 | |
vm.overcommit_memory = 0 | |
# Set maximum amount of memory allocated to shm to 8GB (adjust based on your system's RAM) | |
kernel.shmmax = 8589934592 | |
kernel.shmall = 2097152 | |
# Keep at least 256MB of free RAM space available | |
vm.min_free_kbytes = 262144 | |
### | |
### GENERAL NETWORK SECURITY OPTIONS ### | |
### | |
# Prevent SYN attack, enable SYNcookies (they will kick-in when the max_syn_backlog reached) | |
net.ipv4.tcp_syncookies = 1 | |
net.ipv4.tcp_syn_retries = 2 | |
net.ipv4.tcp_synack_retries = 2 | |
net.ipv4.tcp_max_syn_backlog = 4096 | |
# Disables packet forwarding | |
net.ipv4.ip_forward = 0 | |
net.ipv4.conf.all.forwarding = 0 | |
net.ipv4.conf.default.forwarding = 0 | |
net.ipv6.conf.all.forwarding = 0 | |
net.ipv6.conf.default.forwarding = 0 | |
# Disables IP source routing | |
net.ipv4.conf.all.send_redirects = 0 | |
net.ipv4.conf.default.send_redirects = 0 | |
net.ipv4.conf.all.accept_source_route = 0 | |
net.ipv4.conf.default.accept_source_route = 0 | |
net.ipv6.conf.all.accept_source_route = 0 | |
net.ipv6.conf.default.accept_source_route = 0 | |
# Enable IP spoofing protection, turn on source route verification | |
net.ipv4.conf.all.rp_filter = 1 | |
net.ipv4.conf.default.rp_filter = 1 | |
# Disable ICMP Redirect Acceptance | |
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.ipv6.conf.all.accept_redirects = 0 | |
net.ipv6.conf.default.accept_redirects = 0 | |
# Enable Log Spoofed Packets, Source Routed Packets, Redirect Packets | |
net.ipv4.conf.all.log_martians = 1 | |
net.ipv4.conf.default.log_martians = 1 | |
# Decrease the time default value for tcp_fin_timeout connection | |
net.ipv4.tcp_fin_timeout = 7 | |
# Decrease the time default value for connections to keep alive | |
net.ipv4.tcp_keepalive_time = 120 | |
net.ipv4.tcp_keepalive_probes = 5 | |
net.ipv4.tcp_keepalive_intvl = 15 | |
# Don't relay bootp | |
net.ipv4.conf.all.bootp_relay = 0 | |
# Don't proxy arp for anyone | |
net.ipv4.conf.all.proxy_arp = 0 | |
# Turn on the tcp_timestamps, accurate timestamp make TCP congestion control algorithms work better | |
net.ipv4.tcp_timestamps = 1 | |
# Don't ignore directed pings | |
net.ipv4.icmp_echo_ignore_all = 0 | |
# Enable ignoring broadcasts request | |
net.ipv4.icmp_echo_ignore_broadcasts = 1 | |
# Enable bad error message Protection | |
net.ipv4.icmp_ignore_bogus_error_responses = ::contentReference[oaicite:0]{index=0} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment