the comment can distinguish the upnp rules from the other dynamics
yes, dynamic SMTP from HotSpot, and other related dynamic hotspot rules, walled garden rules, etc.
for example
/ip firewall nat> pri
Flags: X - disabled, I - invalid, D - dynamic
0 D chain=dstnat action=jump jump-target=hotspot hotspot=from-client
1 D chain=hotspot action=jump jump-target=pre-hotspot
2 D chain=hotspot action=redirect to-ports=64872 protocol=udp dst-port=53
3 D chain=hotspot action=redirect to-ports=64872 protocol=tcp dst-port=53
4 D chain=hotspot action=redirect to-ports=64873 protocol=tcp hotspot=local-dst dst-port=80
5 D chain=hotspot action=redirect to-ports=64875 protocol=tcp hotspot=local-dst dst-port=443
6 D chain=hotspot action=jump jump-target=hs-unauth protocol=tcp hotspot=!auth
7 D chain=hotspot action=jump jump-target=hs-auth protocol=tcp hotspot=auth
9 D chain=hs-unauth action=return dst-address=179.44.232.13
10 D ;;; www.paypal.comchain=hs-unauth action=return dst-address=2.17.140.171
11 D ;;; www.paypal.comchain=hs-unauth action=return dst-address=2.20.40.117
[…]
# from
:set ( $array->$listname ) 1
[...]
:foreach k,v in=$array do={
# to
:if (!($array ~ $listname)) do={ :set array ($array , $listname) }
[...]
:foreach k in=$array do={
# only k without v
WARNING: BREAKED COMPATIBILITY missing : before some occurrences of if
(no matter is missing on root, but better if you put : on every if also on root to be sure…)
if ([/ip accounting get enabled]=yes) do={
if ($listdynamic = true) do={
if ($i = $cmd) do={:set $f 1}
if ($f<>1) do={
missing : before some occurrences of foreach
foreach logline in=[/ip accounting snapshot find] do={
foreach i in=[/system history find] do={
I do own you several beers for helping out
DHCP part is the only part I have taken from some other
Added all parts to the script. Even found some local variable without :
Not 100% sure on what I do with the uPnP script. One option is to use your solution, other is to rename Dashboard to Dynamic NAT, and to show all types of NAT added to the Router. Do the other dynamic nat has comment set?
Comments for dynamic nat are some strange. In Winbox overview, you do see the comment, but when you open a rule, the comment button is missing and you can not see the comment. /ip firewall nat print does not show to command for dynamic lines.
I just notice also one :do without the : , :set variable with $ in front of variable, and what you already have noticed for global and local
apparently new routeros 6.48+ ignore if the : are present or not, but previous version get an error when the script is on “subdirectory” like “/ip address” and : are omitted.
# *** missing : on do {
# Get uncounted data
do {
/ip accounting uncounted {
# *** remove $ from first $value in front of ":set"
:set $value [:pick $value 0 $newline]
I rewrite this directly, too much errors
:if ([:tonum [:pick [/system resource get version] 0 1]] > 6 and $CmdHistory) do={
# v missing : on both global and local
:global cmd
:local f 0
:foreach i in=[/system history find] do={
# v missing : on both if v removed $ from $f
:if ($i = $cmd) do={ :set f 1 }
# v v replaced <> with != but not really an error if v7 accept <>
:if ($f != 1) do={
:log info message="StartCMD"
:log info message=[/system history get $i]
:log info message="EndCMD"
}
}
# v missing : v missing /
:global cmd [:pick [/system history find] 0]
}
About the dynamic NAT, can be one from 3 types:
this match upnp rule because all upnp rule are “upnp : ” real example: “upnp 192.168.0.163: DIRECT_REVERSE_SERVER”
[/ip firewall nat find where dynamic=yes and comment~"^upnp "]
this match dynamic rules added from hotspot
[/ip firewall nat find where dynamic=yes and chain="hotspot"]
this match dynamic rules added from walled garden
[/ip firewall nat find where dynamic=yes and chain="hs-unauth"]
Mostly bug fixes. A big thanks to rextended
PS If you upgrade script to 4.5, you will lose uPnP info. Will be fixed in upcoming 3.4 with new dynamic nat rule view.
Do any use the Web Proxy view, or is Web Proxy no longer used by anyone due to HTTPS etc? If so I will remove it.
Hi,
This is great work.
But - Well, something is not working for me.
I have a CHR Mikrotik running the script, and a virtual Debian running Rsyslog + Universal Forwarder.
The UF delivers to a Splunk Enterprise (Free) index MikrotikInfo with the Mikrotik App attached.
Data is coming into the index, but I see nothing in the app. In Data → indexes I see the event counter increasing.
I am able to find events, using “index=* sourcetype=MikroTik”
In the index I am able to find all the Neighbor units.
Nothing in the App
This is how I monitor:
bin/splunk add monitor /var/log/remotelogs/192.168.1.126/script,info.log -index MikrotikInfo -sourcetype MikroTik
I guess the index (MikrotikInfo ) you store the MikroTik data is not set a default search index for you.
If you do not see event here:
sourcetype=MikroTik
But this is ok
index=* sourcetype=MikroTik
If you user is part of the admin role, try this:
Settings->Roles->Admin->Indexes
Find the index (MikrotikInfo ) where you store the MikroTik data and in column Default and mark it.
You may need to log out/inn.
If this work, post it here and I will update this info in top post so that other user not using default index will get it to work.
Getting closer.
After setting the index MikrotikInfo to “default”, and restarting splunk (!), I am now able to see my syslogsrv in the devicelist as a host.
But no devices are listed.
I have set the routerID to “MikroTikCHR”. (A virtual CHR for testing purposes)
Then I started tailing the syslog file on syslogsrv. This came up after I rebooted the router:
2021-08-26T09:26:46.302962+02:00 192.168.1.126 script,info script=version ver=4.5
2021-08-26T09:26:46.305321+02:00 192.168.1.126 script,info script=resource free_memory=54 MB total_memory=96 MB free_hdd_space=26 MB total_hdd_space=63 MB cpu_load=1 uptime=00:02:52 write-sect-total=3577
2021-08-26T09:26:46.307561+02:00 192.168.1.126 script,info script=ntp status=started
2021-08-26T09:26:46.307938+02:00 192.168.1.126 script,info script=traffic,fasttrack=0
2021-08-26T09:26:46.318521+02:00 192.168.1.126 script,info .id=*1;comment=;name=ether1;rx-byte=154737;rx-drop=0;rx-error=0;rx-packet=1532;tx-byte=385454;tx-drop=0;tx-error=0;tx-packet=1508;tx-queue-drop=0;script=if_traffic
2021-08-26T09:26:46.320081+02:00 192.168.1.126 script,info script=sysinfo version=“6.48.4 (stable)” board-name=“CHR” model=“na” serial=na identity=“MikroTikCHR” factory-firmware=“na” current-firmware=“na” upgrade-firmware=“na”
2021-08-26T09:26:46.321610+02:00 192.168.1.126 script,info script=neighbor nid=3 .id=“*3”
2021-08-26T09:26:46.321711+02:00 192.168.1.126 script,info script=neighbor nid=3 address=“192.168.1.1”
2021-08-26T09:26:46.321820+02:00 192.168.1.126 script,info script=neighbor nid=3 address4=“192.168.1.1”
<------ the rest deleted ------>
In the index MikrotikInfo this event appears:
26/08/2021
09:26:46.320
2021-08-26T09:26:46.320081+02:00 192.168.1.126 script,info script=sysinfo version=“6.48.4 (stable)” board-name=“CHR” model=“na” serial=na identity=“MikroTikCHR” factory-firmware=“na” current-firmware=“na” upgrade-firmware=“na” host = syslogsrvsource = /var/log/remotelogs/192.168.1.126/script,info.logsourcetype = MikroTik
So we have the identity string in the index, but it is not shown in the device list.
If you would like the entire logfile, I will happy to share it.
My bad - It is a case of RTFM. I did not put the MikroTik prefix in the action.
I cleaned out all old indexfiles and data, and started over, to remove old data.
I am now able to se that a logfile exists in the Mikrotik app.
I will hack on