Hi everybody
I want to measure my abilities with mikrotik scripting language (only mikrotik scripting no API)
so if anyone has an idea for script i ll try to solve it for him
what you want is exactly here , (the traffic monitor tool) :Here goes one...
I have 2 3g/4g Ethernet routers that i am using as Wan1 and Wan2 links.
What I am trying to do is the following:
all traffic should go out Wan1 until I hit my data limit. The Telco gives me full speed of 4-20G until I hit my limit then throttles me to 32K. So the switch mechanism could be use Wan1 until the speed drops (I think very difficult but does not rely on data counters) or check data counters then disable Wan1 and use Wan2 (default backup routes i think).
Reset data counters on interfaces on specific day of the month.
I would appreciate any help, hints ETC...
Thanks
I dont get the full idea, but i think this is what you are looking for : (just copy and past in the new terminal)A script to maintain a list of static DNS entries based on host names found in DHCP leases. Allow the Mikrotik admin to specify the suffix, so a hostname of PC100 gets set as PC100.mycompany.local in the static DNS.
what you want is exactly here , (the traffic monitor tool) :Here goes one...
I have 2 3g/4g Ethernet routers that i am using as Wan1 and Wan2 links.
What I am trying to do is the following:
all traffic should go out Wan1 until I hit my data limit. The Telco gives me full speed of 4-20G until I hit my limit then throttles me to 32K. So the switch mechanism could be use Wan1 until the speed drops (I think very difficult but does not rely on data counters) or check data counters then disable Wan1 and use Wan2 (default backup routes i think).
Reset data counters on interfaces on specific day of the month.
I would appreciate any help, hints ETC...
Thanks
http://wiki.mikrotik.com/wiki/Manual:To ... ic_Monitor
for resetting-counters , you need to put this in a scheduler that is repeated monthly ...
/interface ethernet reset-counters "name of your interface, example:ether1"
sometimes this not , so you need to put a scheduler to reboot the RB each month
/system reboot
Hi Sinan, I looked at traffic monitor but I get the impresion that its for bandwith not for data passed through the interface.. Am I wrong????
what you want is exactly here , (the traffic monitor tool) :Here goes one...
I have 2 3g/4g Ethernet routers that i am using as Wan1 and Wan2 links.
What I am trying to do is the following:
all traffic should go out Wan1 until I hit my data limit. The Telco gives me full speed of 4-20G until I hit my limit then throttles me to 32K. So the switch mechanism could be use Wan1 until the speed drops (I think very difficult but does not rely on data counters) or check data counters then disable Wan1 and use Wan2 (default backup routes i think).
Reset data counters on interfaces on specific day of the month.
I would appreciate any help, hints ETC...
Thanks
http://wiki.mikrotik.com/wiki/Manual:To ... ic_Monitor
for resetting-counters , you need to put this in a scheduler that is repeated monthly ...
/interface ethernet reset-counters "name of your interface, example:ether1"
sometimes this not , so you need to put a scheduler to reboot the RB each month
/system reboot
See below!Hey Sinan,
Here's one for you I've been struggling with. I'm wanting to loop through all wifi channels in the 2.4GHz with a set delay between the channel changes.
For example: Frequency 2412, wait 30 seconds, change to 2417, wait 30 seconds, change to 2422, wait 30 seconds, etc... and have it continually loop until powered off.
Help with this would be greatly appreciated. Thank you.
David
thanx for answering instead of me.See below!Hey Sinan,
Here's one for you I've been struggling with. I'm wanting to loop through all wifi channels in the 2.4GHz with a set delay between the channel changes.
For example: Frequency 2412, wait 30 seconds, change to 2417, wait 30 seconds, change to 2422, wait 30 seconds, etc... and have it continually loop until powered off.
Help with this would be greatly appreciated. Thank you.
David
I'm curious though, what's the purpose of changing the frequency so frequently?
{
do {
:local WirelessLanName "wlan1";
:local wlan [/interface wireless get [find name=$WirelessLanName]];
:local freq ($wlan->"frequency");
:if ($freq = 2462) do={set $freq 2412} else={set $freq ($freq + 5)};
:set ($wlan->"frequency") $freq;
/interface wireless set [find id=($wlan->"id")] frequency=$freq
delay 30s;
} while=(0=0);
}
Looks like it will work, thank you.See below!Hey Sinan,
Here's one for you I've been struggling with. I'm wanting to loop through all wifi channels in the 2.4GHz with a set delay between the channel changes.
For example: Frequency 2412, wait 30 seconds, change to 2417, wait 30 seconds, change to 2422, wait 30 seconds, etc... and have it continually loop until powered off.
Help with this would be greatly appreciated. Thank you.
David
I'm curious though, what's the purpose of changing the frequency so frequently?
{
do {
:local WirelessLanName "wlan1";
:local wlan [/interface wireless get [find name=$WirelessLanName]];
:local freq ($wlan->"frequency");
:if ($freq = 2462) do={set $freq 2412} else={set $freq ($freq + 5)};
:set ($wlan->"frequency") $freq;
/interface wireless set [find id=($wlan->"id")] frequency=$freq
delay 30s;
} while=(0=0);
}
Hi everybody
I want to measure my abilities with mikrotik scripting language (only mikrotik scripting no API)
so if anyone has an idea for script i ll try to solve it for him
To forum jest w języku angielskim zatem proszę go używać
This forum is in English language so please use it.
What are you looking for?can you help me for some scripting ?
some script will take ddosed ip's from /ip firewall address-list and will add this to black hole like this /ip route add bgp-communities=1111:333 comment=ddosed distance=1 dst-address="$id/32" type=blackhole i would like to run this every 5min and it will check again if ip removed from ddosed it will automatically remove it from black hole also.What are you looking for?can you help me for some scripting ?
So you have the address-list already? Then why don't you just make a firewall rule to drop all packets from that address-list? Why does it have to be a route?some script will take ddosed ip's from /ip firewall address-list and will add this to black hole like this /ip route add bgp-communities=1111:333 comment=ddosed distance=1 dst-address="$id/32" type=blackhole i would like to run this every 5min and it will check again if ip removed from ddosed it will automatically remove it from black hole also.
/ip firewall filter
add action=drop chain=forward src-address-list=test comment=ddosed
add action=drop chain=input src-address-list=test comment=ddosed
but I would like to sent them to upstream provider blackholeSo you have the address-list already? Then why don't you just make a firewall rule to drop all packets from that address-list? Why does it have to be a route?some script will take ddosed ip's from /ip firewall address-list and will add this to black hole like this /ip route add bgp-communities=1111:333 comment=ddosed distance=1 dst-address="$id/32" type=blackhole i would like to run this every 5min and it will check again if ip removed from ddosed it will automatically remove it from black hole also.Code: Select all/ip firewall filter add action=drop chain=forward src-address-list=test comment=ddosed add action=drop chain=input src-address-list=test comment=ddosed
Weird way of doing it, but ok.but I would like to sent them to upstream provider blackhole :)
{
:local ddosedList [/ip firewall address-list find list=ddosed]
:foreach ddosedEntry in=$ddosedList do={
:local ddosedIp [/ip firewall address-list get $ddosedEntry address]
:if ([:len [/ip route find comment=ddosed dst-address="$ddosedIp/32"]] = 0) do={
/ip route add bgp-communities=1111:333 comment=ddosed distance=1 dst-address="$ddosedIp/32" type=blackhole
}
}
}
{
:local blackholeList [/ip route find comment=ddosed]
:foreach blackholeEntry in=$blackholeList do={
:local blackholeIp [/ip route get $blackholeEntry dst-address]
:set blackholeIp [:pick $blackholeIp 0 [:find $blackholeIp "/" -1]]
:if ([:len [/ip firewall address-list find list=ddosed address=$blackholeIp]] = 0) do={
/ip route remove $blackholeEntry
}
}
}
Weird way of doing it, but ok.but I would like to sent them to upstream provider blackhole
Try this:It worked in my little test at least.Code: Select all{ :local ddosedList [/ip firewall address-list find list=ddosed] :foreach ddosedEntry in=$ddosedList do={ :local ddosedIp [/ip firewall address-list get $ddosedEntry address] :if ([:len [/ip route find comment=ddosed dst-address="$ddosedIp/32"]] = 0) do={ /ip route add bgp-communities=1111:333 comment=ddosed distance=1 dst-address="$ddosedIp/32" type=blackhole } } } { :local blackholeList [/ip route find comment=ddosed] :foreach blackholeEntry in=$blackholeList do={ :local blackholeIp [/ip route get $blackholeEntry dst-address] :set blackholeIp [:pick $blackholeIp 0 [:find $blackholeIp "/" -1]] :if ([:len [/ip firewall address-list find list=ddosed address=$blackholeIp]] = 0) do={ /ip route remove $blackholeEntry } } }
I couldn't think of a better way to do it than check each list one at a time.
.Hi Sinan,
i need help with this script:
it works as i want but it fills the firewall with same mac addresses, so i need to filter out already added addresses. i tried if statement but im bad in programing and didnt succeded. please helpCode: Select all:local phone "android"; :local telefon value=[/ip dhcp-server lease find dynamic=yes host-name~$phone]; :foreach looping in=$telefon do={ :local mac value=[/ip dhcp-server lease get $looping value-name=active-mac-address]; /ip firewall filter add chain=forward src-mac-address=$mac action=reject comment=szkriptdroid disabled=no /ip dhcp-server lease remove [/ip dhcp-server lease find dynamic=yes active-mac-address=$mac]; log info $mac; };
:local phone "android"
:local phoneLeases [/ip dhcp-server lease find dynamic=yes host-name~$phone]
:foreach looping in=$phoneLeases do={
:local mac [/ip dhcp-server lease get $looping active-mac-address]
:if ([:len [/ip firewall filter find src-mac-address=$mac]] = 0) do={
/ip firewall filter add chain=forward src-mac-address=$mac action=reject comment="szkriptdroid" disabled=no
/ip dhcp-server lease remove $looping
:log info "Mac address \"$mac\" blocked for having \"$phone\" in the name."
}
}
Thank you very much. It works as I wantedHi Sinan,
i need help with this script:
...
it works as i want but it fills the firewall with same mac addresses, so i need to filter out already added addresses. i tried if statement but im bad in programing and didnt succeded. please helpI didn't test it, but I think this should work better.Code: Select all:local phone "android" :local phoneLeases [/ip dhcp-server lease find dynamic=yes host-name~$phone] :foreach looping in=$phoneLeases do={ :local mac [/ip dhcp-server lease get $looping active-mac-address] :if ([:len [/ip firewall filter find src-mac-address=$mac]] = 0) do={ /ip firewall filter add chain=forward src-mac-address=$mac action=reject comment="szkriptdroid" disabled=no /ip dhcp-server lease remove $looping :log info "Mac address \"$mac\" blocked for having \"$phone\" in the name." } }