Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mikrotik Script Auto add route(Gateway)
- :local GWay [/ip dhcp-client get [find interface="ether1"] gateway];
- /ip route add distance=1 gateway=($GWay."%ether1") routing-mark=conn1 scope=255 comment="Auto-Add"
- ---------------------------------------------------------
- Mikrotik Limit Speed With Queue Tree
- /queue type
- add kind=pcq name=PCQ-Upload pcq-classifier=src-address \
- pcq-dst-address6-mask=64 pcq-rate=2M pcq-src-address6-mask=64
- add kind=pcq name=PCQ-Download pcq-classifier=dst-address \
- pcq-dst-address6-mask=64 pcq-rate=2M pcq-src-address6-mask=64
- /queue simple
- add max-limit=10M/10M name=Limit-All queue=PCQ-Upload/PCQ-Download target=\
- 192.168.2.0/24
- Note:
- - max-limit=10M/10M: is total bandwidth.
- - pcq-rate=2M ; maximum speed for a host is only 2Mb
- if you want to unlimited speed for one user, you just set pcq-rate=0. It mean that
- Queue will share Equally Bandwidth for all user.
- /queue type
- add kind=pcq name=PCQ-Upload pcq-classifier=src-address \
- pcq-dst-address6-mask=64 pcq-rate=0 pcq-src-address6-mask=64
- add kind=pcq name=PCQ-Download pcq-classifier=dst-address \
- pcq-dst-address6-mask=64 pcq-rate=0 pcq-src-address6-mask=64
- Mikrotik Unlimit Browsing but Limit Download
- /ip firewall mangle
- add action=mark-connection chain=prerouting connection-bytes=\
- 262146-4294967295 in-interface=ether1 new-connection-mark=download \
- protocol=tcp src-port=21,80
- add action=mark-packet chain=prerouting connection-mark=download \
- in-interface=ether1 new-packet-mark=download passthrough=no
- /queue type
- add kind=pcq name=shape pcq-classifier=src-address pcq-dst-address6-mask=64 \
- pcq-rate=128k pcq-src-address6-mask=64
- /queue tree
- add max-limit=128k name=Download packet-mark=download parent=global queue=\
- shape
- Not: ether1 = WAN interface
- if you have two ISP and configure as load Balancing, you must add two Mangle
- Ex.
- /ip firewall mangle
- add action=mark-connection chain=prerouting connection-bytes=\
- 262146-4294967295 in-interface=ether1 new-connection-mark=download \
- protocol=tcp src-port=21,80
- add action=mark-packet chain=prerouting connection-mark=download \
- in-interface=ether1 new-packet-mark=download passthrough=no
- /ip firewall mangle
- add action=mark-connection chain=prerouting connection-bytes=\
- 262146-4294967295 in-interface=ether2 new-connection-mark=download \
- protocol=tcp src-port=21,80
- add action=mark-packet chain=prerouting connection-mark=download \
- in-interface=ether1 new-packet-mark=download passthrough=no
- Mikrotik How to Calculate Burst time
- https://docs.google.com/spreadsheets/d/1qx9OXTscdOBbWzuRSm0hP-eNyO8asUohvijItJ19flo/edit#gid=0
- http://www.vshabakeh.com/%D9%85%D8%A7%D8%B4%DB%8C%D9%86-%D8%AD%D8%B3%D8%A7%D8%A8-burst-%DB%8C%D8%A7-burst-calculator-simulator/
- https://ip-pro.eu/en/tools/mikrotik_burst_calculator
- https://wispcasts.com
- Mikrotik Load Balancing(NTH Method) 2 WANs(Static IP)
- /ip address
- add address=103.28.2.254/30 interface=WAN1
- add address=103.28.0.254/30 interface=WAN2
- add address=192.168.168.1/24 interface=bridge-LAN
- /ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-packet-size=512 servers=103.28.3.187,8.8.8.8
- /ip firewall mangle
- add chain=prerouting in-interface=bridge-LAN connection-state=new nth=2,1 action=mark-connection new-connection-mark=conn1 passthrough=yes comment="" disabled=no
- add chain=prerouting in-interface=bridge-LAN connection-mark=conn1 action=mark-routing new-routing-mark=conn1 passthrough=no comment="" disabled=no
- add chain=prerouting in-interface=bridge-LAN connection-state=new nth=2,2 action=mark-connection new-connection-mark=conn2 passthrough=yes comment="" disabled=no
- add chain=prerouting in-interface=bridge-LAN connection-mark=conn2 action=mark-routing new-routing-mark=conn2 passthrough=no comment="" disabled=no
- /ip firewall nat
- add chain=srcnat action=masquerade out-interface=WAN1 comment="" disabled=no
- add chain=srcnat action=masquerade out-interface=WAN2 comment="" disabled=no
- /ip route
- add dst-address=0.0.0.0/0 gateway=103.28.2.253 scope=255 target-scope=10 routing-mark=conn1 comment="" disabled=no
- add dst-address=0.0.0.0/0 gateway=103.28.0.253 scope=255 target-scope=10 routing-mark=conn2 comment="" disabled=no
- add dst-address=0.0.0.0/0 gateway=103.28.2.253 comment="" disabled=no
- add dst-address=0.0.0.0/0 gateway=103.28.0.253 comment="" disabled=no
- Note: if you have more then 2 WANs you just add:
- 1. ip --> Address
- 2. ip --> firewall -->Mangle
- 3. ip --> firewall --> NAT
- 4. ip --> route.
- Example: you have three WANs:
- /ip firewall mangle
- add chain=prerouting in-interface=bridge-LAN connection-state=new nth=3,1 action=mark-connection new-connection-mark=conn1 passthrough=yes comment="" disabled=no
- add chain=prerouting in-interface=bridge-LAN connection-mark=conn1 action=mark-routing new-routing-mark=conn1 passthrough=no comment="" disabled=no
- add chain=prerouting in-interface=bridge-LAN connection-state=new nth=3,2 action=mark-connection new-connection-mark=conn2 passthrough=yes comment="" disabled=no
- add chain=prerouting in-interface=bridge-LAN connection-mark=conn2 action=mark-routing new-routing-mark=conn2 passthrough=no comment="" disabled=no
- /ip firewall nat
- add chain=srcnat action=masquerade out-interface=WAN1 comment="" disabled=no
- add chain=srcnat action=masquerade out-interface=WAN2 comment="" disabled=no
- /ip route
- add dst-address=0.0.0.0/0 gateway=103.28.2.253 scope=255 target-scope=10 routing-mark=conn1 comment="" disabled=no
- add dst-address=0.0.0.0/0 gateway=103.28.0.253 scope=255 target-scope=10 routing-mark=conn2 comment="" disabled=no
- add dst-address=0.0.0.0/0 gateway=103.28.2.253 comment="" disabled=no
- add dst-address=0.0.0.0/0 gateway=103.28.0.253 comment="" disabled=no
- -------------------Add Config-----------------
- /ip address
- add address=X.X.X.X/X interface=WAN3
- /ip firewall mangle
- add chain=prerouting in-interface=bridge-LAN connection-state=new nth=3,3 action=mark-connection new-connection-mark=conn3 passthrough=yes comment="" disabled=no
- add chain=prerouting in-interface=bridge-LAN connection-mark=conn3 action=mark-routing new-routing-mark=conn3 passthrough=no comment="" disabled=no
- /ip firewall nat
- add chain=srcnat action=masquerade out-interface=WAN3 comment="" disabled=no
- /ip route
- add dst-address=0.0.0.0/0 gateway=X.X.X.X scope=255 target-scope=10 routing-mark=conn3 comment="" disabled=no
- add dst-address=0.0.0.0/0 gateway=X.X.X.X comment="" disabled=no
- -------------------------------------------------
- Note: /ip firewall mangle: --> nth=3,3 must equal the amount of your WANs.
Add Comment
Please, Sign In to add comment