Community discussions

MikroTik App
 
tomislav91
Member
Member
Topic Author
Posts: 303
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: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

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]
 
tomislav91
Member
Member
Topic Author
Posts: 303
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: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

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] 
 
tomislav91
Member
Member
Topic Author
Posts: 303
Joined: Fri May 26, 2017 12:47 pm

Re: get src ip from destination in firewall

Wed Mar 17, 2021 11:28 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] 
thats it, thanks!
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: get src ip from destination in firewall

Thu Mar 18, 2021 7:58 am

@
Why did you quote my message? No need to quote the post above you!!

There is a button below the post Post Reply to use when reply on the post.

Who is online

Users browsing this forum: donkeyKong, rogerioqueiroz and 23 guests