35 lines
1.1 KiB
Bash
35 lines
1.1 KiB
Bash
#!/bin/bash
|
||
|
||
kernel_config_file=/etc/sysctl.d/import_kernel.conf
|
||
|
||
cat >> ${kernel_config_file} <<EOF
|
||
# 开启bbr
|
||
net.ipv4.tcp_fastopen = 3
|
||
net.core.default_qdisc = fq
|
||
net.ipv4.tcp_congestion_control = bbr
|
||
#增加缓冲区大小可以提高吞吐量
|
||
net.core.rmem_max = 16777216
|
||
net.core.wmem_max = 16777216
|
||
#缩短超时时间可以提高响应速度。
|
||
net.ipv4.tcp_fin_timeout = 15
|
||
net.ipv4.tcp_keepalive_time = 1200
|
||
net.ipv4.tcp_keepalive_probes = 5
|
||
net.ipv4.tcp_keepalive_intvl = 15
|
||
# 避免IP碎片化可以提高性能。
|
||
net.ipv4.ipfrag_low_thresh = 65536
|
||
net.ipv4.ipfrag_high_thresh = 131072
|
||
# TCP SACK(选择确认)在路由器环境中通常不必要。
|
||
net.ipv4.tcp_sack = 0
|
||
# 快速转发可以提高转发性能。
|
||
net.ipv4.ip_forward_fast_path = 1
|
||
# 禁用日志记录可以节省资源。
|
||
net.ipv4.conf.all.log_martians = 0
|
||
net.ipv4.conf.default.log_martians = 0
|
||
net.ipv4.route.flush=1
|
||
# 缩短ARP超时时间可以提高ARP响应速度。
|
||
net.ipv4.neigh.default.gc_stale_time = 120
|
||
# 增加哈希表大小可以提高路由查找性能。
|
||
net.ipv4.neigh.default.hash_buckets = 1024
|
||
EOF
|
||
|
||
sysctl -p ${kernel_config_file} |