Files
shell-scripts/1-代理Xray/99-网络质量分析/30M带宽服务器-网络内核优化.conf
2025-12-08 08:56:23 +08:00

55 lines
2.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ==========================================================
# 核心拥塞控制与队列管理 (解决丢包与延迟)
# ==========================================================
# 使用 FQ (Fair Queueing) 队列调度算法这是BBR的必要配合
net.core.default_qdisc = fq
# 开启 BBR 拥塞控制算法
net.ipv4.tcp_congestion_control = bbr
# ==========================================================
# TCP 缓冲区调优 (针对 30-50Mbps 带宽优化)
# ==========================================================
# 格式: min default max
# 核心策略:限制 max 值,防止 Bufferbloat。
# 2MB (2097152) 的缓冲区足以应对 50Mbps 下 300ms 的抖动,再大就会导致高延迟。
# 接收缓冲区
net.ipv4.tcp_rmem = 4096 87380 2097152
# 发送缓冲区
net.ipv4.tcp_wmem = 4096 65536 2097152
# 开启窗口缩放,允许窗口超过 64KB
net.ipv4.tcp_window_scaling = 1
# ==========================================================
# 连接追踪与并发优化 (Xray 高并发转发需求)
# ==========================================================
# 增加系统级文件描述符限制
fs.file-max = 1048576
# 增加入站连接队列长度,防止突发流量导致握手失败
net.core.somaxconn = 4096
net.core.netdev_max_backlog = 4096
# TCP Fast Open (TFO):减少握手延迟
# 值 3 表示同时开启客户端和服务端的 TFO 支持
# Xray 需要在配置中显式开启 "tcpFastOpen": true 才能生效
net.ipv4.tcp_fastopen = 3
# ==========================================================
# 抗丢包与快速恢复
# ==========================================================
# 开启 SACK (选择性确认),对丢包环境极其重要
net.ipv4.tcp_sack = 1
net.ipv4.tcp_dsack = 1
net.ipv4.tcp_fack = 1
# 缩短保活探测时间快速剔除死连接GFW常导致连接“假死”
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 15
# ==========================================================
# 转发功能开启 (主机A必须)
# ==========================================================
net.ipv4.ip_forward = 1