Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Kernel sysctl configuration file for Linux
- # Version 1.13 - 2019-3-2
- # Day Milovich,,
- # credit mentioned below, not by me : )
- # nano /etc/sysctl.conf
- # edit save exit
- # then activate with:
- # sysctl -e -p /etc/sysctl.conf
- #
- # uname -a
- # Linux kali 4.18.0-kali2-amd64 #1 SMP Debian 4.18.10-2kali1 (2018-10-09) x86_64 GNU/Linux
- # ----------
- # 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
- # network security section
- # no syn attack, enable syncookies
- net.ipv4.tcp_syncookies = 1
- net.ipv4.tcp_syn_retries = 2
- net.ipv4.tcp_synack_retries = 2
- net.ipv4.tcp_max_syn_backlog = 1024
- # no 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
- # no 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
- # ip spoofing protection and source route verification
- net.ipv4.conf.all.rp_filter = 1
- net.ipv4.conf.default.rp_filter = 1
- # no icmp redir 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
- net.ipv4.tcp_fin_timeout = 7
- net.ipv4.tcp_keepalive_time = 300
- net.ipv4.tcp_keepalive_probes = 5
- net.ipv4.tcp_keepalive_intvl = 15
- # no relay bootp
- net.ipv4.conf.all.bootp_relay = 0
- # no proxy arp
- net.ipv4.conf.all.proxy_arp = 0
- # you can not ping me
- net.ipv4.icmp_echo_ignore_all = 1
- # Enable ignoring broadcasts request
- # net.ipv4.icmp_echo_ignore_broadcasts = 1
- # Enable bad error message Protection
- # net.ipv4.icmp_ignore_bogus_error_responses = 1
- # Enable a fix for RFC1337 - time-wait assassination hazards in TCP
- # net.ipv4.tcp_rfc1337 = 1
- # Do not auto-configure IPv6
- # net.ipv6.conf.all.autoconf=0
- # net.ipv6.conf.all.accept_ra=0
- # net.ipv6.conf.default.autoconf=0
- # net.ipv6.conf.default.accept_ra=0
- # net.ipv6.conf.eth0.autoconf=0
- # net.ipv6.conf.eth0.accept_ra=0
- ### TUNING NETWORK PERFORMANCE ###
- # For high-bandwidth low-latency networks, use 'htcp' congestion control
- # Do a 'modprobe tcp_htcp' first
- net.ipv4.tcp_congestion_control = htcp
- # For servers with tcp-heavy workloads, enable 'fq' queue management scheduler (kernel > 3.12)
- net.core.default_qdisc = fq
- # Turn on the tcp_window_scaling
- net.ipv4.tcp_window_scaling = 1
- # Increase the read-buffer space allocatable
- net.ipv4.tcp_rmem = 8192 87380 16777216
- net.ipv4.udp_rmem_min = 16384
- net.core.rmem_default = 262144
- net.core.rmem_max = 16777216
- # Increase the write-buffer-space allocatable
- net.ipv4.tcp_wmem = 8192 65536 16777216
- net.ipv4.udp_wmem_min = 16384
- net.core.wmem_default = 262144
- net.core.wmem_max = 16777216
- # Increase number of incoming connections
- net.core.somaxconn = 32768
- # Increase number of incoming connections backlog
- net.core.netdev_max_backlog = 16384
- net.core.dev_weight = 64
- # Increase the maximum amount of option memory buffers
- net.core.optmem_max = 65535
- # Increase the tcp-time-wait buckets pool size to prevent simple DOS attacks
- net.ipv4.tcp_max_tw_buckets = 1440000
- # try to reuse time-wait connections, but don't recycle them (recycle can break clients behind NAT)
- net.ipv4.tcp_tw_recycle = 0
- net.ipv4.tcp_tw_reuse = 1
- # Limit number of orphans, each orphan can eat up to 16M (max wmem) of unswappable memory
- net.ipv4.tcp_max_orphans = 16384
- net.ipv4.tcp_orphan_retries = 0
- # Limit the maximum memory used to reassemble IP fragments (CVE-2018-5391)
- net.ipv4.ipfrag_low_thresh = 196608
- net.ipv6.ip6frag_low_thresh = 196608
- net.ipv4.ipfrag_high_thresh = 262144
- net.ipv6.ip6frag_high_thresh = 262144
- # don't cache ssthresh from previous connection
- net.ipv4.tcp_no_metrics_save = 1
- net.ipv4.tcp_moderate_rcvbuf = 1
- # Increase size of RPC datagram queue length
- net.unix.max_dgram_qlen = 50
- # Don't allow the arp table to become bigger than this
- net.ipv4.neigh.default.gc_thresh3 = 2048
- # Tell the gc when to become aggressive with arp table cleaning.
- # Adjust this based on size of the LAN. 1024 is suitable for most /24 networks
- net.ipv4.neigh.default.gc_thresh2 = 1024
- # Adjust where the gc will leave arp table alone - set to 32.
- net.ipv4.neigh.default.gc_thresh1 = 32
- # Adjust to arp table gc to clean-up more often
- net.ipv4.neigh.default.gc_interval = 30
- # Increase TCP queue length
- net.ipv4.neigh.default.proxy_qlen = 96
- net.ipv4.neigh.default.unres_qlen = 6
- # Enable Explicit Congestion Notification (RFC 3168), disable it if it doesn't work for you
- net.ipv4.tcp_ecn = 1
- net.ipv4.tcp_reordering = 3
- # How many times to retry killing an alive TCP connection
- net.ipv4.tcp_retries2 = 15
- net.ipv4.tcp_retries1 = 3
- # Avoid falling back to slow start after a connection goes idle
- # keeps our cwnd large with the keep alive connections (kernel > 3.6)
- net.ipv4.tcp_slow_start_after_idle = 0
- # Allow the TCP fastopen flag to be used, beware some firewalls do not like TFO! (kernel > 3.7)
- net.ipv4.tcp_fastopen = 3
- # This will ensure that immediatly subsequent connections use the new values
- net.ipv4.route.flush = 1
- # net.ipv6.route.flush = 1
- ### Comments/suggestions/additions are welcome!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement