Community discussions

MikroTik App
 
arm920t
just joined
Topic Author
Posts: 12
Joined: Sat Aug 03, 2019 8:02 am

How to update more than one port by scripting to one rule?

Thu May 07, 2020 5:49 am

Sorry for my english.I build a nas bt for 7*24h with qBittorrent.It built a upnp rule with "qBit" in the comment. I want to add the port to a mangle rule to cut off bt speed.But with scripting i can only add one port to the mangle rule.Is there any way to update more than one port ? I have tried to use array but it can not work as what i want , and i can't add chart "," to a array.
this is what i use now.It can only update one port.
:log info "*** check dynamic UPNP port ***";
:local UpnpP
:local newport
:local status
:local currentport
:local dynamicRulesArray [/ip firewall nat find where dynamic=yes];
:foreach i in=$dynamicRulesArray do={
:if ("." . [:find [/ip firewall nat get $i comment] "qBit"] . "."!="..") do={
:set UpnpP value=[/ip firewall nat get $i dst-port]
:set newport ($newport "$UpnpP")
}
:put ($newport)
:set currentport [ /ip firewall mangle get [/ip firewall mangle find comment=("BTTCP")] port ]
:if ($currentport != $newport) do={
/ip firewall mangle set [ /ip firewall mangle find comment=("BTTCP") ] port=$newport
}
:set currentport [ /ip firewall mangle get [/ip firewall mangle find comment=("BTUDP1")] port ]
:if ($currentport != $newport) do={
/ip firewall mangle set [ /ip firewall mangle find comment=("BTUDP1") ] port=$newport
}
:set currentport [ /ip firewall mangle get [/ip firewall mangle find comment=("BTUDP2")] port ]
:if ($currentport != $newport) do={
/ip firewall mangle set [ /ip firewall mangle find comment=("BTUDP2") ] port=$newport
}
}
 
User avatar
jvanhambelgium
Member
Member
Posts: 312
Joined: Thu Jul 14, 2016 9:29 pm
Location: Belgium

Re: How to update more than one port by scripting to one rule?

Thu May 07, 2020 8:09 am

I would :

-> Disable uPNP all together.
-> Configure fixed rules using a set of FIXED ports that you also configured on your torrent application.

Eg. I have 2 rules (for UDP & TCP) for my Deluge torrent environment using ports 6800 to 6900 and fixed the Deluge config accordingly.
Then when these rules are there you can further do something with them through script (eg. bandwidth manipulation)
 
arm920t
just joined
Topic Author
Posts: 12
Joined: Sat Aug 03, 2019 8:02 am

Re: How to update more than one port by scripting to one rule?

Thu May 07, 2020 8:38 am

Thanks for your reply.I shared network with others who won't use static port because they known i will cut their BT speed.I need sometings like "port list",but after google a lot.It seems there is no soluation.The script i use did collect all port i need. The problem is that i can‘t translate it like“ prot1 , port2 , port3" which can be used to config the rule.

Who is online

Users browsing this forum: Jotne and 15 guests