Community discussions

MikroTik App
 
tomislav91
Member Candidate
Member Candidate
Topic Author
Posts: 178
Joined: Fri May 26, 2017 12:47 pm

get src ip from destination in firewall

Tue Feb 23, 2021 11:10 am

:local LocalSubnet [:pick [/ip firewall nat find where dst-add
ress=192.168.0.0/16] src-address]];
idea is to use local subnet for further scripting and i have one rule in nat and i want to exclude from that, so src subnets are different but that dst subnet are the same allways, so i want to get that ip into variable.

this vatiable catch nothing. Somewhere is mistake...
this is rule
add chain=srcnat dst-address=192.168.0.0/16 src-address=10.10.189.0/24
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1915
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: get src ip from destination in firewall

Tue Feb 23, 2021 1:09 pm

Do you get any output from running this form command prompt
:put [/ip firewall nat find where dst-address=192.168.0.0/16]
 
Why do not use Splunk to monitor your MikroTik Router(s)? Look at this page in how to set it up.

MikroTik->Splunk
 
 
tomislav91
Member Candidate
Member Candidate
Topic Author
Posts: 178
Joined: Fri May 26, 2017 12:47 pm

Re: get src ip from destination in firewall

Tue Feb 23, 2021 4:21 pm

Do you get any output from running this form command prompt
:put [/ip firewall nat find where dst-address=192.168.0.0/16]
nope
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1915
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: get src ip from destination in firewall

Tue Feb 23, 2021 5:39 pm

You are missing quotes. Try
:put [/ip firewall nat find where dst-address="192.168.0.0/16"]
So this should give what you looking for:
:put [/ip firewall nat get [find where dst-address="192.168.0.0/16"] src-address] 
 
Why do not use Splunk to monitor your MikroTik Router(s)? Look at this page in how to set it up.

MikroTik->Splunk
 

Who is online

Users browsing this forum: alien78, reinierr and 25 guests