Cript Qos Dinamico
Cript Qos Dinamico
##############
En esta parte debes cambiar tu rango de ip
###################################################################################
##################
/queue type
add kind=pcq name=down pcq-classifier=dst-address pcq-dst-address6-mask=64 pcq-src-
address6-mask=64
###################################################################################
###
###################################################################################
####
###################################################################################
###
/system script
add dont-require-permissions=yes name="pppoe down" owner=admin_roberto \
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
source="/queue tree remove [find where parent=\"QoS_<pppoe-\$user>\"]\r\
\n/queue tree remove [find where name=\"QoS_<pppoe-\$user>\"]\r\
\n:foreach a in=[/queue tree find where invalid] do={ /queue tree remove \
\$a };"
add dont-require-permissions=yes name="pppoe up" owner=admin_roberto policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=":\
foreach i in=[/queue simple find where name=\"<pppoe-\$user>\"] do={\r\
\n :local NamePPP [/queue simple get \$i name];\r\
\n :local RateLimit [/queue simple get \$i max-limit];\r\
\n :local indexExplod [:find \$RateLimit \"/\"];\r\
\n :local lenth [:len \$RateLimit];\r\
\n :local rl [:pick \$RateLimit (\$indexExplod + 1) (\$lenth - 1)];\r\
\n :local RateLimitUn [:pick \$RateLimit (\$lenth - 1) \$lenth];\r\
\n :local BurstLimit [/queue simple get \$i burst-limit];\r\
\n :local indexExplod [:find \$BurstLimit \"/\"];\r\
\n :local lenth [:len \$BurstLimit];\r\
\n :local bl [:pick \$BurstLimit (\$indexExplod + 1) (\$lenth - 1)];\r\
\n :local BurstLimitUn [:pick \$BurstLimit (\$lenth - 1) \$lenth];\r\
\n :local BurstTime [/queue simple get \$i burst-time];\r\
\n :local indexExplod [:find \$BurstTime \"/\"];\r\
\n :local lenth [:len \$BurstTime];\r\
\n :local bt [:pick \$BurstTime (\$indexExplod + 1) (\$lenth - 1)];\r\
\n :local indexExplod [:find \$bt \"m\"];\r\
\n :local lenth [:len \$bt];\r\
\n :local bt0 [:pick \$bt 0];\r\
\n :local bt1 [:pick \$bt (\$indexExplod + 1) \$lenth];\r\
\n :local BurstTh [/queue simple get \$i burst-threshold];\r\
\n :local indexExplod [:find \$BurstTh \"/\"];\r\
\n :local lenth [:len \$BurstTh];\r\
\n :local bth [:pick \$BurstTh (\$indexExplod + 1) (\$lenth - 1)];\r\
\n :local BurstThUn [:pick \$BurstTh (\$lenth - 1) \$lenth];\r\
\n :local cicmp [(\$rl * 23 / 100)];\r\
\n :local credes [(\$rl * 23 / 100)];\r\
\n :local cwww [(\$rl * 23 / 100)];\r\
\n :local cvideos [(\$rl * 23 / 100)];\r\
\n :local cresto [(\$rl * 8 / 100)];\r\
\n :local cBt [((\$bt0 * 60) + \$bt1)];\r\
\n :if ([:len \$bl] != 0) do={\r\
\n :log warning \"QoS ADD === \$NamePPP\";\r\
\n# :log warning \"Com Burst\";\r\
\n# :log warning \"Max Limit === \$rl \$RateLimitUn\";\r\
\n# :log warning \"Burst Limit === \$bl \$BurstLimitUn\";\r\
\n# :log warning \"Burst Thr === \$bth \$BurstThUn\";\r\
\n# :log warning \"Burst Time=== \$cBt\";\r\
\n/queue tree add name=\"QoS_\$NamePPP\" parent=\"\$interface\" queue=\"do\
wn\" max-limit=\"\$(\$rl)\$RateLimitUn\" burst-limit=\"\$(\$bl)\$BurstLimi\
tUn\" burst-time=\"\$cBt\" burst-threshold=\"\$(\$bth)\$BurstThUn\" bucket\
-size=0.20;\r\
\n /queue tree add name=\"1-icmp_\$NamePPP\" parent=\"QoS_\$NamePPP\
\" packet-mark=\"PRIO.1\" queue=\"down\" priority=\"1\" limit-at=\"\$(\$ci\
cmp)\$RateLimitUn\" max-limit=\"\$(\$rl)\$RateLimitUn\" burst-limit=\"\$(\
\$bl)\$BurstLimitUn\" burst-time=\"\$cBt\" burst-threshold=\"\$(\$bth)\$Bu\
rstThUn\";\r\
\n /queue tree add name=\"2-redes_\$NamePPP\" parent=\"QoS_\$NamePP\
P\" packet-mark=\"PRIO.2\" queue=\"down\" priority=\"2\" limit-at=\"\$(\$c\
redes)\$RateLimitUn\" max-limit=\"\$(\$rl)\$RateLimitUn\";\r\
\n /queue tree add name=\"3-www_\$NamePPP\" parent=\"QoS_\$NamePPP\
\" packet-mark=\"PRIO.3\" queue=\"down\" priority=\"3\" limit-at=\"\$(\$cw\
ww)\$RateLimitUn\" max-limit=\"\$(\$rl)\$RateLimitUn\";\r\
\n /queue tree add name=\"4-videos_\$NamePPP\" parent=\"QoS_\$NameP\
PP\" packet-mark=\"PRIO.4\" queue=\"down\" priority=\"5\" limit-at=\"\$(\$\
cvideos)\$RateLimitUn\" max-limit=\"\$(\$rl)\$RateLimitUn\";\r\
\n /queue tree add name=\"8-resto_\$NamePPP\" parent=\"QoS_\$NamePP\
P\" packet-mark=\"PRIO.8\" queue=\"down\" priority=\"8\" limit-at=\"\$(\$c\
resto)\$RateLimitUn\" max-limit=\"\$(\$rl)\$RateLimitUn\";\r\
\n } \\\r\
\n else={\r\
\n :log warning \"QoS ADD === \$NamePPP\";\r\
\n /queue tree add name=\"QoS_\$NamePPP\" parent=\"\$interface\" qu\
eue=\"down\" max-limit=\"\$(\$rl)\$RateLimitUn\" bucket-size=0.20;\r\
\n /queue tree add name=\"1-icmp_\$NamePPP\" parent=\"QoS_\$NamePPP\
\" packet-mark=\"PRIO.1\" queue=\"down\" priority=\"1\" limit-at=\"\$(\$ci\
cmp)\$RateLimitUn\" max-limit=\"\$(\$rl)\$RateLimitUn\";\r\
\n /queue tree add name=\"2-redes_\$NamePPP\" parent=\"QoS_\$NamePP\
P\" packet-mark=\"PRIO.2\" queue=\"down\" priority=\"2\" limit-at=\"\$(\$c\
redes)\$RateLimitUn\" max-limit=\"\$(\$rl)\$RateLimitUn\";\r\
\n /queue tree add name=\"3-www_\$NamePPP\" parent=\"QoS_\$NamePPP\
\" packet-mark=\"PRIO.3\" queue=\"down\" priority=\"3\" limit-at=\"\$(\$cw\
ww)\$RateLimitUn\" max-limit=\"\$(\$rl)\$RateLimitUn\";\r\
\n /queue tree add name=\"4-videos_\$NamePPP\" parent=\"QoS_\$NameP\
PP\" packet-mark=\"PRIO.4\" queue=\"down\" priority=\"5\" limit-at=\
\"\$(\$cvideos)\$RateLimitUn\" max-limit=\"\$(\$rl)\$RateLimitUn\";\r\
\n /queue tree add name=\"8-resto_\$NamePPP\" parent=\"QoS_\$NamePP\
P\" packet-mark=\"PRIO.8\" queue=\"down\" priority=\"8\" limit-at=\"\$(\$c\
resto)\$RateLimitUn\" max-limit=\"\$(\$rl)\$RateLimitUn\";\r\
\n \r\
\n \r\
\n }\r\
\n}"
###################################################################################
###############