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: 9119
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)
 
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: UkRainUa and 27 guests