ROS超智能的脚本

本脚本实现固定限速和PCQ智能限速相结合,当流量超过设定流量时,会自动切换  

   这是我个人用的脚本供大家参考,修改,希望大家顶上去,脚本如下:

:for aaa from 1 to 254 do={/queue simple add name=(PC . $aaa) dst-address=(192.168.0. . $aaa) limit-at=500000/500000 max-limit=4000000/4000000}

/ip firewall mangle
add chain=prerouting action=mark-packet new-packet-mark=all-mark
    passthrough=yes comment="" disabled=no

/ queue type
add name="PCQ-up" kind=pcq pcq-rate=1000000 pcq-limit=50
    pcq-classifier=src-address pcq-total-limit=2000
add name="PCQ-down" kind=pcq pcq-rate=1000000 pcq-limit=50
    pcq-classifier=dst-address pcq-total-limit=2000

/ queue simple
add name="PCQ" target-addresses=192.168.0.0/22 dst-address=0.0.0.0/0
    interface=all parent=none packet-marks=all-mark direction=both priority=1
    queue=PCQ-up/PCQ-down limit-at=0/0 max-limit=10000000/10000000
    total-queue=default-small disabled=yes

/ system script
add name="PCQON" source=":if ([ /queue sim get [/queue sim find
    name="PCQ"] disable ]=true ) do={/queue sim enable PCQ}"
    policy=ftp,reboot,read,write,policy,test,winbox,password
add name="PCQOFF" source=":if ([ /queue sim get [/queue sim find
    name="PCQ"] disable ]=false ) do={/queue sim disable PCQ}"
    policy=ftp,reboot,read,write,policy,test,winbox,password

/ tool traffic-monitor
add name="PCQON" interface=WAN traffic=received trigger=above
    threshold=9500000 on-event=PCQON comment="" disabled=no
add name="PCQOFF" interface=WAN traffic=received trigger=below
    threshold=4000000 on-event=PCQOFF comment="" disabled=no

-----------------------------------------------------------------------------------------------------------------------------

/system scheduler add name=timeon interval=24h start-time=06:00:00 on-event={PCQON} disabled=no
/system scheduler add name=timeoff interval=24h start-time=11:59:59 on-event={PCQOFF} disabled=no


下面对以上脚本加以说明:

10M为例 静态是4M,达到9.5M后启用动态是1M!

/ ip firewall mangle 这个是固定脚本

/ queue type
add name="PCQ-up" kind=pcq pcq-rate=1000000 pcq-limit=50
    pcq-classifier=src-address pcq-total-limit=2000
add name="PCQ-down" kind=pcq pcq-rate=1000000 pcq-limit=50
    pcq-classifier=dst-address pcq-total-limit=2000
这里把1000000改为你动态限速时的全网上传速度和下载速度!其他不要改!这里是1M!

/ queue simple
add name="PCQ" target-addresses=192.168.0.0/22 dst-address=0.0.0.0/0
    interface=all parent=none packet-marks=all-mark direction=both priority=1
    queue=PCQ-up/PCQ-down limit-at=0/0 max-limit=10000000/10000000
    total-queue=default-small disabled=yes
到这里就是建立动态限速的策略了!192.168.0.0/22 改为你IP段!max-limit=10000000/10000000 这里是你总宽带,电信给你多少就填多少!其他不用改,,因为需要转跳到上面的!

/ system script
这个是启发脚本,就是启发动态和关闭动态的脚本!

/ tool traffic-monitor
add name="PCQON" interface=WAN traffic=received trigger=above
    threshold=9500000 on-event=PCQON comment="" disabled=no
add name="PCQOFF" interface=WAN traffic=received trigger=below
    threshold=4000000 on-event=PCQOFF comment="" disabled=no
这个是流量监控,我有10M设置是9.5M启发,足够了。不会延时或者怎么的,不建议改得太少。threshold=4000000是少于4M时关闭动态!这个自己掌握好!多试试!
另外注意的是!interface=WAN 把WAN改成你外网的网卡!

/system scheduler add name=timeon interval=24h start-time=06:00:00 on-event={PCQON} disabled=no
/system scheduler add name=timeoff interval=24h start-time=11:59:59 on-event={PCQOFF} disabled=no
最后这两句是通过时间段来控制PCQ切换的,只需改最后一步就OK了!

你可能感兴趣的:(脚本,职场,ROS,休闲,智能)