Community discussions

MikroTik App
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Help. Log IP List turn values invalid

Mon Feb 06, 2023 10:46 am

Please do help in my simple code, i do like to log all the dst-address of the certain ip, but it returns invalid item number here's my code
/ip firewall connection
:foreach ip in=[get [find] src-address] do={

	:local src [:pick $ip [:find $ip "10.0.4.240"] ([:len $ip] - 6)]

	:local dstResult [/ip firewall connection get [find src=$src] dst-address]
	:log warning $dstResult

}
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Help. Log IP List turn values invalid

Mon Feb 06, 2023 12:04 pm

Can not work, because after just a moment some connections timed out and the "get" return error because the connection not longer exist.

Increase "timeout" if needed, do not remove it.
/ip firewall connection
:foreach idc in=[find where (timeout>2) and src-address~"0.0.0.0"] do={
	:log warning [get $idc dst-address]
}
Last edited by rextended on Mon Feb 06, 2023 2:08 pm, edited 1 time in total.
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: Help. Log IP List turn values invalid

Mon Feb 06, 2023 2:00 pm

thankyou for your reply again sir, ill try this code.
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: Help. Log IP List turn values invalid

Mon Feb 06, 2023 2:07 pm

what if in /tool torch sir? does it work ?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Help. Log IP List turn values invalid

Mon Feb 06, 2023 2:08 pm

???
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Help. Log IP List turn values invalid

Mon Feb 06, 2023 2:12 pm

You can add this on top of your nat rules, it add dynamically any contacted IP, of any protocol, to one firewall address-list thisaddlist
/ip firewall nat
add action=add-dst-to-address-list address-list=thisaddlist address-list-timeout=none-dynamic chain=srcnat dst-address-list=!thisaddlist \
    src-address=10.0.4.240
Last edited by rextended on Mon Feb 06, 2023 2:19 pm, edited 1 time in total.
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: Help. Log IP List turn values invalid

Mon Feb 06, 2023 2:13 pm

What could be wrong sir? , i cant also capture the torch dst-address, what should i do? here's my code

/tool torch
:foreach idc in=[find where interface="vlan10-Hotspot" and src-address~"12.0.4.240" and (timeout>2) ] do={
	/file print file="dst-address.txt"
	/file set "dst-address.txt" content=$idc
}

 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: Help. Log IP List turn values invalid

Mon Feb 06, 2023 2:14 pm

You can add this on top of your nat rules, it add dynamically any contacted IP, of any protocol, to one firewall address-list thisaddlist
/ip firewall nat
add action=add-dst-to-address-list address-list=thisaddlist address-list-timeout=none-dynamic chain=dstnat dst-address-list=!thisaddlist \
    src-address=10.0.4.240
so much appreciated sir, ill try it too. thankyou so much
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Help. Log IP List turn values invalid

Mon Feb 06, 2023 2:19 pm

Sorry, my error, on previous post the chain=srcnat, already fixed.
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: Help. Log IP List turn values invalid

Mon Feb 06, 2023 2:24 pm

Sorry, my error, on previous post the chain=srcnat, already fixed.
It works sir, thankyou so much, so so so much appreciated!!!
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Help. Log IP List turn values invalid

Mon Feb 06, 2023 2:26 pm

It works sir, thankyou so much, so so so much appreciated!!!
Salamat!
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: Help. Log IP List turn values invalid

Mon Feb 06, 2023 2:32 pm

woah , you know tagalog sir ? are you a Filipino ?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Help. Log IP List turn values invalid

Mon Feb 06, 2023 2:35 pm

woah , you know tagalog sir ? are you a Filipino ?
No, you are always kind, and to be kind I wanted to thank you in your language ;)
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: Help. Log IP List turn values invalid

Mon Feb 06, 2023 2:45 pm

ito lang kasi ang aking maibibigay sir, ang aking pasasalamat, at sobrang matulungin po kasi kayo. Godbless always, more luck to come! :D :D :D

Who is online

Users browsing this forum: ko00000000001, mbezuidenhout and 18 guests