Community discussions

MikroTik App
 
moveik
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Tue Nov 24, 2020 1:16 am

Disabling/Enabling a specific entry in an Address List

Wed Mar 24, 2021 10:50 pm

WebFig has a "Address Lists" page in the menu IP -> Firewall -> Address Lists.

That page offers to disable/enable an entry.
How do I perform the same disable/enable mechanism - but using a script?

I searched in the relevant wiki:
https://wiki.mikrotik.com/wiki/Manual:I ... dress_list
but there's no such option..
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11452
Joined: Thu Mar 03, 2016 10:23 pm

Re: Disabling/Enabling a specific entry in an Address List  [SOLVED]

Wed Mar 24, 2021 11:39 pm

The easiest way is to add comment to the entry ... and then toggle disabled flag by searching the comment. E.g.
/ip firewall address-list
add address=192.168.88.88/32 list=somelist comment="My address #1"

# from some script set the address list entry disabled
/ip firewall address-list set [ find comment="My address #1" ] disabled=yes

# ditto to enable it

You can even enable or disable number of address list entries if they have same comment set. You can use other properties in [ find ... ] construct, such as list name ...
 
moveik
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Tue Nov 24, 2020 1:16 am

Re: Disabling/Enabling a specific entry in an Address List

Fri Mar 26, 2021 11:16 am

Works like a charm.

For completeness I'd add that "write" policy should be enabled.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3292
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Disabling/Enabling a specific entry in an Address List

Fri Mar 26, 2021 2:19 pm

You can also use the IP part to find it, like:
/ip firewall address-list set [ find address=192.168.88.88/32 ] disabled=yes

Who is online

Users browsing this forum: mikrochad and 10 guests