Community discussions

MikroTik App
 
tik4jn
just joined
Topic Author
Posts: 8
Joined: Wed Apr 13, 2016 5:15 pm

Hotspot Script Match Assistance

Thu Apr 05, 2018 2:15 am

Hi All,

We are attempting to create a script that :

Deletes all queues where
1) Name contains the word "hotspot" AND
2) IP Address NOT in a specified subnet

The first part works with the name, but we can't seem to get the IP Address section to work.

here is our code:

/queue simple {
:foreach item in=[find name ~"hotspot" && target in !="1.1.1.0/24"] do={
remove $item
}
}

Here is the queue that should be deleted :
[admin@MikroTik] /queue simple> pr
Flags: X - disabled, I - invalid, D - dynamic
0 name="hotspot" target=2.2.2.2/32 parent=none packet-marks="" priority=8/8 queue=default-small/default-small limit-at=0/0 max-limit=0/0
burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s bucket-size=0.1/0.1


Can someone assist please? Thank You
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: Hotspot Script Match Assistance

Fri Apr 06, 2018 11:30 am

:foreach item in=[/queue simple find where (name~"hotspot" && target!="1.1.1.0/24")] do={/queue simple remove $item}
 
tik4jn
just joined
Topic Author
Posts: 8
Joined: Wed Apr 13, 2016 5:15 pm

Re: Hotspot Script Match Assistance

Mon Apr 09, 2018 7:08 pm

Thank You for the assistance.

The code provided matches anything that is not specifically "1.1.1.0/24" but does not actually check to see if the IP Address is not in that range.

Example : the script provided will remove a queue with the target IP of 1.1.1.2 which it should not.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: Hotspot Script Match Assistance

Tue Apr 10, 2018 9:54 am

:foreach item in=[/queue simple find where (name~"hotspot" && target~"1\\.1\\.1\\.[0-9]+"=false)] do={/queue simple remove $item}

Who is online

Users browsing this forum: No registered users and 10 guests