Community discussions

MikroTik App
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 13149
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connections

Wed Mar 19, 2014 10:23 pm

* = OVPN and PPP [and async???] connection must be tested, but I think is also working for that connection,
when I have confirmation, I remove the * on the title.


This IS the script, I think for all type of PPP connection, but are tested only for PPPOE, PPTP, L2TP, SSTP, I have not tested this for OVPN and PPP:

The syntax are 6.7+ compatible, I do not know if also is working on 5.x or previous.

What this scheduling do on a "ppp" of any type server:
Each 20 minutes [also from routerboard reboots], check all type of ppp connected, if 2 ping over 2 fail, the connection are closed (and logged). Everytime the script start and ends, write logs.


Simply paste this on terminal
/system scheduler
add disabled=no interval=20m name=check-ppp-client on-event=":log info message=\"*** start check any ppp client connection ***\";\r\
    \n:local pppTest value=[/ppp active find];\r\
    \n:local pingNumber value=2;\r\
    \n:local pingMin value=1;\r\
    \n:foreach userTest in=\$pppTest do={\r\
    \n :local pingOk value=[:ping [/ppp active get \$userTest value-name=address] count=\$pingNumber]\r\
    \n :if ( \$pingOk < \$pingMin) do={\r\
    \n  :log warning message=([/ppp active get \$userTest value-name=service] . \" auto disconnected: \". \$pingOk . \" ping ok over \" . \$pingNumber . \" \" . [/ppp active get \$userTest value-name=name] . \" \" . [/ppp active get \$userTest value-\
    name=address])\r\
    \n  /ppp active remove \$userTest\r\
    \n }\r\
    \n};\r\
    \n:log info message=\"*** end check any ppp client connection ***\";\r\
    \n" policy=ftp,read,write,test start-date=jan/01/2002 start-time=00:20:00
This is the version not coded for scheduler:
:log info message="*** start check any ppp client connection ***";
:local pppTest value=[/ppp active find];
:local pingNumber value=2;
:local pingMin value=1;
:foreach userTest in=$pppTest do={
 :local pingOk value=[:ping [/ppp active get $userTest value-name=address] count=$pingNumber]
 :if ($pingOk < $pingMin) do={
  :log warning message=([/ppp active get $userTest value-name=service] . " auto disconnected: ". $pingOk . " ping ok over " . $pingNumber . " " . [/ppp active get $userTest value-name=name] . " " . [/ppp active get $userTest value-name=address])
  /ppp active remove $userTest
 }
};
:log info message="*** end check any ppp client connection ***";
If anyone find a bug, please report.
Thanks.
Last edited by rextended on Mon Mar 20, 2023 6:30 pm, edited 1 time in total.
 
efaden
Forum Guru
Forum Guru
Posts: 1708
Joined: Sat Mar 30, 2013 1:55 am
Location: New York, USA

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connect

Wed Mar 19, 2014 11:35 pm

* = OVPN and PPP [and async???] connection must be tested, but I think is also working for that connection,
when I have confirmation, I remove the * on the title.


This IS the script, I think for all type of PPP connection, but are tested only for PPPOE, PPTP, L2TP, SSTP, I have not tested this for OVPN and PPP:

The syntax are 6.7+ compatible, I do not know if also is working on 5.x or previous.

What this scheduling do on a "ppp" of any type server:
Each 20 minutes [also from routerboard reboots], check all type of ppp connected, if 2 ping over 2 fail, the connection are closed (and logged). Everytime the script start and ends, write logs.


Simply paste this on terminal
/system scheduler
add disabled=no interval=20m name=check-ppp-client on-event=":log info message=\"*** start check any ppp client connection ***\";\r\
    \n:local pppTest value=[/ppp active find];\r\
    \n:local pingNumber value=2;\r\
    \n:local pingMin value=1;\r\
    \n:foreach userTest in=\$pppTest do={\r\
    \n :local pingOk value=[:ping [/ppp active get \$userTest value-name=address] count=\$pingNumber]\r\
    \n :if ( \$pingOk < \$pingMin) do={\r\
    \n  :log warning message=([/ppp active get \$userTest value-name=service] . \" auto disconnected: \". \$pingOk . \" ping ok over \" . \$pingNumber . \" \" . [/ppp active get \$userTest value-name=name] . \" \" . [/ppp active get \$userTest value-\
    name=address])\r\
    \n  /ppp active remove \$userTest\r\
    \n }\r\
    \n};\r\
    \n:log info message=\"*** end check any ppp client connection ***\";\r\
    \n" policy=ftp,read,write,test start-date=jan/01/2002 start-time=00:20:00
This is the version not coded for scheduler:
:log info message="*** start check any ppp client connection ***";
:local pppTest value=[/ppp active find];
:local pingNumber value=2;
:local pingMin value=1;
:foreach userTest in=$pppTest do={
 :local pingOk value=[:ping [/ppp active get $userTest value-name=address] count=$pingNumber]
 :if ($pingOk < $pingMin) do={
  :log warning message=([/ppp active get $userTest value-name=service] . " auto disconnected: ". $pingOk . " ping ok over " . $pingNumber . " " . [/ppp active get $userTest value-name=name] . " " . [/ppp active get $userTest value-name=address])
  /ppp active remove $userTest
 }
};
:log info message="*** end check any ppp client connection ***";

IF ANYONE USE THIS SCRIPT, PLEASE ADD KARMA.
THANKS TO ALL.


If anyone find a bug, please report.
Thanks.
Tagging for future reference.
 
User avatar
omidkosari
Trainer
Trainer
Posts: 640
Joined: Fri Sep 01, 2006 4:18 pm
Location: Canada, Toronto

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connect

Wed Apr 02, 2014 10:08 pm

Thanks
Please also provide what is the usage of this script ? I mean in which situations this script will be useful .
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 13149
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connect

Wed Apr 02, 2014 11:58 pm

Sometime the "ppp" link stop working, but still considered active on both sides.
This script simply check if the "ppp" on the client side are reachable.
If not reachable by IP, but is considered wrongly as active, the script close the connection.
The "ppp", once disconnected, made again the connection and all restart to working correctly.

This script is tested for PPPoE, PPtP L2L2TP, SSTP, but I have not yet tested for OVPN or PPP (serial / usb) connections.
 
User avatar
omidkosari
Trainer
Trainer
Posts: 640
Joined: Fri Sep 01, 2006 4:18 pm
Location: Canada, Toronto

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connect

Thu Apr 03, 2014 2:37 pm

What happens if client's firewall blocks ping ( icmp ) ?
Then your script will always disconnect those clients .
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 13149
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connect

Thu Apr 03, 2014 4:23 pm

What happens if client's firewall blocks ping ( icmp ) ?
Then your script will always disconnect those clients .
Who is the ..... that block ping coming from IP master of the other side of the tunnel? :shock:

Your let your client to enter on RouterBoard and change parameters?

This script is not intended for PC connected to ppp, but for the RouterBoard (like CPE) remotely connected.

Can be used ARP ping.
 
n21roadie
Forum Guru
Forum Guru
Posts: 1949
Joined: Fri Aug 07, 2009 10:36 pm
Location: Limerick,Ireland

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connect

Thu Apr 03, 2014 5:06 pm

With V5x APs using PPPoE server an intermittent issue where dynamic local IP address was not assigned to clients but remote address was, so clients had no internet, the solution was to reboot and problem solved now I have a script to check for pppoe local ip address and email when there is ping failure with 2000ms timeout, I could simply run disable/enable pppoe server interface but this issue thankfully does not happen very often
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 13149
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connect

Thu Apr 03, 2014 5:19 pm

This script simply do all without intervention...
 
User avatar
TheWiFiGuy
Member
Member
Posts: 351
Joined: Thu Nov 24, 2011 7:26 pm
Location: UK

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connect

Thu Apr 03, 2014 11:29 pm

Are you not seeing the PPP connection sometimes hang? Ive been using a very similar script on 500+ 411's with Huawei modems and whilst it works for the most count, at least once per day PPP totally freezes (watchdog may kick in and reboot). We also see the USB in /ports disapear and re-appear with a different name and a default PPP connection get created.

Currently with Mikrotik for resolution (seen in 6.1 -> 7.
 
User avatar
omidkosari
Trainer
Trainer
Posts: 640
Joined: Fri Sep 01, 2006 4:18 pm
Location: Canada, Toronto

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connect

Sat Apr 05, 2014 9:34 am

This script is not intended for PC connected to ppp, but for the RouterBoard (like CPE) remotely connected.
I know it may look impossible but INVENTING a way for that situation will be also very useful .
 
rodolfo
Long time Member
Long time Member
Posts: 553
Joined: Sat Jul 05, 2008 11:50 am

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connect

Mon Sep 22, 2014 11:18 am

ciao rextended.
Do you have an idea why this pppoe client stops?
I realized this happen when, for some reasons, there is a disconnection between client and pppoe server if they are connected via an eoip tunnel.
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 13149
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connect

Fri Sep 26, 2014 4:19 pm

I have no idea, I made this script for prevent that problem, but I not know why the problem happen.
 
stealthmatt
just joined
Posts: 2
Joined: Sun Mar 01, 2015 7:23 am

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connections

Sun Mar 01, 2015 3:16 pm

how to i specify what ip address to ping?

also is there a way only to test pptp?
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 13149
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connections

Mon Mar 16, 2015 11:39 am

how to i specify what ip address to ping?

also is there a way only to test pptp?
The address is automatically get from pptp connection, you do not need to specify the IP.
Last edited by rextended on Mon Mar 20, 2023 6:30 pm, edited 1 time in total.
 
Alaqmar12121
just joined
Posts: 19
Joined: Sun Dec 22, 2019 2:19 pm

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connections

Sun Dec 22, 2019 2:24 pm

I used code below with PPPoE client, seems not working when i got the FP Rx 0 with pppoe status (connected). Do I need to change ppp to pppoe? My router-board RB 1100Dx4 version 6.46.1
* = OVPN and PPP [and async???] connection must be tested, but I think is also working for that connection,
when I have confirmation, I remove the * on the title.


This IS the script, I think for all type of PPP connection, but are tested only for PPPOE, PPTP, L2TP, SSTP, I have not tested this for OVPN and PPP:

The syntax are 6.7+ compatible, I do not know if also is working on 5.x or previous.

What this scheduling do on a "ppp" of any type server:
Each 20 minutes [also from routerboard reboots], check all type of ppp connected, if 2 ping over 2 fail, the connection are closed (and logged). Everytime the script start and ends, write logs.


Simply paste this on terminal
/system scheduler
add disabled=no interval=20m name=check-ppp-client on-event=":log info message=\"*** start check any ppp client connection ***\";\r\
    \n:local pppTest value=[/ppp active find];\r\
    \n:local pingNumber value=2;\r\
    \n:local pingMin value=1;\r\
    \n:foreach userTest in=\$pppTest do={\r\
    \n :local pingOk value=[:ping [/ppp active get \$userTest value-name=address] count=\$pingNumber]\r\
    \n :if ( \$pingOk < \$pingMin) do={\r\
    \n  :log warning message=([/ppp active get \$userTest value-name=service] . \" auto disconnected: \". \$pingOk . \" ping ok over \" . \$pingNumber . \" \" . [/ppp active get \$userTest value-name=name] . \" \" . [/ppp active get \$userTest value-\
    name=address])\r\
    \n  /ppp active remove \$userTest\r\
    \n }\r\
    \n};\r\
    \n:log info message=\"*** end check any ppp client connection ***\";\r\
    \n" policy=ftp,read,write,test start-date=jan/01/2002 start-time=00:20:00
This is the version not coded for scheduler:
:log info message="*** start check any ppp client connection ***";
:local pppTest value=[/ppp active find];
:local pingNumber value=2;
:local pingMin value=1;
:foreach userTest in=$pppTest do={
 :local pingOk value=[:ping [/ppp active get $userTest value-name=address] count=$pingNumber]
 :if ($pingOk < $pingMin) do={
  :log warning message=([/ppp active get $userTest value-name=service] . " auto disconnected: ". $pingOk . " ping ok over " . $pingNumber . " " . [/ppp active get $userTest value-name=name] . " " . [/ppp active get $userTest value-name=address])
  /ppp active remove $userTest
 }
};
:log info message="*** end check any ppp client connection ***";

IF ANYONE USE THIS SCRIPT, PLEASE ADD KARMA.
THANKS TO ALL.


If anyone find a bug, please report.
Thanks.
Last edited by Alaqmar12121 on Mon Dec 23, 2019 8:03 am, edited 1 time in total.
 
Alaqmar12121
just joined
Posts: 19
Joined: Sun Dec 22, 2019 2:19 pm

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connections

Mon Dec 23, 2019 7:01 am

Anyone please to help me
 
nikc
Member Candidate
Member Candidate
Posts: 208
Joined: Wed Jul 13, 2016 6:05 pm

Re: Check locked PPPOE, PPTP, L2TP, SSTP, OVPN* PPP* connections

Tue Aug 04, 2020 8:15 pm

Just discovered this thread, absolutely superb, thanks for sharing, solves a problem for me !