OpenWRT-BBR优化

主路由 OpwnWrt Turbo ACC 网络加速设置

路径:

1
/etc/sysctl.conf

脚本:

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

应用新参数:

1
2
sysctl -p

检查是否生效:

1
2
3
sysctl net.netfilter.nf_conntrack_max
sysctl net.ipv4.tcp_congestion_control

主路由 无Turbo ACC 网络加速设置

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
# BBR & TCP 优化参数
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr

# 连接跟踪表容量
net.netfilter.nf_conntrack_max = 262144
net.netfilter.nf_conntrack_buckets = 131072

# 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

# TIME_WAIT 优化
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 10

# 队列与并发优化
net.ipv4.tcp_max_syn_backlog = 8192
net.core.somaxconn = 8192

# 安全/性能优化
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

# TCP Fast Open
net.ipv4.tcp_fastopen = 3

# TCP 窗口扩展
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_mtu_probing = 1

# 桥接相关参数(避免性能损耗)
net.bridge.bridge-nf-call-arptables = 0
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0

AP路由

路径:

1
/etc/sysctl.conf

脚本:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Defaults are configured in /etc/sysctl.d/* and can be customized in this file

# ===============================
# OpenWrt sysctl.conf (AP 优化版)
# ===============================

# 1. TCP 连接表小一些(AP 不做 NAT,大表没必要)
net.netfilter.nf_conntrack_max = 65536

# 2. 减少 TIME_WAIT 连接(无线多客户端时有帮助)
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 10

# 3. 队列优化(应对并发 WiFi 连接)
net.core.netdev_max_backlog = 8192
net.core.somaxconn = 4096

# 4. 安全/性能优化(禁止额外的重定向)
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

检查是否生效:

1
2
3
4
5
6
7
8
9
# 查看当前 TCP 拥塞控制算法
sysctl net.ipv4.tcp_congestion_control

# 查看内核里支持哪些拥塞控制
sysctl net.ipv4.tcp_available_congestion_control

# 查看当前默认队列规则(BBR 依赖 fq)
sysctl net.core.default_qdisc