1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| # Defaults are configured in /etc/sysctl.d/* and can be customized in this file # =============================== # OpenWrt sysctl.conf (主路由优化版) # ===============================
# ------------------------------- # 默认存在的桥接相关参数(避免 bridge 转发走防火墙,提升性能) net.bridge.bridge-nf-call-arptables = 0 net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0
# ------------------------------- # 主路由优化参数
# 1. 提升连接跟踪表容量(根据内存大小可调,低内存设备可调小一些) net.netfilter.nf_conntrack_max = 262144
# 2. TCP 缓冲区与内存优化 net.core.rmem_max = 67108864 net.core.wmem_max = 67108864 net.core.netdev_max_backlog = 16384 net.ipv4.tcp_rmem = 4096 87380 67108864 net.ipv4.tcp_wmem = 4096 65536 67108864
# 3. TIME_WAIT 优化 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_fin_timeout = 10
# 4. 队列与并发优化 net.ipv4.tcp_max_syn_backlog = 8192 net.core.somaxconn = 8192
# 5. 安全/性能优化(避免额外路由计算) net.ipv4.conf.all.accept_redirects = 0 net.ipv4.conf.all.send_redirects = 0 net.ipv4.conf.default.accept_redirects = 0 net.ipv4.conf.default.send_redirects = 0
# 6. TCP Fast Open(浏览器/应用端支持才有效) net.ipv4.tcp_fastopen = 3
# 提高 conntrack hash 桶数量(避免大并发卡顿) net.netfilter.nf_conntrack_buckets = 131072
# 优化 TCP 窗口自动扩展 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_mtu_probing = 1
|