Can you please recommend how to parse active ppp connections (VPN clients) to an array, which can be then checked by the foreach loop ?
For some reason, randomly some of my 5 VPN clients get 0.0.0.0 as address. It's enough to kill that connection and Vpn will reconnect with right IP, so I was thinking to script it (yeah, I know best is to resolve culprit of the problem itself)
I get in the log
Processing connection - Index: , Name: , Address: , Uptime:
Connection does not have 0.0.0.0 address. Skipping removal.
So it's not possible to parse it.... however I never wrote any script for Mikrotik.
Thank you.
For some reason, randomly some of my 5 VPN clients get 0.0.0.0 as address. It's enough to kill that connection and Vpn will reconnect with right IP, so I was thinking to script it (yeah, I know best is to resolve culprit of the problem itself)
Code:
# Fetch active PPP connections:local connectionsList [:parse [/ppp/active/print as-value]]# Process connections:foreach connection in=$connectionsList do={ :local index ($connection->".id") :local name ($connection->"name") :local address ($connection->"address") :local uptime ($connection->"uptime") # Log details of each connection :log info ("Processing connection - Index: " . $index . ", Name: " . $name . ", Address: " . $address . ", Uptime: " . $uptime) # Check if ADDRESS is 0.0.0.0 :if ($address="0.0.0.0") do={ :log info ("Connection has 0.0.0.0 address. Initiating removal.") # ($removeConnection $index $name $address $uptime) } else={ :log info ("Connection does not have 0.0.0.0 address. Skipping removal.") }}
Processing connection - Index: , Name: , Address: , Uptime:
Connection does not have 0.0.0.0 address. Skipping removal.
So it's not possible to parse it.... however I never wrote any script for Mikrotik.
Thank you.
Statistics: Posted by sharkys — Thu Dec 14, 2023 11:20 pm