Linux 系统优化参数总结

时间:2021-12-31 16:08:47
系统优化参数总结:

net.ipv4.tcp_syncookies = 1  
    表示开启SYN Cookies。当出现SYN等待队列溢出时,启用cookies来处理,可防范少量SYN攻击
net.ipv4.tcp_tw_reuse = 1    
    表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接
net.ipv4.tcp_tw_recycle = 1  
    表示开启TCP连接中TIME-WAIT sockets的快速回收
    关闭 tcp_tw_reccycle 的时候,kernal 是不会检查对端机器的包的时间戳的
    在多nat模式下,需要关闭该参数,不然会导致用户无法连接或者连接超时
net.ipv4.tcp_fin_timeout = 30      
    表示如果套接字由本端要求关闭,这个参数决定了它保持在FIN-WAIT-2状态的时间

net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_default = 8388608
net.core.wmem_max = 16777216
net.ipv4.tcp_timestamps = 1
vm.overcommit_memory = 1
net.ipv4.tcp_keepalive_time = 120
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_max_syn_backlog = 6553500
net.core.somaxconn = 32768
net.core.netdev_max_backlog = 262144
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.ip_local_port_range = 1024  65535
net.ipv4.ip_forward = 1
    开启nat转发
net.ipv4.tcp_max_tw_buckets = 280000
net.netfilter.nf_conntrack_max = 65535000
net.netfilter.nf_conntrack_tcp_timeout_established = 1200