Community discussions

MUM Europe 2020
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 2950
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

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 USE THIS SCRIPT, PLEASE ADD KARMA.
THANKS TO ALL.


If anyone find a bug, please report.
Thanks.
I'm Italian, not English. Sorry for my imperfect grammar.
 
efaden
Forum Guru
Forum Guru
Posts: 1711
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: 617
Joined: Fri Sep 01, 2006 4:18 pm
Location: Iran , Karaj
Contact:

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 .
MTCNA , MTCRE, MTCWE, Mikrotik Certified Trainer
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 2950
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

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.
I'm Italian, not English. Sorry for my imperfect grammar.
 
User avatar
omidkosari
Trainer
Trainer
Posts: 617
Joined: Fri Sep 01, 2006 4:18 pm
Location: Iran , Karaj
Contact:

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 .
MTCNA , MTCRE, MTCWE, Mikrotik Certified Trainer
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 2950
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

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.
I'm Italian, not English. Sorry for my imperfect grammar.
 
n21roadie
Forum Guru
Forum Guru
Posts: 1896
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
N21roadie,
Network 100% MT for Now?
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 2950
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

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

Thu Apr 03, 2014 5:19 pm

This script simply do all without intervention...
I'm Italian, not English. Sorry for my imperfect grammar.
 
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.
----------------------
Mikrotik Consultant.
MTCNA, MTWCE, MTCTCE, MTCRE, MTCINE
 
User avatar
omidkosari
Trainer
Trainer
Posts: 617
Joined: Fri Sep 01, 2006 4:18 pm
Location: Iran , Karaj
Contact:

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 .
MTCNA , MTCRE, MTCWE, Mikrotik Certified Trainer
 
rodolfo
Long time Member
Long time Member
Posts: 543
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.
rodolfo
IZ0UQV
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 2950
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

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.
I'm Italian, not English. Sorry for my imperfect grammar.
 
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: 2950
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

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.

For test only (active) pptp replace
:local pppTest value=[/ppp active find];
with
:local pppTest value=[/ppp active find where service=pptp];
I'm Italian, not English. Sorry for my imperfect grammar.

Who is online

Users browsing this forum: CoMMyz and 9 guests