vim /etc/sysctl.conf
复制覆盖进去
# 保障TCP通信质量
net.ipv4.tcp_sack = 1
net.ipv4.tcp_fack = 1
fs.aio-max-nr = 1048576
kernel.sem = 250 32000 100 128
#最小化交换的数量
vm.swappiness = 20
vm.dirty_ratio = 80
vm.dirty_background_ratio = 5
#增加文件句柄和inode缓存的大小并限制核心转储
fs.file-max = 2097152
fs.suid_dumpable = 0
#修改inotify 监控优化
fs.inotify.max_queued_events=66666
fs.inotify.max_user_watches=100000
#更改传入连接和传入连接积压的数量
net.core.netdev_max_backlog = 262144
#增加内存缓冲区的最大数量
net.core.optmem_max = 25165824
#增加默认和最大的发送/接收缓冲区
net.core.rmem_default = 31457280
net.core.rmem_max = 67108864
net.core.wmem_default = 31457280
net.core.wmem_max = 67108864
# 启用TCP SYN cookie保护
net.ipv4.tcp_syncookies = 1
#关闭路由转发
net.ipv4.ip_forward = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
#关闭ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
#开启反向路径过滤
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
# 启用忽略对ICMP请求和广播请求
net.ipv4.icmp_echo_ignore_all = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
# 允许记录欺骗包、源路由包和重定向包
net.ipv4.conf.all.log_martians = 1
# 禁用IP源路由
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
# 开启恶意icmp错误消息保护
net.ipv4.icmp_ignore_bogus_error_responses = 1
# 确保无人能修改路由表
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
加载
sysctl -p