1、ROS 最正确的限速- 小包优先+ 带宽均分+简单队列限制上传速度注意:本文针对 10M 带宽做出的限速说明,请根据自己的实际带宽更改相应的限速设置= START =一、小包优先的脚本如下:/ip firewall mangleadd chain=forward p2p=all-p2p action=mark-connection new-connection-mark=p2p_conn passthrough=yes comment=“ disabled=noadd chain=forward connection-mark=p2p_conn action=mark-packet new-p
2、acket-mark=p2p passthrough=yes comment=“ disabled=noadd chain=forward connection-mark=!p2p_conn action=mark-packet new-packet-mark=general passthrough=yes comment=“ disabled=noadd chain=forward packet-size=32-512 action=mark-packet new-packet-mark=small passthrough=yes comment=“ disabled=noadd chain
3、=forward packet-size=512-1200 action=mark-packet new-packet-mark=big passthrough=yes comment=“ disabled=no/ queue treeadd name=“p2pW“ parent=WAN packet-mark=p2p limit-at=400000 queue=default priority=8 max-limit=400000 burst-limit=0 burst-threshold=0 burst-time=0s disabled=noadd name=“p2pL“ parent=L
4、AN packet-mark=p2p limit-at=400000 queue=default priority=8 max-limit=400000 burst-limit=0 burst-threshold=0 burst-time=0s disabled=noadd name=“ClassA“ parent=LAN packet-mark=“ limit-at=0 queue=default priority=8 max-limit=100000000 burst-limit=0 burst-threshold=0 burst-time=0s disabled=noadd name=“
5、ClassB“ parent=ClassA packet-mark=“ limit-at=0 queue=default priority=8 max-limit=0 burst-limit=0 burst-threshold=0 burst-time=0s disabled=noadd name=“Leaf1“ parent=ClassA packet-mark=general limit-at=0 queue=default priority=7 max-limit=0 burst-limit=0 burst-threshold=0 burst-time=0s disabled=noadd
6、 name=“Leaf2“ parent=ClassB packet-mark=big limit-at=0 queue=default priority=6 max-limit=0 burst-limit=0 burst-threshold=0 burst-time=0s disabled=noadd name=“Leaf3“ parent=ClassB packet-mark=small limit-at=0 queue=default priority=5 max-limit=0 burst-limit=0 burst-threshold=0 burst-time=0s disabled
7、=no二、然后是带宽均分:这个例子示范了如何将 10Mbps 下载 2Mbps 上传,均分给网络 10.10.12.0/24 中的活动的用户# 所有来自本地网络 192.168.0.0/24 的流,标记 一个用户标记/ip firewall mangle add chain=forward src-address=192.168.10.0/24 action=mark-connection new-connection-mark=users-con/ip firewall mangle add connection-mark=users-con action=mark-packet new-p
8、acket-mark=users chain=forward# 添加两个新的 PCQ 类型。第一个命名 pcq-download,将依据目的地址聚合所有流。我们将给本地接口使用这个 queue type。它将为那些目的地址是网络 10.10.12.0/24 的下载,创建一个动态队列。第二个命名为 pcq-upload,将依据源地址聚合所有流。我们将给公网接口使用,所以它将为来自本地网络 10.10.12.0/24 到 internet 的上传,创建以一个动态队列/queue type add name=pcq-download kind=pcq pcq-classifier=dst-addre
9、ss/queue type add name=pcq-upload kind=pcq pcq-classifier=src-address# 给下载流创建一个 queue tree/ queue treeadd name=“Download“ parent=LAN packet-mark=“ limit-at=0 queue=default priority=8 max-limit=10000000 burst-limit=0 burst-threshold=0 burst-time=0sadd parent=Download packet-mark=users limit-at=0 queu
10、e=pcq-download priority=8 max-limit=0 burst-limit=0 burst-threshold=0 burst-time=0s# 给上传流创建一个 queue tree/ queue treeadd name=“Upload“ parent=WAN packet-mark=“ limit-at=0 queue=default priority=8 max-limit=2000000 burst-limit=0 burst-threshold=0 burst-time=0sadd parent=Upload packet-mark=users limit-
11、at=0 queue=pcq-upload priority=8 max-limit=0 burst-limit=0 burst-threshold=0 burst-time=0s# 注意:如果你的 ISP 不能提供一个固定的流量,你可以在上传 QUEUE 规则和下载 QUEUE规则中,直接在接口上使用 QUEUE/queue tree add parent=LAN queue=pcq-download packet-mark=users/queue tree add parent=WAN queue=pcq-upload packet-mark=users三、限制上传速度的脚本::for aaa from 2 to 254 do=/queue simple add name=(pc . $aaa) dst-address=(192.168.10. . $aaa) max-limit=800000/320000 interface=all disabled=no请根据直接实际修改 IP 地址段,下载最大速度,上传最大速度,LAN 为我连接内网的网卡,WAN 是我连接外网的网卡