当前位置:首页>Linux>Linux TC(Traffic Control)完整详细指南 + 场景实战用例

Linux TC(Traffic Control)完整详细指南 + 场景实战用例

  • 2026-06-26 22:22:21
Linux TC(Traffic Control)完整详细指南 + 场景实战用例
一、TC 基础原理
1.1 核心架构(三要素:qdisc/class/filter)
TC 仅原生管控Egress(网卡出方向,发包),入方向 Ingress 需配合IFB虚拟网卡实现下行限速。
  • qdisc (排队规则,队列):网卡根队列,数据包先入 qdisc 再发送;分为有类 qdisc (HTB/Prio)、无类 qdisc (TBF/SFQ/Netem/FQ_CODEL)
  • class (分类):仅存在于有类 qdisc 下,树形分层,分配带宽、优先级(HTB 最常用分层带宽管控)
  • filter (过滤器):数据包分拣器,按源 IP / 目的 IP / 端口 / 五元组 /fw 标记把报文划入指定 class
1.2 句柄命名规则
    主号:次号,根 qdisc:1:、子 class:1:10、子 qdisc:10:;ffff:固定代表 Ingress 入队列句柄。
1.3 带宽单位换算(必记,坑点:bit≠Byte)
1Gbit=1000Mbit=10⁶Kbit
1Byte=8bit → 1Mbit/s=125KB/s
单位支持:bit/kbit/mbit/gbit、kb/mb/gb(字节)。
1.4 环境依赖
    系统预装iproute2,yum install iproute2 / apt install iproute2;Netem 内核模块默认内置。
二、TC 常用 Qdisc 分类与选型表
Qdisc 类型
适用场景
核心参数
HTB
业务带宽分层、多业务差异化限速(生产首选)
rate (保底带宽)、ceil (峰值带宽)、prio (优先级)
TBF
单接口简单限速、上行整形、轻量限流
rate、burst、latency
Netem
弱网模拟:延迟、抖动、随机丢包、乱序
delay/loss/corrupt/reorder
SFQ/FQ_CODEL
同分类下多连接公平调度,防单连接占满带宽
perturb (刷新周期)
Prio
基于优先级队列调度,语音 > 业务 > 下载
prio 分级
三、TC 基础通用命令(增删查)
3.1 qdisc 操作
# 添加根队列
tc qdisc add dev eth0 root handle 1: htb default 99
# 替换原有队列(推荐,避免重复添加报错)
tc qdisc replace dev eth0 root handle 1: htb default 99
# 查看队列(-s展示统计:发包/丢包数)
tc -s qdisc show dev eth0
# 删除全量队列
tc qdisc del dev eth0 root
# 删除ingress入队列
tc qdisc del dev eth0 ingress
3.2 class 操作(HTB)
# 创建带宽分类
tc class add dev eth0 parent 1: classid 1:10 htb rate 10mbit ceil 20mbit prio 2
# 查看分类统计
tc -s class show dev eth0
# 删除分类
tc class del dev eth0 classid 1:10
  • rate:最低保障带宽,必须配置
  • ceil:突发最大带宽(不写默认 = rate)
  • prio:优先级,数值越小优先级越高 (0 最高)
3.3 filter 过滤(u32/fw 两大主流)
3.3.1 u32:按 IP / 端口匹配报文
# 目的端口22(SSH)流量划入1:10分类
tc filter add dev eth0 parent 1: protocol ip prio 10 u32 match ip dport 22 0xffff flowid 1:10
# 源IP 192.168.1.10全流量限速
tc filter add dev eth0 parent 1: protocol ip prio 10 u32 match ip src 192.168.1.10 flowid 1:10
3.3.2 fw:配合 iptables 打标记限速(多规则首选)
# iptables给80端口打标记10
iptables -A OUTPUT -p tcp --dport 80 -j MARK --set-mark 10
# filter匹配标记10划入1:10
tc filter add dev eth0 parent 1: prio 10 handle 10 fw flowid 1:10
四、九大实战场景完整用例
场景 1:整机接口整体上行限速(HTB 全局限速)
需求:eth0 网卡总出口带宽限制 50M,峰值 60M,未匹配流量默认全量走默认分类
#!/bin/bash
DEV=eth0
tc qdisc del dev $DEV root 2>/dev/null
# 根HTB队列,default 99:未匹配流量默认进入1:99
tc qdisc add dev $DEV root handle 1: htb default 99
# 总带宽根分类
tc class add dev $DEV parent 1: classid 1:1 htb rate 50mbit ceil 60mbit
# 默认分类(不限速/可按需限制)
tc class add dev $DEV parent 1:1 classid 1:99 htb rate 50mbit ceil 60mbit
场景 2:按目的端口限速(Git/SSH/ 下载端口限流)
需求:SSH (22) 限速 1M 保底,峰值 1.5M;其余业务不限速
DEV=eth0
tc qdisc del dev $DEV root 2>/dev/null
tc qdisc add dev $DEV root handle 1: htb default 999
tc class add dev $DEV parent 1: classid 1:999 htb rate 1000mbit ceil 1000mbit # 默认全带宽
# SSH限速分类
tc class add dev $DEV parent 1: classid 1:10 htb rate 1mbit ceil 1.5mbit burst 15k
# SFQ公平队列,防止单SSH连接独占
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
# 过滤22端口进1:10
tc filter add dev $DEV parent 1: prio 5 u32 match ip dport 22 0xffff flowid 1:10
场景 3:按源 IP 限速(限制指定客户端 IP 出口带宽)
需求:192.168.1.20 出口限速 5M,其他 IP 不限速
DEV=eth0
tc qdisc del dev $DEV root 2>/dev/null
tc qdisc add dev $DEV root handle 1: htb default 99
tc class add dev $DEV parent 1: classid 1:99 htb rate 1000mbit ceil 1000mbit
tc class add dev $DEV parent 1: classid 1:10 htb rate 5mbit ceil 5mbit
tc filter add dev $DEV parent 1: prio 5 u32 match ip src 192.168.1.20 flowid 1:10
场景 4:下行 (入方向 Ingress) 限速(IFB 方案,解决 TC 不能控下载)
原理:Ingress 报文重定向至 IFB 虚拟网卡,在 IFB 的 Egress 做限速,实现下行管控
需求:eth0 入方向总下载限速 30M
#!/bin/bash
DEV=eth0
modprobe ifb 2>/dev/null
ip link add ifb0 type ifb || true
ip link set ifb0 up
# 清空原有ingress规则
tc qdisc del dev $DEV ingress 2>/dev/null
# 配置网卡入队列,所有入流量转发ifb0
tc qdisc add dev $DEV handle ffff: ingress
tc filter add dev $DEV parent ffff: protocol ip prio 1 u32 match u32 0 0 action mirred egress redirect dev ifb0
# ifb0出口限速30M(TBF简单限速)
tc qdisc add dev ifb0 root tbf rate 30mbit burst 64k latency 300ms
# 清理命令
# tc qdisc del dev ifb0 root;tc qdisc del dev $DEV ingress;ip link del ifb0
场景 5:弱网环境模拟(Netem:延迟 / 抖动 / 丢包 / 乱序,测试应用容错)
1 全局固定延迟 + 抖动
# eth0所有报文延迟100ms,±30ms随机抖动
tc qdisc replace dev eth0 root netem delay 100ms 30ms
# 带正态分布抖动(更贴近真实运营商网络)
tc qdisc replace dev eth0 root netem delay 100ms 20ms distribution normal
2 随机丢包 + 延迟组合
# 1%随机丢包 + 80ms延迟
tc qdisc replace dev eth0 root netem loss 1% delay 80ms
# 仅30%报文发生丢包(概率丢包)
tc qdisc replace dev eth0 root netem loss 3% 30%
3 报文乱序(模拟路由多路径转发)
# 20%数据包乱序,延迟50ms
tc qdisc replace dev eth0 root netem reorder 20% gap 3 delay 50ms
4 单端口弱网(只让 80 端口延迟丢包,其余流量正常)
# 根HTB
tc qdisc del dev eth0 root;tc qdisc add dev eth0 root handle 1: htb default 99
tc class add dev eth0 parent 1: classid 1:99 htb rate 1000mbit ceil 1000mbit
tc class add dev eth0 parent 1: classid 1:10 htb rate 1000mbit ceil 1000mbit
# 1:10绑定netem弱网
tc qdisc add dev eth0 parent 1:10 handle 10: netem delay 150ms loss 2%
# 80端口划入弱网分类
tc filter add dev eth0 parent 1: prio 5 u32 match ip dport 80 0xffff flowid 1:10
场景 6:多业务优先级 QoS(游戏 > 业务数据库 > 视频下载,带宽抢占优先级)
需求:总带宽 100M,游戏 (prio0,保底 30M,峰值 50M)、数据库 (prio1,保底 40M,峰值 60M)、下载 (prio2,保底 20M,峰值 30M),空闲带宽高优先级业务可抢占
游戏端口:6000~6100;数据库:3306;下载:80/443
DEV=eth0
tc qdisc del dev $DEV root 2>/dev/null
tc qdisc add dev $DEV root handle 1: htb default 99
# 总带宽
tc class add dev $DEV parent 1: classid 1:1 htb rate 100mbit ceil 100mbit
# 业务分类
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 30mbit ceil 50mbit prio 0 #游戏
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 40mbit ceil 60mbit prio 1 #数据库
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 20mbit ceil 30mbit prio 2 #下载
# 各分类挂载SFQ保证单连接公平
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
# 流量过滤
tc filter add dev $DEV parent 1: prio 5 u32 match ip dport 6000 0xfffc flowid 1:10 #6000-6100
tc filter add dev $DEV parent 1: prio 6 u32 match ip dport 3306 0xffff flowid 1:20
tc filter add dev $DEV parent 1: prio 7 u32 match ip dport 80 0xffff flowid 1:30
tc filter add dev $DEV parent 1: prio 7 u32 match ip dport 443 0xffff flowid 1:30
场景 7:Docker 容器独立限速(按容器 IP 限制单个容器出口带宽)
容器 IP:172.17.0.10,限速 10M
DEV=docker0
tc qdisc del dev $DEV root 2>/dev/null
tc qdisc add dev $DEV root handle 1: htb default 99
tc class add dev $DEV parent 1: classid 1:99 htb rate 1000mbit ceil 1000mbit
tc class add dev $DEV parent 1: classid 1:10 htb rate 10mbit ceil 10mbit
tc filter add dev $DEV parent 1: prio 5 u32 match ip src 172.17.0.10 flowid 1:10
场景 8:网桥 / OpenWrt 路由器 QoS(按客户端 MAC 地址限速,家庭宽带)
配合ebtables二层 MAC 打标,br-lan 网桥下不同设备差异化限速
需求:电视 MAC (XX:XX:XX:XX:XX:01) 下行 20M,手机 MAC (XX:XX:XX:XX:XX:02) 下行 10M
# 1.ebtables二层打标记
ebtables -t filter -F OUTPUT
ebtables -A OUTPUT -d XX:XX:XX:XX:XX:01 -j mark --mark-set 10
ebtables -A OUTPUT -d XX:XX:XX:XX:XX:02 -j mark --mark-set 20
# 2.tc按fw标记限速
DEV=br-lan
tc qdisc del dev $DEV root 2>/dev/null
tc qdisc add dev $DEV root handle 1: htb default 99
tc class add dev $DEV parent 1: classid 1:99 htb rate 100mbit ceil 100mbit
tc class add dev $DEV parent 1: classid 1:10 htb rate 20mbit ceil 20mbit
tc class add dev $DEV parent 1: classid 1:20 htb rate 10mbit ceil 10mbit
tc filter add dev $DEV parent 1: prio 5 handle 10 fw flowid 1:10
tc filter add dev $DEV parent 1: prio 5 handle 20 fw flowid 1:20
场景 9:TBF 极简单链路限速(无需分层,适合临时快速限流)
# eth0出口限速20M,burst缓冲区64k
tc qdisc replace dev eth0 root tbf rate 20mbit burst 64k latency 200ms
# 取消限速
tc qdisc del dev eth0 root tbf
五、FQ_CODEL 替代 SFQ 现代低时延 QoS(解决 Bufferbloat,生产首选)
SFQ 老旧,FQ_CODEL 是 Linux 官方推荐宽带 Qdisc,自适应缓存、抗队列膨胀、短视频 / VoIP 低延迟
5.1 HTB+FQ_CODEL 嵌套(标准生产架构)
DEV=eth0
tc qdisc del dev $DEV root 2>/dev/null
tc qdisc add dev $DEV root handle 1: htb default 99
# 总带宽100M
tc class add dev $DEV parent 1: classid 1:1 htb rate 100mbit ceil 100mbit
# 默认流量分类
tc class add dev $DEV parent 1:1 classid 1:99 htb rate 90mbit ceil 100mbit
# FQ_CODEL挂载在分类下,替代sfq
# codel_target:目标缓冲时延,默认5ms;codel_quantum:分片大小
tc qdisc add dev $DEV parent 1:99 handle 99: fq_codel target 5ms quantum 1514 noecn
参数释义:
  • target 5ms:队列缓存超过 5ms 延迟开始主动丢包防胀缓存
  • ecn:开启显式拥塞通知(TCP 友好,不直接丢包),noecn关闭 ECN
适用:家用软路由、企业出口网关、公网服务器网卡。
5.2 全局 FQ_CODEL 无分层简易限速
tc qdisc replace dev eth0 root fq_codel limit 1024 target 4ms ecn
六、DSCP + TC 基于 IP TOS/DSCP 标记 QoS(政企专线 / 运营商高级 QoS)
原理:前端 iptables/nft 根据业务打 DSCP 值,TC 读取 DSCP 字段做带宽分级,跨网段路由保留优先级
DSCP 常用值:
DSCP
用途
cs7(56)
网管、BGP、核心路由(最高优先级)
ef(46)
VoIP 语音、实时音视频
af41(34)
关键业务 TCP 数据库
default(0)
普通网页下载
实操:匹配 DSCP 做带宽优先级
DEV=eth0
tc qdisc del dev $DEV root
tc qdisc add dev $DEV root handle 1: htb default 99
tc class add dev $DEV parent 1: classid 1:1 htb rate 200mbit ceil 200mbit
# EF(46)语音流量:保底50M,优先级0最高
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 50mbit ceil 120mbit prio 0
tc qdisc add dev $DEV parent 1:10 handle 10: fq_codel target 3ms ecn
# AF41业务:保底60M prio1
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 60mbit ceil 150mbit prio 1
tc qdisc add dev $DEV parent 1:20 handle 20: fq_codel
# 默认流量
tc class add dev $DEV parent 1:1 classid 1:99 htb rate 80mbit ceil 200mbit prio 2
tc qdisc add dev $DEV parent 1:99 handle 99: fq_codel
# filter匹配DSCP
tc filter add dev $DEV parent 1: prio 1 protocol ip u32 match ip dsfield 0xb8 0xff flowid 1:10 # EF=46=0x2E<<2=0xb8
tc filter add dev $DEV parent 1: prio 2 protocol ip u32 match ip dsfield 0x88 0xff flowid 1:20 # AF41=34=0x22<<2=0x88
配合 iptables 打 DSCP 标签示例
# 源10.0.1.0/24语音服务器出站打EF
iptables -t mangle -A POSTROUTING -s 10.0.1.0/24 -j DSCP --set-dscp 46
# 数据库3306端口打AF41
iptables -t mangle -A POSTROUTING -p tcp --dport 3306 -j DSCP --set-dscp 34
七、IFB 高级进阶:多 IFB 拆分上下行、VLAN 接口下行限速、多网卡共用 IFB
高级:多 VLAN / 多 LAN 口分别下行限速、多 IFB 隔离不同网段
7.1 双 IFB 分别管控 eth0、eth1 入方向
modprobe ifb numifbs=2
ip link set ifb0 up
ip link set ifb1 up
# eth0 ingress重定向ifb0
tc qdisc add dev eth0 handle ffff: ingress
tc filter add dev eth0 parent ffff: u32 match u32 0 0 action mirred egress redirect dev ifb0
# eth1 ingress重定向ifb1
tc qdisc add dev eth1 handle ffff: ingress
tc filter add dev eth1 parent ffff: u32 match u32 0 0 action mirred egress redirect dev ifb1
# ifb0下行总限速50M
tc qdisc add dev ifb0 root htb default 99
tc class add dev ifb0 parent 1: classid 1:1 htb rate 50mbit ceil 50mbit
# ifb1下行总限速30M
tc qdisc add dev ifb1 root tbf rate 30mbit burst 128k latency 200ms
7.2 VLAN 子接口下行限速(eth0.100 VLAN100)
modprobe ifb
ip link set ifb0 up
tc qdisc add dev eth0.100 handle ffff: ingress
tc filter add dev eth0.100 parent ffff: u32 match u32 0 0 action mirred redirect dev ifb0
# VLAN100下载限速20M
tc qdisc add dev ifb0 root tbf rate 20mbit burst 64k latency 150ms
八、Netem 复合高级用法(分层弱网、部分 IP / 端口单独劣化、随机波动带宽)
Netem 不建议直接绑 root,推荐 HTB 分类挂载 Netem 实现精细化弱网
8.1 仅特定源 IP 加延迟丢包,其余流量正常
DEV=eth0
tc qdisc del dev $DEV root
tc qdisc add dev $DEV root handle 1: htb default 99
tc class add dev $DEV parent 1: classid 1:99 htb rate 1000mbit ceil 1000mbit
# 劣化分类
tc class add dev $DEV parent 1: classid 1:10 htb rate 1000mbit ceil 1000mbit
# netem:延迟200ms±50ms、随机2%丢包、0.5%报文损坏
tc qdisc add dev $DEV parent 1:10 handle 10: netem delay 200ms 50ms loss 2% corrupt 0.5%
# 192.168.5.0/24进入劣化通道
tc filter add dev $DEV parent 1: u32 match ip src 192.168.5.0/24 flowid 1:10
8.2 周期性带宽波动(模拟运营商带宽抖动,配合 netem+HTB 动态修改带宽)
脚本动态修改 ceil 实现带宽上下波动:
# 基础规则
tc qdisc add dev eth0 root handle 1:htb default 99
tc class add dev eth0 parent 1: classid 1:1 htb rate 50mbit ceil 80mbit
# 波动脚本示例(5秒在30M~80M来回切换峰值)
while true;do
tc class change dev eth0 classid 1:1 htb rate 50mbit ceil 30mbit
sleep 5
tc class change dev eth0 classid 1:1 htb rate 50mbit ceil 80mbit
sleep 5
done
8.3 报文重复 (duplicate) 模拟线路串扰
# 5%数据包重复发送
tc qdisc replace dev eth0 root netem duplicate 5%
九、二层网桥 / OVS 高级限速:基于 MAC、VLAN ID 限速(ebtables+tc+fwmark)
适用 OpenWrt、Linux 网桥网关、OVS 虚拟交换机,二层不依赖 IP 即可限速
DEV=br0
# 清空旧规则
tc qdisc del dev $DEV root 2>/dev/null
ebtables -F OUTPUT
# MAC1:AA:BB:CC:DD:EE → mark10;MAC2:AA:BB:CC:DD:FF→mark20
ebtables -A OUTPUT -d AA:BB:CC:DD:EE -j mark --mark-set 10
ebtables -A OUTPUT -d AA:BB:CC:DD:FF -j mark --mark-set 20
# TC配置
tc qdisc add dev $DEV root handle 1: htb default 99
tc class add dev $DEV parent 1: classid 1:99 htb rate 500mbit ceil 500mbit
tc class add dev $DEV parent 1: classid 1:10 htb rate 15mbit ceil 15mbit
tc class add dev $DEV parent 1: classid 1:20 htb rate 8mbit ceil 8mbit
tc filter add dev $DEV parent 1: handle 10 fw flowid 1:10
tc filter add dev $DEV parent 1: handle 20 fw flowid 1:20
十、tc + nftables 新一代标记方案(替代老旧 iptables MARK,现代 Linux5.x+)
iptables 逐步淘汰,nftables 打 mark 更简洁
# nft设置mark
nft add table ip tc_mark
nft add chain ip tc_mark out {type filter hook postrouting priority mangle;}
# 源10.2.0.0/24标记30
nft add rule ip tc_mark out ip saddr 10.2.0.0/24 meta mark set 30
# TC匹配mark30限速
tc qdisc add dev eth0 root handle 1:htb default99
tc class add dev eth0 parent1: classid1:30 htb rate 20mbit ceil30mbit
tc filter add dev eth0 parent1: handle30 fw flowid1:30
十一、嵌套多层 HTB(三级树形带宽:总带宽→分组→单个 IP,企业多租户限速)
架构:
1 级:总出口 1G → 2 级:租户 A 组 (400M)、租户 B 组 (400M) →3 级:组内各 IP 单独限速
DEV=eth0
tc qdisc del dev $DEV root
tc qdisc add dev $DEV root handle 1: htb default 99
# 一级总带宽
tc class add dev $DEV parent 1: classid 1:1 htb rate 1000mbit ceil 1000mbit
# 二级分组
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 400mbit ceil 500mbit #租户A组
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 400mbit ceil 500mbit #租户B组
# 三级:A组内两个IP分别限速
tc class add dev $DEV parent 1:10 classid 1:101 htb rate 50mbit ceil 80mbit
tc class add dev $DEV parent 1:10 classid 1:102 htb rate 60mbit ceil 90mbit
# 挂载fq_codel
tc qdisc add dev $DEV parent 1:101 handle 101: fq_codel
tc qdisc add dev $DEV parent 1:102 handle 102: fq_codel
# 匹配IP
tc filter add dev $DEV parent1: u32 match ip src 192.168.10.10 flowid1:101
tc filter add dev $DEV parent1: u32 match ip src 192.168.10.11 flowid1:102
十二、action 重定向高级:tc filter mirred 端口镜像(流量镜像抓包,无需交换机镜像口)
tc 原生实现端口镜像,把 eth0 全部流量镜像到 eth1 做 wireshark 抓包
# ingress入流量镜像
tc qdisc add dev eth0 handle ffff: ingress
tc filter add dev eth0 parent ffff: u32 match u32 0 0 action mirred egress mirror dev eth1
# egress出流量镜像
tc filter add dev eth0 parent 1: u32 match u32 0 0 action mirred egress mirror dev eth1
十三、TC 统计监控高级:定时抓取 class/qdisc 丢包、overlimit 告警
13.1 提取超限丢包数值脚本
#!/bin/bash
DEV=eth0
tc -s class show dev $DEV |awk '/overlimit/ {print $NF,$0}'
字段说明:
  • overlimit:超出 ceil 上限被丢弃报文数
  • dropped:队列满溢出丢包
13.2 实时带宽速率计算(配合 sar/ifstat)
# 查看分类收发字节
tc -s class show dev eth0 | grep 'bytes'
十四、特殊场景:loopback 本地回环限速(测试本机进程间通信限流)
# 限制lo网卡本地程序互访带宽
tc qdisc replace dev lo root tbf rate 10mbit burst 32k latency 100ms
十五、TC + XDP 内核旁路高性能限速(Linux 5.8+)
核心优势
  • 比传统 TC 快 5~10 倍,10G/25G 网卡线速处理
  • CPU 占用极低(XDP 网卡驱动层直接处理)
  • XDP 做分类 / 限流 + TC 做带宽整形,完美结合
  • 支持:端口、IP、五元组、MAC、DSCP 匹配
环境要求
  • Linux Kernel >= 5.8
  • iproute2 >= 5.8
  • 驱动支持 XDP:ixgbe/i40e/mlx5/virtio_net
1 基础 XDP 直接丢包 / 限速(最简单)
# 加载 XDP 到网卡(高速模式)
ip link set dev eth0 xdp off
ip link set dev eth0 xdp obj /usr/lib/bpf/xdp_drop.o
# 查看 XDP 状态
ip link show dev eth0
2 XDP + TC 完整高性能带宽管控(生产推荐)
DEV=eth0
# 1. 卸载旧规则
tc qdisc del dev $DEV root 2>/dev/null
ip link set dev $DEV xdp off
# 2. 加载 XDP 程序(分类+打标记)
ip link set dev $DEV xdp obj /etc/xdp/xdp_mark.o sec classifier
# 3. TC HTB 带宽队列
tc qdisc add dev $DEV root handle 1: htb default 99
tc class add dev $DEV parent 1: classid 1:1 htb rate 1000mbit ceil 1000mbit
# 4. 高优业务(VoIP/SSH)100M
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 100mbit ceil 300mbit prio 0
tc qdisc add dev $DEV parent 1:10 fq_codel
# 5. 普通业务 500M
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 500mbit ceil 800mbit prio 2
tc qdisc add dev $DEV parent 1:20 fq_codel
# 6. XDP 打过 mark 的包直接匹配(比 u32 快 10 倍)
tc filter add dev $DEV parent 1: prio 1 handle 10 fw flowid 1:10
tc filter add dev $DEV parent 1: prio 2 handle 20 fw flowid 1:20
3. 卸载 XDP
ip link set dev eth0 xdp off
tc qdisc del dev eth0 root
十六、多出口策略路由 + TC 独立限速(双宽带 / 三宽带)
场景
  • 电信 100M + 联通 100M 双线
  • 每条线路独立带宽控制、互不干扰
  • 按 IP / 端口 / 用户选路 + 独立限速
接口说明
  • eth1 :电信 100M
  • eth2 :联通 100M
1. 开启策略路由
echo "100 telecom" >> /etc/iproute2/rt_tables
echo "101 unicom" >> /etc/iproute2/rt_tables
2. 双线路独立路由
# 电信路由表
ip route add default via 电信网关 dev eth1 table telecom
ip rule add from 192.168.1.0/24 table telecom
# 联通路由表
ip route add default via 联通网关 dev eth2 table unicom
ip rule add from 192.168.2.0/24 table unicom
3. 双线路 TC 独立限速(互不影响)
① 电信线路限速 100M
DEV=eth1
tc qdisc del dev $DEV root
tc qdisc add dev $DEV root handle 1: htb default 99
tc class add dev $DEV parent 1: classid 1:1 htb rate 100mbit ceil 100mbit
tc class add dev $DEV parent 1:1 classid 1:99 htb rate 100mbit ceil 100mbit
tc qdisc add dev $DEV parent 1:99 fq_codel
② 联通线路限速 100M
DEV=eth2
tc qdisc del dev $DEV root
tc qdisc add dev $DEV root handle 2: htb default 99
tc class add dev $DEV parent 2: classid 2:1 htb rate 100mbit ceil 100mbit
tc class add dev $DEV parent 2:1 classid 2:99 htb rate 100mbit ceil 100mbit
tc qdisc add dev $DEV parent 2:99 fq_codel
4. 按业务分流 + 独立限速
SSH / 游戏 → 电信高优
下载 / HTTP → 联通普通
# 电信高优
tc class add dev eth1 parent 1:1 classid 1:10 htb rate 30mbit ceil 100mbit prio 0
tc filter add dev eth1 parent 1: prio 1 u32 match ip dport 22 0xffff flowid 1:10
十七、Kubernetes CNI 容器集群批量 Pod 限速(最实用)
支持所有 CNI
  • Calico
  • Flannel
  • Canal
  • Weave
原理
  • Pod 网卡 = veth 虚拟网卡
  • 直接在 veth 接口 上用 TC 限速
  • 支持:批量、一键、按命名空间、按标签
1. 单 Pod 限速(10M 上行 + 下行)
# 找到 Pod 对应的 veth 接口
POD_IP=10.244.1.23
VETH=$(ip route get $POD_IP | awk '/dev/{print $3}')
# 上行限速(出口)
tc qdisc add dev $VETH root handle 1: htb
tc class add dev $VETH parent 1: classid 1:1 htb rate 10mbit ceil 10mbit
tc filter add dev $VETH parent 1: prio 1 u32 match u32 0 0 flowid 1:1
# 下行限速(入口,IFB)
modprobe ifb
ip link add ifb0 type ifb
ip link set ifb0 up
tc qdisc add dev $VETH ingress
tc filter add dev $VETH parent ffff: u32 match u32 0 0 action mirred egress redirect dev ifb0
tc qdisc add dev ifb0 root tbf rate 10mbit burst 64k latency 100ms
2. 批量 Pod 限速脚本(生产神器)
批量限速命名空间 default 下所有 Pod 为 20M
#!/bin/bash
NS=default
RATE=20mbit
# 获取所有 Pod veth
for pod in $(kubectl get pods -n $NS -o jsonpath='{.items[*].status.podIP}'); do
VETH=$(ip route get $pod | awk '/dev/{print $3}')
echo "限速 $pod ($VETH) $RATE"
# 上行
tc qdisc del dev $VETH root 2>/dev/null
tc qdisc add dev $VETH root handle 1: htb
tc class add dev $VETH parent 1: classid 1:1 htb rate $RATE ceil $RATE
tc filter add dev $VETH parent 1: prio 1 u32 match u32 0 0 flowid 1:1
done
3. 一键清空所有 Pod TC 规则
#!/bin/bash
for veth in $(ip link | grep veth | awk '{print $2}' | tr -d :); do
tc qdisc del dev $veth root 2>/dev/null
tc qdisc del dev $veth ingress 2>/dev/null
done
十八、TC 运维排查 & 调优
18.1 查看队列统计(丢包 / 超限排查)
tc -s qdisc show dev eth0
tc -s class show dev eth0
# overlimit超限=流量超过ceil上限被丢弃
18.2 规则一键清空脚本
#!/bin/bash
dev=(eth0 ifb0 docker0 br-lan)
for i in ${dev[@]};do
tc qdisc del dev $i root 2>/dev/null
tc qdisc del dev $i ingress 2>/dev/null
done
18.3 开机自启持久化
  • CentOS:写入/etc/rc.local
  • Ubuntu:systemd service 挂载 tc 脚本
18.4 生产调优建议
  • 业务 HTB 分类下层一律挂载 SFQ/FQ_CODEL,防止单流霸占队列
  • 互联网业务优先 FQ_CODEL(低延迟,解决 Bufferbloat 缓冲膨胀)
  • Netem 测试完成务必删除队列,避免长期弱网影响业务
十九、补充:tc+iptables 高级组合(五元组精细化管控)
# iptables匹配源10.0.0.0/24所有流量打标记5
iptables -A OUTPUT -s 10.0.0.0/24 -j MARK --set-mark 5
# tc匹配标记5限速8M
tc qdisc add dev eth0 root handle 1: htb default 99
tc class add dev eth0 parent 1: classid 1:5 htb rate 8mbit ceil 10mbit
tc filter add dev eth0 parent 1: prio 5 handle 5 fw flowid 1:5
二十、TC 持久化高级方案(systemd 托管 tc 服务)
新建 `/etc/systemd/system/tc-qos.service`
[Unit]
Description=TC QoS Limit Service
After=network.target
[Service]
Type=oneshot
ExecStart=/etc/tc/start.sh
ExecStop=/etc/tc/stop.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
# 启用开机自启
systemctl daemon-reload
systemctl enable tc-qos
systemctl start tc-qos
二十一、补充冷门高级 qdisc:CHOKE、RED 主动队列管理(路由器拥塞控制)
RED:随机早期探测,TCP 拥塞控制,多用于骨干链路
tc qdisc add dev eth0 root red limit 100k min 30k max 80k avpkt 1500 bandwidth 100mbit

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-03 04:00:24 HTTP/2.0 GET : https://f.mffb.com.cn/a/497610.html
  2. 运行时间 : 0.207196s [ 吞吐率:4.83req/s ] 内存消耗:4,578.78kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=02cccaaf8b93aa0df77c7d86012a358f
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000373s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000601s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.016878s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000319s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000625s ]
  6. SELECT * FROM `set` [ RunTime:0.000208s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000552s ]
  8. SELECT * FROM `article` WHERE `id` = 497610 LIMIT 1 [ RunTime:0.008206s ]
  9. UPDATE `article` SET `lasttime` = 1783022424 WHERE `id` = 497610 [ RunTime:0.012283s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 67 LIMIT 1 [ RunTime:0.003173s ]
  11. SELECT * FROM `article` WHERE `id` < 497610 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.004460s ]
  12. SELECT * FROM `article` WHERE `id` > 497610 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000507s ]
  13. SELECT * FROM `article` WHERE `id` < 497610 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.025440s ]
  14. SELECT * FROM `article` WHERE `id` < 497610 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.048902s ]
  15. SELECT * FROM `article` WHERE `id` < 497610 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.008228s ]
0.209752s