

cat > /etc/sysctl.d/proxy-wdd.conf <<EOF

# 启用 BBR
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr

# 启用 IP 转发
net.ipv4.ip_forward = 1

# 调整 TCP 的时间等待状态
net.ipv4.tcp_fin_timeout = 15

# 提高 TCP 的最大连接数
net.ipv4.tcp_max_syn_backlog = 4096

# 增加 TCP 的缓冲区大小
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216

# 增加最大连接数
net.core.somaxconn = 1024
net.ipv4.tcp_max_tw_buckets = 2000

# 启用 TCP 快速打开
net.ipv4.tcp_fastopen = 3

# 减少 TCP 连接的延迟
net.ipv4.tcp_low_latency = 1

# 启用 TCP 时间戳
net.ipv4.tcp_timestamps = 1

# 启用 TCP 窗口扩大
net.ipv4.tcp_window_scaling = 1

# 设置 TCP 连接的最大重传次数
net.ipv4.tcp_retries2 = 5

# 启用 TCP 选择确认
net.ipv4.tcp_sack = 1

# 启用 SYN Cookies
net.ipv4.tcp_syncookies=1

# 调整连接追踪表大小
net.netfilter.nf_conntrack_max=131072

# 增加连接追踪哈希表大小
net.netfilter.nf_conntrack_buckets=65536

# 优化 TCP Keepalive 设置
net.ipv4.tcp_keepalive_time=600
net.ipv4.tcp_keepalive_intvl=60
net.ipv4.tcp_keepalive_probes=5

# 调整 TIME-WAIT 套接字再利用
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_tw_recycle=1

# 增加本地端口范围
net.ipv4.ip_local_port_range='1024 65535'

EOF
sudo sysctl -p /etc/sysctl.d/proxy-wdd.conf

sysctl net.ipv4.tcp_congestion_control

sudo ethtool -K enp3s0 gro on
sudo ethtool -K enp3s0 gso on
sudo ethtool -K enp3s0 tso on

