Limit Youtube Bandwidth on Mikrotik

Video stream usually consume high bandwidth, at least 384kbps, you can imagine if 15 peoples stream YouTube video at the same time while we only have 5MB bandwidth. The speed of video streams limited by using Simple Queue rule.

mikrotik_vs_youtube

Here are the steps to Limit Youtube Video Stream Bandwidth on Mikrotik.

1. Login to your Mikrotik WinBox
Click on IP > Firewall, select tab : Layer7 Protocols, and click on + button and then click Ok.
You will have the new rule of Layer7 Protocols with the name streaming. You can add any other url video stream inside Regexp.

/ip firewall layer7-protocol
add comment="" name=streaming regexp="^.+(c.youtube.com).*$"

or

/ip firewall layer7-protocol
add comment="" name=streaming regexp="videoplayback|video"

2. Still in firewall window, select tab : Mangle
Here you will to create a new mangle rule.

/ip firewall mangle
add chain=prerouting action=mark-connection new-connection-mark=video_stream \
comment="Mark Streaming" passthrough=yes src-address-list=Youtuber in-interface=bridge-local

add chain=prerouting action=mark-packet new-packet-mark=video_stream_packet \
passthrough=yes connection-mark=video_stream

3. On the winbox menu click : Queues
Queue list will be shown. On tab : Simple Queue, here you will to create a new queue rule for video streaming.

/queue simple
add name=Limit_Video_Day target-addresses=192.168.88.0/24 \
direction=both disabled=no interface=bridge-local limit-at=128k/128k max-limit=256k/256k \
packet-marks=video_stream_packet parent=none priority=8 \
queue=default-small/default-small burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s \
total-queue=default-small
add name=Limit_Video_Night target-addresses=192.168.88.0/24 \
direction=both disabled=yes interface=bridge-local limit-at=0/3M max-limit=0/3M \
packet-marks=video_stream_packet parent=none priority=8 \
queue=default-small/default-small burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s \
total-queue=default-small

In this case, we want to make differences bandwidth on Day and Night
Day = 06:00am – 18:00pm – 256kbps. <Max-Limit>
Night = 18:00pm – 06:00am – 3Mbps. <Max-Limit>

4. Script
System > Script

/system script
add name=Limit_Video_Day source="/queue simple enable Limit_Video_Day; \
/queue simple disable Limit_Video_Night"
add name=Limit_Video_Night source="/queue simple enable Limit_Video_Night; \
/queue simple disable Limit_Video_Day"

5. Scheduler
System > Scheduler

/system scheduler
add disabled=no interval=1d name=Limit_Video_Day on-event=Limit_Video_Day \
start-date=oct/10/2014 start-time=06:00:00
add disabled=no interval=1d name=Limit_Video_Night on-event=Limit_Video_Night \
start-date=oct/10/2014 start-time=18:00:00

Source:
http://www.oaultimate.com/networking/mikrotik-hotspot-limit-youtube-based-on-user-profile.html
http://agratitudesign.blogspot.com/2013/08/solution-to-limit-youtube-video-streams.html
http://adamonline.web.id/mikrotik/beda-limit-bandwidth-siang-dan-malam

You may also like...