1.ROS网络管理功能十分强大,如需简单对IP或网段进行限速可使用简单队列限速。
queue simple add target-addresses=192.168.0.0/24 limit-at=500000/1000000 max-limit=1000000/2000000 \
burst-threshold=1000000/1000000 burst-limit=1000000/3000000 burst-time=8/8
#limit-at 限制在此速率
#max-limit 空闲时可用最大速率,未设置等于limit-at
#burst-threshold 速率阀值
#burst-limit 单位时间内速率低于阀值,可突破至此速率
#burst time 突破速率的时间间隔
2.使用简单限速用户较少时会造成带宽的浪费,为此可使用PCQ动态限速。
queue type add name=down-pcq kind=pcq pcq-rate=0 pcq-limit=50 pcq-total-limit=2000 pcq-classifier=dst-address
#PCQ下载队列,针对内部目标IP
#默认情况下仅能容纳50个用户,即2000/50,用户较多时可调整pcq-total-limit或pcq-limit数值
queue type add name=up-pcq kind=pcq pcq-rate=0 pcq-limit=50 pcq-total-limit=2000 pcq-classifier=src-address
#PCQ上传队列,针对内部源IP
queue simple add name=pcq-queue target-addresses=192.168.1.0/24 max-limit=500000/1000000 queue=up-pcq/down-pcq
#新建简单队列应用PCQ规则
3.基于等级优先级HTB设置,可针对IP、协议进行限制。
ip firewall mangle add chain=forward action=mark-connection new-connection-mark=1.2 src-address=192.168.1.2 passthrough=yes
ip firewall mangle add chain=forward action=mark-connection new-connection-mark=1.3 src-address=192.168.1.3 passthrough=yes
#标记特定的连接
ip firewall mangle add chain=forward action=mark-packet new-packet-mark=1.2 connection-mark=1.3 passthrough=no
ip firewall mangle add chain=forward action=mark-packet new-packet-mark=1.3 connection-mark=1.3 passthrough=no
#标记特定连接的所有数据包
建立父队列:
queue tree add name=totaldown parent=ether2 limit-at=2000000 max-limit=2000000
queue tree add name=totalup parent=ether1 limit-at=500000 max-limit=500000
#标记数据LAN为下载,WAN为上传
#Global-in识别Prerouting标记的数据
#Global-out/total能识别pre,forward,post标记的数据
建立子队列:
queue tree add name=pc1.2down parent=totaldown limit-at=2000000 max-limit=2000000 priority=2
queue tree add name=pc1.2up parent=totalup limit-at=500000 max-limit=5555500000 priority=2
queue tree add name=pc1.3down parent=totaldown limit-at=1000000 max-limit=1000000 priority=3
queue tree add name=pc1.3up parent=totalup limit-at=500000 max-limit=500000 priority=3