Community discussions

MikroTik App
 
User avatar
BrasDeutscher
newbie
Topic Author
Posts: 41
Joined: Sat Sep 03, 2016 12:31 am
Location: Brazil

Qos, Simple but very effectiv setup !!!

Sun Oct 09, 2016 8:37 pm

I've find out a very simple way to Qos my network config, I've only a very slow (700k download) bandwidth and only 400 Mhz Router cpu, but it works very well, I can open 6 YouTube Videos on Mozilla and Simultany navegate my Facebook or each other Site on Chrome !!!
My settings are based on the digital basis, 0 + 1 + 0 + 1 + 1 + 1, yes or no, cold or hot, good or bad, prioritized or no prioritized, very simple but effective !!
You can find this Script in German Language here http://mikrotik-forum.de/viewforum.php?f=41

1. Step, run this to create schedule rule, to edit any go to schedule and edit

/system scheduler
add comment="Dns to Fw and Queue Tree" interval=1m name=\
"Dns to Fw and Queue Tree" on-event="## Dns to Fw and Queue Tree ##\r\
\n## Testet under RouterOS 6.38rc8 ##\r\
\n## Written by BrasDeutscher,PA,Brazil ##\r\
\n{\r\
\n## Set the list name here ##\r\
\n:global ln \"Limited\"\r\
\n\r\
\n## Set the list timeout here ##\r\
\n:global ttl \"1h\"\r\
\n\r\
\n/ip firewall address-list remove [find where address=0.0.0.0 ];\r\
\n/ip firewall address-list remove [find where ! dynamic list=\"\$ln\" ];\
\r\
\n\r\
\n## Set the content here ##\r\
\n:global cont1 \"video\"\r\
\n:foreach d1 in=[/ip dns cache find where (name~\"\$cont1\") type=A ] do=\
{\r\
\n:if ([:len [/ip dns cache get \$d1 address ]] < 16 ) do={\r\
\n:local ip1 [/ip dns cache get \$d1 address ];\r\
\n:local dnsn1 [/ip dns cache get \$d1 name ];\r\
\n:if ([/ip firewall address-list find where address=\$ip1 ] = \"\" ) do={\
\r\
\n/ip firewall address-list add list=\"\$ln\" address=\$ip1 timeout=\"\$tt\
l\" comment=\"\$dnsn1\";\r\
\n}}\r\
\n}}" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive \
start-time=startup

2. Step setup Layer7

/ip firewall layer7-protocol
add comment=EXE name=EXE regexp="\\.(exe)"
add comment=RAR name=RAR regexp="\\.(rar)"
add comment=ZIP name=ZIP regexp="\\.(zip)"
add comment=7z name=7z regexp="\\.(7z)"
add comment=CAB name=CAB regexp="\\.(cab)"
add comment=ASF name=ASF regexp="\\.(asf)"
add comment=MOV name=MOV regexp="\\.(mov)"
add comment=WMV name=WMV regexp="\\.(wmv)"
add comment=MPG name=MPG regexp="\\.(mpg)"
add comment=MKV name=MKV regexp="\\.(mkv)"
add comment=AVI name=AVI regexp="\\.(avi)"
add comment=FLV name=FLV regexp="\\.(flv)"
add comment=WAV name=WAV regexp="\\.(wav)"
add comment=RM name=RM regexp="\\.(rm)"
add comment=M4A name=M4A regexp="\\.(m4a)"
add comment=MP3 name=MP3 regexp="\\.(mp3)"
add comment=MP4 name=MP4 regexp="\\.(mp4)"
add comment=RAM name=RAM regexp="\\.(ram)"
add comment=RMVB name=RMVB regexp="\\.(rmvb)"
add comment=DAT name=DAT regexp="\\.(dat)"
add comment=DAA name=DAA regexp="\\.(daa)"
add comment=ISO name=ISO regexp="\\.(iso)"
add comment=NRG name=NRG regexp="\\.(nrg)"
add comment=BIN name=BIN regexp="\\.(bin)"
add comment=VCD name=VCD regexp="\\.(vcd)"
add comment=WMA name=WMA regexp="\\.(wma)"
add comment=JPG name=JPG regexp="\\.(jpg)"
add comment=JPEG name=JPEG regexp="\\.(jpeg)"
add comment=PNG name=PNG regexp="\\.(png)"
add comment=GIF name=GIF regexp="\\.(gif)"
add comment=WEBM name=WEBM regexp="\\.(webm)"
add comment=3GP name=3GP regexp="\\.(3gp)"
add comment=3G2 name=3G2 regexp="\\.(3g2)"
add comment=MPEG name=MPEG regexp="\\.(f4v)"
add comment=F4A name=F4A regexp="\\.(f4a)"
add comment=F4B name=F4B regexp="\\.(f4b)"
add comment=F4P name=F4P regexp="\\.(f4p)"


3. Step add adicional firewall filter rules
# Set your Wan interface name here #
:global int "Wan-interface-name
/ip firewall filter
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=3G2
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=EXE
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=3GP
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=F4A
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=F4B
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=F4P
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=\
MPEG
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=7z
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=BIN
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=FLV
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=ISO
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=M4A
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=MKV
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=MOV
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=MP3
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=MP4
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=RAR
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=WAV
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=\
WEBM
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=WMA
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=WMV
add action=jump chain=forward comment=Qos jump-target=Qos layer7-protocol=ZIP
add action=jump chain=forward comment=Qos content=download jump-target=Qos
add action=add-src-to-address-list address-list=Limited address-list-timeout=\
1h chain=Qos comment=Qos connection-bytes=10000000-0 connection-rate=\
128k-20M in-interface="$int" protocol=tcp
add action=add-src-to-address-list address-list=Limited address-list-timeout=\
1h chain=Qos comment=Qos connection-bytes=10000000-0 connection-rate=\
128k-20M in-interface="$int" protocol=udp

4. Step add firewall mangle rules, edit your interface-names
# Set your Lan interface name here #
:global int1 "Lan-interface-name"
/ip firewall mangle
add action=mark-packet chain=prerouting comment=Upload in-interface="$int1" \
new-packet-mark=Upload passthrough=no
add action=mark-packet chain=postrouting comment=Limited new-packet-mark=\
Limited out-interface="$int1" passthrough=no src-address-list=Limited
add action=mark-packet chain=postrouting comment=Unlimited new-packet-mark=\
Unlimited out-interface="$int1" passthrough=no src-address-list=!Limited

5. Step add new queue types, you must ajust the pcq dst and src-address-mask to your own network size

/queue type
add kind=pcq name=Limited pcq-burst-rate=768k pcq-burst-threshold=512k \
pcq-classifier=dst-address pcq-dst-address-mask=29 pcq-rate=256k \
pcq-src-address-mask=21
add kind=pcq name=Upload pcq-burst-rate=512k pcq-burst-threshold=384k \
pcq-classifier=src-address pcq-dst-address-mask=29 pcq-rate=256k \
pcq-src-address-mask=21
add kind=pcq name=Unlimited pcq-burst-rate=1M pcq-burst-threshold=768k \
pcq-classifier=dst-address pcq-dst-address-mask=29 pcq-rate=512k \
pcq-src-address-mask=21

6. Step add queue-tree rules

/queue tree
add comment=Upload name=Upload packet-mark=Upload parent=global queue=Upload
add comment=Limited name=Limited packet-mark=Limited parent=global queue=\
Limited
add comment=Unlimited name=Unlimited packet-mark=Unlimited parent=global \
priority=2 queue=Unlimited

7. Step, if you need diferent bandwidth for night and day run this in new terminal

/system scheduler
add comment="Daytime - 1" interval=1d name="Daytime - 1" on-event="## Daytim\
e ##\r\
\n{\r\
\n:global ref \"512k\"\r\
\n:global pref [:pick \$ref 0 3 ];\r\
\n:global x [/queue type get [find where name=Unlimited ] pcq-rate ];\r\
\n:global xx [:pick \$x 0 3 ];\r\
\n:if (\$pref != \$xx) do={\r\
\n:log warning (\"Bandwidth change to Daytime\");\r\
\n/queue type set [find name=Unlimited ] pcq-rate=\"\$ref\" pcq-burst-rate\
=1M pcq-burst-threshold=768k \\\r\
\n pcq-dst-address-mask=29 pcq-src-address-mask=21; \r\
\n/queue type set [find name=Limited ] pcq-rate=256k pcq-burst-rate=768k p\
cq-burst-threshold=512k \\\r\
\n pcq-dst-address-mask=29 pcq-src-address-mask=21;\r\
\n/queue type set [find name=Upload ] pcq-rate=256k pcq-burst-rate=512k pc\
q-burst-threshold=384k \\\r\
\n pcq-dst-address-mask=29 pcq-src-address-mask=21; \r\
\n}}" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive \
start-date=oct/08/2016 start-time=07:00:00
add comment="Daytime - 2" interval=1d name="Daytime - 2" on-event="## Daytim\
e ##\r\
\n{\r\
\n:global ref \"512k\"\r\
\n:global pref [:pick \$ref 0 3 ];\r\
\n:global x [/queue type get [find where name=Unlimited ] pcq-rate ];\r\
\n:global xx [:pick \$x 0 3 ];\r\
\n:if (\$pref != \$xx) do={\r\
\n:log warning (\"Bandwidth change to Daytime\");\r\
\n/queue type set [find name=Unlimited ] pcq-rate=\"\$ref\" pcq-burst-rate\
=1M pcq-burst-threshold=768k \\\r\
\n pcq-dst-address-mask=29 pcq-src-address-mask=21; \r\
\n/queue type set [find name=Limited ] pcq-rate=256k pcq-burst-rate=768k p\
cq-burst-threshold=512k \\\r\
\n pcq-dst-address-mask=29 pcq-src-address-mask=21;\r\
\n/queue type set [find name=Upload ] pcq-rate=256k pcq-burst-rate=512k pc\
q-burst-threshold=384k \\\r\
\n pcq-dst-address-mask=29 pcq-src-address-mask=21; \r\
\n}}" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive \
start-date=oct/08/2016 start-time=17:00:00
add comment="Nighttime - 1" interval=1d name="Nighttime - 1" on-event="## Nigh\
ttime ##\r\
\n{\r\
\n:global ref \"1024k\"\r\
\n:global pref [:pick \$ref 0 3 ];\r\
\n:global x [/queue type get [find where name=Unlimited ] pcq-rate ];\r\
\n:global xx [:pick \$x 0 3 ];\r\
\n:if (\$pref != \$xx) do={\r\
\n:log warning (\"Bandwidth change to Nighttime\");\r\
\n/queue type set [find name=Unlimited ] pcq-rate=\"\$ref\" pcq-burst-rate\
=2M pcq-burst-threshold=1536k \\\r\
\n pcq-dst-address-mask=29 pcq-src-address-mask=21;\r\
\n/queue type set [find name=Limited ] pcq-rate=512k pcq-burst-rate=1536k \
pcq-burst-threshold=1M \\\r\
\n pcq-dst-address-mask=29 pcq-src-address-mask=21;\r\
\n/queue type set [find name=Upload ] pcq-rate=512k pcq-burst-rate=1M pcq-\
burst-threshold=768k \\\r\
\n pcq-dst-address-mask=29 pcq-src-address-mask=21; \r\
\n}}" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive \
start-date=oct/08/2016 start-time=00:00:01
add comment="Nighttime - 2" interval=1d name="Nighttime - 2" on-event="## Nigh\
ttime ##\r\
\n{\r\
\n:global ref \"1024k\"\r\
\n:global pref [:pick \$ref 0 3 ];\r\
\n:global x [/queue type get [find where name=Unlimited ] pcq-rate ];\r\
\n:global xx [:pick \$x 0 3 ];\r\
\n:if (\$pref != \$xx) do={\r\
\n:log warning (\"Bandwidth change to Nighttime\");\r\
\n/queue type set [find name=Unlimited ] pcq-rate=\"\$ref\" pcq-burst-rate\
=2M pcq-burst-threshold=1536k \\\r\
\n pcq-dst-address-mask=29 pcq-src-address-mask=21;\r\
\n/queue type set [find name=Limited ] pcq-rate=512k pcq-burst-rate=1536k \
pcq-burst-threshold=1M \\\r\
\n pcq-dst-address-mask=29 pcq-src-address-mask=21;\r\
\n/queue type set [find name=Upload ] pcq-rate=512k pcq-burst-rate=1M pcq-\
burst-threshold=768k \\\r\
\n pcq-dst-address-mask=29 pcq-src-address-mask=21; \r\
\n}}" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive \
start-date=oct/08/2016 start-time=04:00:01
You do not have the required permissions to view the files attached to this post.

Who is online

Users browsing this forum: Google [Bot] and 35 guests