Mikrotik Script and Scheduler Tutorial

There are lot many ways to limit bandwidth for day and Night, but personally I found this is the easiest way, Here it is.

I have used mikrotik Simple Queue, Script and Scheduler.

Suppose we have one network 192.168.1.0/24 and want to limit mikrotik Bandwidth for day and Night Time.

Network 192.168.1.0/24
mikrotik Bandwidth = 06:00am – 18:00pm – 1Mbps.
mikrotik Bandwidth = 18:00pm – 06:00am – 2Mbps.
Create two simple queues for the same network with different mikrotik Bandwidth Limit.

/queue simple
#name=”Day” target-addresses=192.168.1.0/24 dst-address=0.0.0.0/0
interface= parent=none direction=both priority=8
queue=default-small/default-small limit-at=512k/512k
max-limit=1M/1M total-queue=default-small

#name=”Night” target-addresses=192.168.1.0/24 dst-address=0.0.0.0/0
interface= parent=none direction=both priority=8
queue=default-small/default-small limit-at=1M/1M
max-limit=2M/2M total-queue=default-small
Now, write scripts

/system script
#name=”Day” source=/queue simple enable Day; /queue simple disable Night

#name=”Night” source=/queue simple enable Night; /queue simple disable Day
Finally, Schedule it

/system scheduler
#name=”Day” on-event=Day start-date=oct/13/2007 start-time=06:00:00 interval=1d

#name=”Night” on-event=Night start-date=oct/13/2007 start-time=18:00:00 interval=1d

=====================================================

Script for Mangle and Queue :

Mikrotik v.2.xx

{
:local casper
:set casper “PC0″
:local ip
:set ip “192.168.1.”
:local startip
:set startip 1
:local endip
:set endip 100
/queue tree add name=”Donlot” parent=[LAN interface] limit-at=0 priority=8 queue=default
/queue tree add name=”Upload” parent=[INET interface] limit-at=0 priority=8 queue=default
:for i from=$startip to=$endip do={
:if ($i < 10) do={:set casper "PC0"} else={:set casper "PC"}
/ip firewall mangle add chain=prerouting src-address=($ip . $i) action=mark-connection new-connection-mark=(mc . $i)

passthrough=yes
/ip firewall mangle add chain=prerouting protocol=!1 connection-mark=(mc . $i)action=mark-packet new-packet-mark=(mp . $i)

passthrough=no
/queue tree add name=($casper. $i. "Down") parent="Donlot" packet-mark=(mp . $i) limit-at=0 max-limit=0 queue=default

priority=8
/queue tree add name=($casper. $i. "Up") parent="Upload" packet-mark=(mp . $i) limit-at=0 max-limit=0 queue=default

priority=8
}
}

Mikrotik v.3.xx

{
:local “casper”
:set casper “PC0″
:local “ip”
:set ip 192.168.1.
:local “startip”
:set startip 1
:local “endip”
:set endip 200
/queue tree add name=”Donlot” parent=[LAN interface] limit-at=0 priority=8 queue=default
:for i from=$startip to=$endip do={
:if ($i < 10) do={:set casper “PC0″} else={:set casper “PC”}
/queue tree add name=($casper. $i. “Down”) parent=”Donlot” packet-mark=(”mp” . $i) limit-at=0 max-limit=0 queue=default

priority=8
}
}

credit : MikroTik Wiki

Related Posts
  • Mikrotik Blocking Web
  • VLAN MIKROTIK TUTORIAL
  • Mikrotik Traffic Load Balancing Tutorial
  • Mikrotik Simple Firewall Tutorial
  • Mikrotik Hotspot and RADIUS Server Tutorial
  • Mikrotik Bandwidth Test Tutorial
  • Hardware Reset Mikrotik Tutorial
  • Create Server Dota Game Online in Mikrotik Tutorial
  • The Dude Network Monitoring From Mikrotik Tutorial
  • Load-balancing and Fail-over in MikroTik Tutorial


Trackbacks / Pingbacks

  1. Mikrotik Script and Scheduler Client « 5UP1Y4NT0

Leave a Reply