Community discussions

MikroTik App
 
HWTest
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 62
Joined: Tue Apr 17, 2007 7:20 pm

How to make one interface dependant on another?

Sat Sep 13, 2014 4:53 pm

I have a PPoE connection to the internet called ADSL and a SSTP VPN client connection called VPN.
My ISP disconnects me every 24h and RB automatically reconnects. The problem is, the VPN connection stays connected but doesn't work after the PPoE reconnection.

I would like to create a script that when the status of the interface ADSL changes to any other status than connected, disables the VPN interface and when the status of the interface ADSL changes back to connected, enables the VPN interface.

It looks simple but I have no scripting skills and so far I'm not able to make a working script, which gets the status of the ADSL interface.

Can anybody please help me?

Thank you.
 
IntrusDave
Forum Guru
Forum Guru
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: How to make one interface dependant on another?

Sat Sep 13, 2014 6:15 pm

Use the NetWatch on the Tools menu. You can have it watch the PPPoE interface, when the PPPoE goes down, use a script to reset both of them.
 
HWTest
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 62
Joined: Tue Apr 17, 2007 7:20 pm

Re: How to make one interface dependant on another?

Sat Sep 13, 2014 7:26 pm

Thank you for the idea.
But the PPoE interface has a dynamic IP, so I have to watch an external address, which could lead to false alarms.
If I could watch the status of the interface directly, that would help.
 
HWTest
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 62
Joined: Tue Apr 17, 2007 7:20 pm

Re: How to make one interface dependant on another?

Sun Sep 14, 2014 8:12 pm

Use the NetWatch on the Tools menu. You can have it watch the PPPoE interface, when the PPPoE goes down, use a script to reset both of them.
I tested the idea.

I watch the ADSL gateway address, I hope it doesn't change. On down I disable the VPN interface, on up I enable it.
The ADSL reconnection is very fast - around 3 seconds, I had to set ping interval to 1 second to catch the reconnection, which on the other hand generates unnecessary traffic.

There must be some other, better way ...
 
IntrusDave
Forum Guru
Forum Guru
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: How to make one interface dependant on another?

Sun Sep 14, 2014 8:23 pm

Okay, new idea. If you know that the connection will drop every 24 hours, how about a script that runs at say 3am..
Have that script take down the VPN (Disable SSTP), Reset the ADSL, and clear all of the connections.
If you preempt the ISP maybe that will help.
 
HWTest
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 62
Joined: Tue Apr 17, 2007 7:20 pm

Re: How to make one interface dependant on another?

Sun Sep 14, 2014 8:36 pm

Okay, new idea. If you know that the connection will drop every 24 hours, how about a script that runs at say 3am..
Have that script take down the VPN (Disable SSTP), Reset the ADSL, and clear all of the connections.
If you preempt the ISP maybe that will help.
So far I've used a workaround - I had set a session timeout to 24:00:00 in the PPP profile. But that wasn't 100% reliable.

The ISP reconnects me every 24h (-+ a couple of seconds) at the time the "first" connection was made, if I reconnect manually the ADSL say at 03:07 am, on the next day it reconnects automatically again on 03:07 am (-+ a couple of seconds). So I cannot prempt the ISP.

My idea is this:
trigger - when status of interface ADSL changes
check status of interface ADSL
if status (/interface pppoe-client monitor status) other than connected
then /interface sstp-client VPN disable

if status (/interface pppoe-client monitor status) is connected
then /interface sstp-client VPN enable

go to the start and wait for another trigger event
The part of disabling, enabling the interface was relatively easy.
But I'm not able to get the status - /interface pppoe-client monitor status and I don't know if there even is a trigger - when status of interface ADSL changes.
 
HWTest
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 62
Joined: Tue Apr 17, 2007 7:20 pm

Re: How to make one interface dependant on another?

Thu Oct 02, 2014 4:22 pm

So far I've set Netwatch to ping every second the internet gateway and disable the VPN interface if not successful, it works but it isn't 100% reliable.

Who is online

Users browsing this forum: No registered users and 26 guests