Community discussions

MikroTik App
 
skynetcuba
just joined
Topic Author
Posts: 1
Joined: Fri Mar 15, 2024 6:12 pm

Please help with Script for Eoip Tunnel

Fri Mar 15, 2024 6:21 pm

Please help with Script for Eoip Tunnel
I have 10 EoIP tunnel interfaces, which through a script obtain the remote addresses of the other part of the tunnel, they communicate through some portals that I have established and assigning the client to dhcp, an example would be
EoIP-21 is established through a link called portal21
The problem I am presenting is that when an eoip runs out of traffic, just by doing a dhcp client release communication is established again, I need a script that allows me to monitor each EoIP and if they do not have traffic then do a dhcp release to their portal a example that I have been working on but it doesn't work for me would be


:local eoipInterface "EoIP-21"


:local eoipInterface "EoIP-21" ; # EoIP interface name
:local dhcpInterface "portal21" ; # DHCP interface name

# Get traffic statistics from EoIP interface
:local eoipStats [/interface eoip monitor $eoipInterface once as-value]
:local txBytes ($eoipStats->"tx-byte")
:local rxBytes ($eoipStats->"rx-byte")

# Check if there is no traffic on the EoIP interface and release the DHCP IP address if applicable
:if (($rxBytes = 0) && ($txBytes = 0)) do={
:log info "No traffic on EoIP interface $eoipInterface. Releasing the DHCP IP address on interface $dhcpInterface."
/ip dhcp-client release [find interface=$dhcpInterface]
} else={
:log info "Traffic detected on EoIP interface $eoipInterface. The DHCP IP address on interface $dhcpInterface will not be released."
}

Who is online

Users browsing this forum: No registered users and 8 guests