服务器配置
狗云重庆物理机CQ.E型号,详细配置如下:
- CPU:Xeon® Platinum 8259CL @ 24C48T 2.5 ~ 3.5 GHz
- 内存:64G DDR4 RECC
- 存储:960G SSD 企业级
- GPU:无
- 内网:☑️
- 带宽:联通125 Mbps| 7,500 GB(现在是1,5000 GB)
- 基础费用:¥450 /月度
系统是Debian13,内核版本是6.12.63+deb13-amd64。
BBR优化
内核配置文件在:/etc/sysctl.conf
# ============================================
# 服务器配置:Intel Xeon 8259CL @ 2.50GHz
# 内存:64GB | 带宽:125Mbps 上下行对等
# 优化日期:2026-01-30
# ============================================
# 启用BBR拥塞控制算法(适合125Mbps带宽)
net.ipv4.tcp_congestion_control = bbr
net.core.default_qdisc = fq_codel
# 网络协议栈优化
## TCP读写缓冲区大小(针对125Mbps带宽优化)
net.core.rmem_default = 524288
# 默认接收缓冲区512KB
net.core.wmem_default = 524288
# 默认发送缓冲区512KB
net.core.rmem_max = 8388608
# 最大接收缓冲区8MB(适合125Mbps)
net.core.wmem_max = 8388608
# 最大发送缓冲区8MB(适合125Mbps)
## TCP自动调优设置(最小,默认,最大)- 针对125Mbps优化
net.ipv4.tcp_rmem = 4096 524288 4194304
# 接收缓冲区:4KB 512KB 4MB
net.ipv4.tcp_wmem = 4096 524288 4194304
# 发送缓冲区:4KB 512KB 4MB
# 网络性能优化
## 网络设备数据包队列长度
net.core.netdev_max_backlog = 16384
# 适中的队列长度,适合125Mbps
net.core.netdev_budget = 600
# NAPI轮询预算
net.core.netdev_budget_usecs = 8000
# NAPI轮询时间预算
## 监听队列和连接队列
net.core.somaxconn = 32768
# 监听队列最大长度
net.ipv4.tcp_max_syn_backlog = 16384
# TCP SYN队列长度
# TCP连接优化
## 启用TCP Fast Open(加速连接建立)
net.ipv4.tcp_fastopen = 3
## 启用TCP时间戳(用于RTT计算和PAWS)
net.ipv4.tcp_timestamps = 1
## 启用TCP SACK(选择性确认)
net.ipv4.tcp_sack = 1
net.ipv4.tcp_dsack = 1
## 启用TCP窗口扩展(支持大窗口)
net.ipv4.tcp_window_scaling = 1
## 优化TCP延迟
net.ipv4.tcp_low_latency = 1
net.ipv4.tcp_notsent_lowat = 16384
net.ipv4.tcp_mtu_probing = 1
# MTU探测,避免黑洞
## TCP ECN(显式拥塞通知)
net.ipv4.tcp_ecn = 1
# 启用ECN,配合BBR效果更好
# TCP连接复用与回收
## 启用TIME-WAIT套接字重用
net.ipv4.tcp_tw_reuse = 1
## TIME-WAIT套接字的最大数量
net.ipv4.tcp_max_tw_buckets = 65535
## TCP孤儿连接最大数量
net.ipv4.tcp_max_orphans = 262144
# 防止孤儿连接占用过多资源
## TCP连接保活设置
net.ipv4.tcp_keepalive_time = 600
# 10分钟后开始发送keepalive探测
net.ipv4.tcp_keepalive_intvl = 30
# 探测间隔30秒
net.ipv4.tcp_keepalive_probes = 5
# 探测5次后断开连接
## TCP重传优化
net.ipv4.tcp_retries2 = 8
# 减少重传次数,更快释放死连接
# TCP内存优化(针对64GB内存优化)
## TCP内存自动调优(最小,压力,最大,单位:页/4KB)
net.ipv4.tcp_mem = 1572864 2097152 3145728
# 低压力:6GB | 中压力:8GB | 高压力:12GB
# 充分利用64GB内存,为TCP连接预留足够空间
# 系统资源限制
## 系统文件描述符限制
fs.file-max = 1048576
# 支持大量并发连接
# IPv4协议优化
## TCP SYN Cookies(防止SYN Flood攻击)
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_synack_retries = 2
# SYN-ACK重传2次
net.ipv4.tcp_syn_retries = 2
# SYN重传2次
## 禁用TCP慢启动重启(提升长连接性能)
net.ipv4.tcp_slow_start_after_idle = 0
## 本地端口范围(扩大可用端口)
net.ipv4.ip_local_port_range = 1024 65535
## FIN超时时间(加速连接回收)
net.ipv4.tcp_fin_timeout = 15
# 15秒后回收FIN-WAIT-2连接
## TCP窗口缩放因子
# 路由优化
## 路由缓存垃圾回收超时
net.ipv4.route.gc_timeout = 100
# 内存管理优化(针对64GB内存)
## 内存过量使用策略
vm.overcommit_memory = 1
# 允许系统分配所有物理内存
## 大页内存(如无特殊需求可设为0)
vm.nr_hugepages = 128
# 不预留大页内存,除非运行数据库等应用
## Swap使用策略
vm.swappiness = 10
# 尽量使用物理内存,减少swap使用
## 脏页管理
vm.dirty_ratio = 40
# 脏页达到40%时同步写入(64GB内存下更合理)
vm.dirty_background_ratio = 5
# 后台进程5%时开始写入
# 连接跟踪优化(如果使用iptables/firewall)
net.netfilter.nf_conntrack_max = 1048576
# 最大连接跟踪数
net.netfilter.nf_conntrack_tcp_timeout_established = 7200
# 已建立连接超时时间2小时
# Ping配置
net.ipv4.ping_group_range = 0 2147483647
# 允许所有用户组使用ping
# 禁用 IPv6(如确实不需要)
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
# 微调接收缓冲区与接收窗口的比例,从而影响 TCP 的流控与性能表现
net.ipv4.tcp_moderate_rcvbuf = 1
net.ipv4.tcp_adv_win_scale = 2
安全配置
主要是宝塔面板首页的「安全风险」这个提示太吓人了,我是按照宝塔的建议添加的,如果大家还有其他安全参数,可以在评论区分享~~
# 安全性配置
## ICMP配置
net.ipv4.icmp_echo_ignore_all=1
# 允许ping响应(便于网络诊断,如需禁用改为1)
net.ipv4.icmp_echo_ignore_all=1
# 忽略广播ICMP请求
net.ipv4.icmp_ignore_bogus_error_responses = 1
# 忽略伪造ICMP错误响应
## 禁用IPv4重定向
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
## 禁用源路由
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
## 启用反向路径过滤(防止IP欺骗)
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
## 可疑数据包日志
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.default.log_martians = 1
## 禁用IPv4转发(非路由器)
net.ipv4.ip_forward = 0
最后在终端输入:
sysctl -p
至此就可以永久生效了!你将会在终端看到如下提示:
root@localhost:~# sysctl -p
net.ipv4.tcp_congestion_control = bbr
net.core.default_qdisc = fq_codel
net.core.rmem_default = 524288
net.core.wmem_default = 524288
net.core.rmem_max = 8388608
net.core.wmem_max = 8388608
net.ipv4.tcp_rmem = 4096 524288 4194304
net.ipv4.tcp_wmem = 4096 524288 4194304
net.core.netdev_max_backlog = 16384
net.core.netdev_budget = 600
net.core.netdev_budget_usecs = 8000
net.core.somaxconn = 32768
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_dsack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_low_latency = 1
net.ipv4.tcp_notsent_lowat = 16384
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_ecn = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_max_tw_buckets = 65535
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_retries2 = 8
net.ipv4.tcp_mem = 1572864 2097152 3145728
fs.file-max = 1048576
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_fin_timeout = 15
net.ipv4.route.gc_timeout = 100
vm.overcommit_memory = 1
vm.nr_hugepages = 128
vm.swappiness = 10
vm.dirty_ratio = 40
vm.dirty_background_ratio = 5
net.netfilter.nf_conntrack_max = 1048576
net.netfilter.nf_conntrack_tcp_timeout_established = 7200
net.ipv4.ping_group_range = 0 2147483647
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv4.tcp_moderate_rcvbuf = 1
net.ipv4.tcp_adv_win_scale = 2
net.ipv4.icmp_echo_ignore_all = 1
net.ipv4.icmp_echo_ignore_all = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.default.log_martians = 1
net.ipv4.ip_forward = 0
如果参数错误,终端会输出对于不合理的提示。
© 版权声明
THE END


暂无评论内容