Getting destination IP

Hey guys,

I want to get the destination IP(s) from a mangle rule that shows activity, I will save it to a file later on for further viewing. I’m now doing it manually from torch, how can I do it by scripting automatically?

Thanks.

I would rather use the add dst to address list action in mangle.

Easier, and you can get a text output at any later stage.

Thank you! Nice shortcut.

I have a question, I have 2 mangle (pre/post routing) marking packets for specific ports. Where can I add my rule? To the end of the mangle list or in between those specific mangle rules? I’m asking this because I know that the order is important in mangle, therefore I do not want to interfere with already working rules.

/ip firewall mangle add chain=prerouting in-interface=ether1 src-address=192.168.1.2 action=add-dst-to-address-list address-list=ping_list protocol=icmp

Above will save the IP(s) to a list whenever the src-address pings a server. I haven’t tested it though.

EDIT: Or this:

/ip firewall mangle add chain=postrouting out-interface=ether2 action=add-dst-to-address-list address-list=ping_list protocol=icmp

(ether2 is that src-address, used out-interface and postrouting to get download, it is viceversa for WAN interface ether1) Am I thinking right?

Only first one (prerouting) is needed.

You can add the address-list mangle rule after the existing one, as long as the existing one has passthrough enabled, mangle proccessing won’t stop there and will reach the one adding to the address list.