Hi
I need a script in such a way that when the interface is out of run mode, it will be in run mode again with enable, and this script will be checked every minute.
mikrotik ver : 7.7
Sample code generated by ChatGBT:
/system script add name=check_l2tp source={
:local interface_name;
:foreach interface in=[/interface find type=l2tp-ethernet] do={
:set interface_name [/interface get $interface name];
:if ([/interface get $interface running]) do={
:put (“L2TP Ethernet interface ‘$interface_name’ is already running.”);
} else {
:put (“Starting L2TP Ethernet interface ‘$interface_name’…”);
/interface enable $interface;
}
}
}
Really? Can’t believe it …
yes but don’t work
So what are you posting this nonworking code for? Just to promote chat?
try this:
:global ifstatus
:if ([/interface ethernet get ether1 running]=true) do={
:put "running"
:if ($ifstatus="down") do={
:put "changed to up"
}
:set $ifstatus "up"
} else={
:put "not running"
:if ($ifstatus="up") do={
:put "changed to down"
}
:set $ifstatus "down"
}
i running l2tp ethernet
change ethernet to l2tp ethernet ?
This script worked with a few changes, but if ether is not running, will it automatically run again?
This script was tested. When Ether exits the run mode, it does not run again, even though the script counts.
stop spam quotes everywhere.
It’s ridiculous, simply modify last post if you want add something to yourself.
clean up the mess you made in previous posts: delete everything quoted.