博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
tcp/ip 调优示例
阅读量:5122 次
发布时间:2019-06-13

本文共 8348 字,大约阅读时间需要 27 分钟。

# Kernel sysctl configuration file for Linux## Version 1.12 - 2015-09-30# 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###### GENERAL SYSTEM SECURITY OPTIONS ####### Controls the System Request debugging functionality of the kernelkernel.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 PIDskernel.pid_max = 65535# The contents of /proc/
/maps and smaps files are only visible to# readers that are allowed to ptrace() the processkernel.maps_protect = 1#Enable ExecShield protectionkernel.exec-shield = 1kernel.randomize_va_space = 2# Controls the maximum size of a message, in byteskernel.msgmnb = 65535# Controls the default maxmimum size of a mesage queuekernel.msgmax = 65535# Restrict core dumpsfs.suid_dumpable = 0# Hide exposed kernel pointerskernel.kptr_restrict = 1###### IMPROVE SYSTEM MEMORY MANAGEMENT ####### Increase size of file handles and inode cachefs.file-max = 209708# Do less swappingvm.swappiness = 30vm.dirty_ratio = 30vm.dirty_background_ratio = 5# specifies the minimum virtual address that a process is allowed to mmapvm.mmap_min_addr = 4096# 50% overcommitment of available memoryvm.overcommit_ratio = 50vm.overcommit_memory = 0# Set maximum amount of memory allocated to shm to 256MBkernel.shmmax = 268435456kernel.shmall = 268435456# Keep at least 64MB of free RAM space availablevm.min_free_kbytes = 65535###### GENERAL NETWORK SECURITY OPTIONS #######Prevent SYN attack, enable SYNcookies (they will kick-in when the max_syn_backlog reached)net.ipv4.tcp_syncookies = 1net.ipv4.tcp_syn_retries = 2net.ipv4.tcp_synack_retries = 2net.ipv4.tcp_max_syn_backlog = 4096# Disables packet forwardingnet.ipv4.ip_forward = 0net.ipv4.conf.all.forwarding = 0net.ipv4.conf.default.forwarding = 0net.ipv6.conf.all.forwarding = 0net.ipv6.conf.default.forwarding = 0# Disables IP source routingnet.ipv4.conf.all.send_redirects = 0net.ipv4.conf.default.send_redirects = 0net.ipv4.conf.all.accept_source_route = 0net.ipv4.conf.default.accept_source_route = 0net.ipv6.conf.all.accept_source_route = 0net.ipv6.conf.default.accept_source_route = 0# Enable IP spoofing protection, turn on source route verificationnet.ipv4.conf.all.rp_filter = 1net.ipv4.conf.default.rp_filter = 1# Disable ICMP Redirect Acceptancenet.ipv4.conf.all.accept_redirects = 0net.ipv4.conf.default.accept_redirects = 0net.ipv4.conf.all.secure_redirects = 0net.ipv4.conf.default.secure_redirects = 0net.ipv6.conf.all.accept_redirects = 0net.ipv6.conf.default.accept_redirects = 0# Enable Log Spoofed Packets, Source Routed Packets, Redirect Packetsnet.ipv4.conf.all.log_martians = 1net.ipv4.conf.default.log_martians = 1# Decrease the time default value for tcp_fin_timeout connectionnet.ipv4.tcp_fin_timeout = 7# Decrease the time default value for connections to keep alivenet.ipv4.tcp_keepalive_time = 300net.ipv4.tcp_keepalive_probes = 5net.ipv4.tcp_keepalive_intvl = 15# Don't relay bootpnet.ipv4.conf.all.bootp_relay = 0# Don't proxy arp for anyonenet.ipv4.conf.all.proxy_arp = 0# Turn on the tcp_timestamps, accurate timestamp make TCP congestion control algorithms work betternet.ipv4.tcp_timestamps = 1# Don't ignore directed pingsnet.ipv4.icmp_echo_ignore_all = 0# Enable ignoring broadcasts requestnet.ipv4.icmp_echo_ignore_broadcasts = 1# Enable bad error message Protectionnet.ipv4.icmp_ignore_bogus_error_responses = 1# Allowed local port rangenet.ipv4.ip_local_port_range = 16384 65535# Enable a fix for RFC1337 - time-wait assassination hazards in TCPnet.ipv4.tcp_rfc1337 = 1# Do not auto-configure IPv6net.ipv6.conf.all.autoconf=0net.ipv6.conf.all.accept_ra=0net.ipv6.conf.default.autoconf=0net.ipv6.conf.default.accept_ra=0net.ipv6.conf.eth0.autoconf=0net.ipv6.conf.eth0.accept_ra=0###### TUNING NETWORK PERFORMANCE ####### For high-bandwidth low-latency networks, use 'htcp' congestion control# Do a 'modprobe tcp_htcp' firstnet.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_scalingnet.ipv4.tcp_window_scaling = 1# Increase the read-buffer space allocatablenet.ipv4.tcp_rmem = 8192 87380 16777216net.ipv4.udp_rmem_min = 16384net.core.rmem_default = 262144net.core.rmem_max = 16777216# Increase the write-buffer-space allocatablenet.ipv4.tcp_wmem = 8192 65536 16777216net.ipv4.udp_wmem_min = 16384net.core.wmem_default = 262144net.core.wmem_max = 16777216# Increase number of incoming connectionsnet.core.somaxconn = 32768# Increase number of incoming connections backlognet.core.netdev_max_backlog = 16384net.core.dev_weight = 64# Increase the maximum amount of option memory buffersnet.core.optmem_max = 65535# Increase the tcp-time-wait buckets pool size to prevent simple DOS attacksnet.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 = 0net.ipv4.tcp_tw_reuse = 1# Limit number of orphans, each orphan can eat up to 16M (max wmem) of unswappable memorynet.ipv4.tcp_max_orphans = 16384net.ipv4.tcp_orphan_retries = 0# Increase the maximum memory used to reassemble IP fragmentsnet.ipv4.ipfrag_high_thresh = 512000net.ipv4.ipfrag_low_thresh = 446464# don't cache ssthresh from previous connectionnet.ipv4.tcp_no_metrics_save = 1net.ipv4.tcp_moderate_rcvbuf = 1# Increase size of RPC datagram queue lengthnet.unix.max_dgram_qlen = 50# Don't allow the arp table to become bigger than thisnet.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 networksnet.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 oftennet.ipv4.neigh.default.gc_interval = 30# Increase TCP queue lengthnet.ipv4.neigh.default.proxy_qlen = 96net.ipv4.neigh.default.unres_qlen = 6# Enable Explicit Congestion Notification (RFC 3168), disable it if it doesn't work for younet.ipv4.tcp_ecn = 1net.ipv4.tcp_reordering = 3# How many times to retry killing an alive TCP connectionnet.ipv4.tcp_retries2 = 15net.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 enusre that immediatly subsequent connections use the new valuesnet.ipv4.route.flush = 1net.ipv6.route.flush = 1###### Comments/suggestions/additions are welcome!###
posted on
2017-05-22 15:26 阅读(
...) 评论(
...)

转载于:https://www.cnblogs.com/liujitao79/p/6889680.html

你可能感兴趣的文章
Java变量的初始化问题探究
查看>>
DSU on tree——令人惊叹的想法
查看>>
javascript 闭包
查看>>
约瑟夫环问题
查看>>
c++ __int64
查看>>
IP封锁 (防火墙维护一张IP黑名单)
查看>>
【模板】trie树(字典树)
查看>>
JSON.stringify 语法实例讲解
查看>>
Python6 模块
查看>>
P3377 【模板】左偏树(可并堆)
查看>>
Djang 用户登录
查看>>
Java同步锁——lock与synchronized 的区别【转】
查看>>
洛谷-校门外的树-数组
查看>>
Python--网络编程-----文件传输简单版本
查看>>
CF 208E. Blood Cousins [dsu on tree 倍增]
查看>>
趣谈面试(一)
查看>>
Quart2D setNeedsDisplay
查看>>
设计模式之策略设计模式
查看>>
Sql server 从一个表中获取数据更新到另一个表中
查看>>
JS继承的实现方式 原型 原型链 prototype和_proto_的区别
查看>>