📦 ChatGPT 定制 RouterOS 带宽控制脚本 .rsc 完整内容如下:

# ================================
# 🚀 RouterOS 智能QoS队列控制脚本
# 功能:下载识别限权 + 网页优先 + DNS优先 + 上传保障
# 适配:pppoe-out1 接口
# 作者:ChatGPT 定制
# ================================

# ---------- 禁用 FastTrack(确保标记和队列生效) ----------
/ip firewall filter
disable [find where action=fasttrack-connection]

# ---------- Mangle 标记规则 ----------
/ip firewall mangle
remove [find where comment~"download_pkt" || comment~"dns_pkt" || comment~"upload_pkt"]

# 下载流量标记(>500KB的TCP连接)
add chain=forward protocol=tcp connection-bytes=500000-0 dst-address-type=!local \
    action=mark-packet new-packet-mark=download_pkt passthrough=no comment="download_pkt_balanced"

# DNS 查询标记(UDP 53)
add chain=forward protocol=udp dst-port=53 action=mark-packet \
    new-packet-mark=dns_pkt passthrough=no comment="dns_pkt"

# 上传流量标记(所有出站流量)
add chain=forward out-interface=pppoe-out1 action=mark-packet \
    new-packet-mark=upload_pkt passthrough=no comment="upload_pkt"

# ---------- Queue Tree 队列结构 ----------
/queue tree
remove [find where name~"Download|Upload|priority|control|dns"]

# 下载方向:pppoe-out1(带宽按实际出口带宽设置)
add name="WAN-Download" parent=pppoe-out1 max-limit=300M

# 下载识别流量 → 降权处理
add name="download-low" parent="WAN-Download" packet-mark=download_pkt \
    limit-at=1M max-limit=300M priority=8 comment="Download Queue"

# 网页、短连接等未标记流量 → 高优先级处理
add name="other-priority" parent="WAN-Download" packet-mark="" \
    limit-at=5M max-limit=300M priority=1 comment="Other High Priority"

# DNS 优先保障
add name="dns-priority" parent=pppoe-out1 packet-mark=dns_pkt \
    limit-at=512k max-limit=5M priority=1 comment="DNS Priority"

# 上传方向:挂在 pppoe-out1(不使用 global-out)
add name="WAN-Upload" parent=pppoe-out1 max-limit=50M

# 上传识别流量控制
add name="upload-control" parent="WAN-Upload" packet-mark=upload_pkt \
    limit-at=1M max-limit=50M priority=5 comment="Upload Bandwidth Control"

  • 📥 下载识别 + 降级
  • 🌐 网页未标记流量 + 提高优先
  • 📤 上传识别限速
  • 🧠 DNS 高优先保障
  • 🔥 FastTrack 正确禁用

✅ 使用说明:

  1. 将以上内容复制保存为 smart-qos.rsc
  2. 使用 WinBox / WebFig 上传 .rsc 文件
  3. 在终端执行导入:
/import file-name=smart-qos.rsc

🧠 每一项的含义:

参数解释说明
add添加一个新的队列
dst-address-type=!local排除内网、Zerotier、容器等流量
name="upload-control"队列名称,便于管理和查看
parent="WAN-Upload"挂载的父队列,表示这是上传方向的子队列(你已经创建的WAN-Upload
packet-mark=upload_pkt只处理已经被mangle 标记为 upload_pkt 的上传流量
limit-at=1M保底带宽:即使网络拥堵,该流量也至少有 1 Mbps 保证
max-limit=50M最大带宽限制,超过 50 Mbps 的流量会被限速
priority=5优先级(1最高,8最低),数字越小优先级越高,5 是中等优先级
comment="Upload Bandwidth Control"队列备注,方便在 GUI 中识别和管理

查看流量命中情况

/queue tree print stats
如果觉得我的文章对你有用,请随意赞赏