wiki:Mikrotik

Version 5 (modified by krit, 4 years ago) (diff)

--

Mikrotik

Checking LTE signal, ssh

[admin@G01] > /interface lte info lte1 
[admin@G01] > /system ssh 192.168.11.11 user=pi 

Script for checking Internet, VPN

[admin@G01] > /system script print 
Flags: I - invalid 
 0   name="script_reboot" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon 
     dont-require-permissions=no last-started=feb/28/2021 16:13:33 run-count=30 
     source=
       :if ([/ping 8.8.8.8 count=3 size=64 interval=2s]=0) do={
        :log error "LTE DOWN";
        /system reboot;
       } else={
        :log info "LTE OK";
       }

 1   name="check_vpn" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon dont-require-permissions=no 
     last-started=feb/28/2021 16:22:33 run-count=15 source=
       :if ([/ping 192.168.59.1 count=3 size=64 interval=2s]=0) do={
           :log error "----VPN DOWN";
           /interface pptp-client set pptp-out1 disabled=yes;
           /delay 1s;
           /interface pptp-client set pptp-out1 disabled=no;
       } else={
         :log info "----VPN OK";
       }

 2   name="check_internet" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon 
     dont-require-permissions=no last-started=feb/28/2021 16:23:33 run-count=29 
     source=
       :if ([/ping 8.8.8.8 count=3 size=64 interval=2s]=0) do={
           :log error "----Internet DOWN";
           /interface lte set numbers=lte1 disabled=yes;
           /system routerboard usb power-reset duration=1;
           :log info "---Power USB DOWN ---";
           /delay 40s;
           /interface lte set numbers=lte1 disabled=no;
           :log info "---Enable lte1 ";
       } else={
           :log info "----Internet OK";
       }   

 3   name="vpn_lossLong" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon 
     dont-require-permissions=no run-count=0 source=
       :if ([/ping 192.168.59.1 count=10 size=64 interval=5s]=0) do={
           :log error "----VPN LOSS LONG DOWN Reboot";
           /system reboot;
       } else={
           :log info "----VPN LOSS LONG OK";
       }
[admin@G01] > 

Scheduler for checking Internet, VPN

[admin@G01] > /system scheduler print 
Flags: X - disabled 
 #   NAME                       START-DATE  START-TIME                     INTERVAL             ON-EVENT                      RUN-COUNT
 0   CheckReboot                            startup                        15m                  script_reboot                         3
 1   CheckVPN                               startup                        3m                   check_vpn                            15
 2   CheckInternet                          startup                        2m                   check_internet                       23
 3   CheckVPNLongLoss                       startup                        1h                   vpn_lossLong                          0
[admin@G01] >