The official Mikrotik router thread

Out of interest sake, you changing the "byte" query to give you "bits". But why? Or is it because the grafana dash show it as bits aka Mb/s ?
Yip, my dashboard was showing me incorrect values in Mbps, so when I saturated my 30Mbps line, it was only showing 3.75Mbps utilization.
 
Yip, my dashboard was showing me incorrect values in Mbps, so when I saturated my 30Mbps line, it was only showing 3.75Mbps utilization.
Interesting. I didn't make that change, and can confirm mine still shows the same as your query before the change. But my values seems....accurate.

Screenshot 2022-12-06 at 07.36.46.png


Screenshot 2022-12-06 at 07.37.01.png
 
Huh, that is quite strange. Mine was definitely out by a large margin, but adding in that *8 into the query solved it.

BTW, if you don't want periodic internet speedtests to be done, you can turn it off by doing the following:

Ssh to the mktxp service/container (bin/sh and root)
Type mktxp edit -i and press enter
Change Bandwidth = True to Bandwidth = False
Press ctrl-x to exit Nano and press y and enter to save
Restart the mktxp service stack
 
While fiddling with my mangle rules to try and get some of my nonessential traffic to route across rain instead of Frogfoot, I managed to make it work using tables and route rules instead.

First, create a routing table for each ISP, making sure they are added to the Forwarding Information Base (FIB):

[phireside@MikroTik] > /routing table add name=ISP1 fib
[phireside@MikroTik] > /routing table add name=ISP2 fib

Then, add a route to 0.0.0.0/0 for each of the ISP's listed above (pppoe0 and ether2 respectively):

[phireside@MikroTik] > /ip route add dst-address=0.0.0.0/0 gateway=pppoe0 routing-table=ISP1
[phireside@MikroTik] > /ip route add dst-address=0.0.0.0/0 gateway=ether2 routing-table=ISP2

Then, add rules to route the traffic (In this case, I am routing traffic from 10.0.0.6 to ISP2, and traffic to 8.8.8.8 to ISP1:

[phireside@MikroTik] > /routing rule add src-address=10.0.0.6 action=lookup-only-in-table table=ISP1
[phireside@MikroTik] > /routing rule add dst-address=8.8.8.8 action=lookup-only-in-table table=ISP2

This is a quick and dirty way to route traffic to certain ISP's, but it is not as granular as mangle rules can be as you cannot specify ports/protocols. Also note that if an ISP goes down, traffic will fail to be routed at all, unless you specify action=lookup as the routing rule. Lookup-only-in-table means that the traffic will be forced to go via that rule and cannot failover to any other WAN interface.
 
I have a simple script to push a notification to uptime kuma every 10 minutes.

/tool fetch url="https://dagger.humptydumpty.com/api/push/<key>?status=up&msg=OK&ping=1" mode=http

I would like to to include the actual value of a ping to 1.1.1.1 in the url. Any ideas?
 
I have a simple script to push a notification to uptime kuma every 10 minutes.



I would like to to include the actual value of a ping to 1.1.1.1 in the url. Any ideas?
:local result [/tool ping-speed address=1.1.1.1 first-ping-size=32 second-ping-size=1500 duration=5 interval=1s as-value];

Use result as a variable in your push notification
 
I have a simple script to push a notification to uptime kuma every 10 minutes.



I would like to to include the actual value of a ping to 1.1.1.1 in the url. Any ideas?
{
:local avgRtt;
/tool flood-ping 1.1.1.1 count=10 do={
:if ($sent = 10) do={
:set avgRtt $"avg-rtt"
}
}
/tool fetch url="https://dagger.humptydumpty.com/api/push/<key>?status=up&msg=OK&ping=$avgRtt" mode=http;
}
 
Here's one for the more experienced okes on here. I have a dual WAN situation, but I also dynamically change queues depending on the status of said WAN connections. Because they are assymetric, I think I would need to include some logic into the script itself. I am not very good with scripting, I might add.

How would I go about making a script that can run every 10 seconds with the scheduler, and dynamically adjust the queue limits based on which WAN connections are up? I'd like something sort of similar to this:

If WAN1+WAN2=up, set queue to 100mbps
If WAN1=up and WAN2=down, set queue to 15mbps
If WAN2=down and WAN2=up, set queue to 50mbps
If both WANs down, revert to 100mbps

I can then just use the scheduler to run on startup and every ten seconds after that, which is easy enough. At the moment I am using Netwatch to achieve the above, but it's janky as when both go down and one WAN comes back, it installs the wrong queue limits and causes a bit of havoc with downloads etc.

EDIT: I was thinking that I might need to assign some variables to help me out. Was thinking of something like assigning a '1' to WAN1 and a 2' to WAN2 (I can do this by watching which routes are available since Netwatch does this for me), so that if the variable is '3', then set queues to 100mbps, but if it's '1', then set it to 15mbps, and if '2', set to 50mbps.
 
Last edited:
At the moment I am using Netwatch to achieve the above, but it's janky as when both go down and one WAN comes back, it installs the wrong queue limits and causes a bit of havoc with downloads etc.
Can you not modify the up script in netwatch to check the other interface so for example when wan2 comes back online:

:if ([/interface WAN1 running=yes]) do={
/queue set 100meg
} else={
/queue set 50meg
}
 
Oh God :-/
I really have alot to learn about this shandis. I'm just a little boy, **** it, infantile even. LOL! I'll just do me self a favour, and just start reading/figuring out alles. I'll take me time. Haha!
... Lemme not ask them further questions. Rather, lemme jus' immerse me self innit :D

Anyways, thanks alot guys. No.:1
 
Can you not modify the up script in netwatch to check the other interface so for example when wan2 comes back online:

:if ([/interface WAN1 running=yes]) do={
/queue set 100meg
} else={
/queue set 50meg
}
Thanks man.

I used the above and modified it slightly.

Here is the code I used:

Netwatch WAN1 UP:

Python:
/log error "*** Frogfoot is UP ***"
:if [/ip route find where comment="ISP2_TEST" and active=yes] do={
/queue simple set [find comment=limit] max-limit=100M/100M
} else={
/queue simple set [find comment=limit] max-limit=15M/15M
}

Netwatch WAN1 DOWN:

Python:
/log error "*** Frogfoot is DOWN ***"
:if [/ip route find where comment="ISP2_TEST" and active=yes] do={
/queue simple set [find comment=limit] max-limit=50M/50M
} else={
/queue simple set [find comment=limit] max-limit=100M/100M
}

Netwatch WAN2 UP:

Python:
/log error "*** Rain is UP ***"
:if [/ip route find where comment="ISP1_TEST" and active=yes] do={
/queue simple set [find comment=limit] max-limit=100M/100M
} else={
/queue simple set [find comment=limit] max-limit=15M/15M
}

Netwatch WAN2 DOWN:

Python:
/log error "*** Rain is DOWN ***"
:if [/ip route find where comment="ISP1_TEST" and active=yes] do={
/queue simple set [find comment=limit] max-limit=15M/15M
} else={
/queue simple set [find comment=limit] max-limit=100M/100M
}

I have two routes to 0.0.0.0/0, one via Frogfoot (pppoe0) and the other via Rain (ether2), so I commented those and watch them for activity with the above. I also have two static blackhole routes setup to 1.1.1.2 and 1.1.1.3 for Frogfoot and Rain respectively which ensures that Netwatch works properly in the first place. I could only have imagined having this sort of autonomy with my old EdgeRouter! Safe to say I am converted :)
 
Last edited:
Thanks man.

I used the above and modified it slightly.

Here is the code I used:

Netwatch WAN1 UP:

Python:
/log error "*** Frogfoot is UP ***"
:if [/ip route find where comment="ISP2_TEST" and active=yes] do={
/queue simple set [find comment=limit] max-limit=100M/100M
} else={
/queue simple set [find comment=limit] max-limit=15M/15M
}

Netwatch WAN1 DOWN:

Python:
/log error "*** Frogfoot is DOWN ***"
:if [/ip route find where comment="ISP2_TEST" and active=yes] do={
/queue simple set [find comment=limit] max-limit=50M/50M
} else={
/queue simple set [find comment=limit] max-limit=100M/100M
}

Netwatch WAN2 UP:

Python:
/log error "*** Rain is UP ***"
:if [/ip route find where comment="ISP1_TEST" and active=yes] do={
/queue simple set [find comment=limit] max-limit=100M/100M
} else={
/queue simple set [find comment=limit] max-limit=15M/15M
}

Netwatch WAN2 DOWN:

Python:
/log error "*** Rain is DOWN ***"
:if [/ip route find where comment="ISP1_TEST" and active=yes] do={
/queue simple set [find comment=limit] max-limit=15M/15M
} else={
/queue simple set [find comment=limit] max-limit=100M/100M
}

I have two routes to 0.0.0.0/0, one via Frogfoot (pppoe0) and the other via Rain (ether2), so I commented those and watch them for activity with the above. I also have two static blackhole routes setup to 1.1.1.2 and 1.1.1.3 for Frogfoot and Rain respectively which ensures that Netwatch works properly in the first place. I could only have imagined having this sort of autonomy with my old EdgeRouter! Safe to say I am converted :)

now just to add email integration :sneaky:
 
Top
Sign up to the MyBroadband newsletter
X