Community discussions

MikroTik App
 
josecat
just joined
Topic Author
Posts: 10
Joined: Tue May 10, 2011 4:27 pm
Location: Spain

Use of Variables on firewall src-address

Sun Nov 29, 2020 12:25 am

I´m traying to do this:
:global lan "192.168.250.0/24"
/ip firewall filter
add action=drop chain=forward comment="Drop packets from LAN Not in LAN IP Range" in-interface-list=LOCAL_LAN log=yes log-prefix=!LAN_TOWAN_ src-address=!$lan

It seems that variables can´t be used on src-address with negation wildcard !......

If i make the following works fine:
:global lan "192.168.250.0/24"
/ip firewall filter
add action=drop chain=forward comment="Drop packets from LAN Not in LAN IP Range" in-interface-list=LOCAL_LAN log=yes log-prefix=!LAN_TOWAN_ src-address=$lan

Where i´m making a mistake?

Thanks in advance.
 
Sob
Forum Guru
Forum Guru
Posts: 6474
Joined: Mon Apr 20, 2009 9:11 pm

Re: Use of Variables on firewall src-address  [SOLVED]

Sun Nov 29, 2020 12:50 am

You can make the "!" part of string, either when you define it, or like this:
src-address=("!".$lan)
Excessive quoting is useless and annoying. If you use it, please consider if you could do without it.
 
josecat
just joined
Topic Author
Posts: 10
Joined: Tue May 10, 2011 4:27 pm
Location: Spain

Re: Use of Variables on firewall src-address

Sun Nov 29, 2020 1:13 am

Thanks very much Sob for your fast and correct response. It works

Who is online

Users browsing this forum: No registered users and 28 guests