Community discussions

MikroTik App
 
User avatar
danz9370
just joined
Topic Author
Posts: 22
Joined: Sun Mar 27, 2005 1:21 pm
Location: Philippines
Contact:

Disable PPPoE Dialer if the Ethernet Cable is not connected

Thu Apr 10, 2014 7:34 pm

Have you experienced your PPPoE dialer keeps on dialing even if the Ethernet cable is disconnected? and the only to stop it from dialing is to disable it?
This is script is to monitor your Ethernet port, if the port has no cable, the PPPoE dialer binded to it will be disabled, and will only enable it again once the port has a "link ok" status.

foreach i in=[/interface find type=pppoe-out] do={

   local intName [/interface get $i name]
   local p [/int pppoe-client get $i interface]

#       Get ethernet links state

        local ethStat [:pick [/interface ether monitor $p  as-value] 6]

#       Check ethernet link state - if link is ok.. enable DSL pppoe dialer

        if ( [:len $ethStat] > 0 ) do={ 

#               Check PPPoE is diasbled

                 if ( [/interface get $intName disabled] ) do={ 

                        log info " $intName on interface $p is OK and disabled.. enabling $intName dialer "
                       [/int ppp-client enable $i]
                 }

       } else= { 

                if ( ![/interface get $intName disabled] ) do={ 
                       log info "$intName on interface $p is down and enabled: CHECK CABLE on port $p.. disabling $intName" 
                       [/int ppp-client disable $i]
                }

       }

}
Last edited by danz9370 on Tue Apr 15, 2014 12:06 am, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12003
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Disable PPPoE Dialer if the Ethernet Cable is not connec

Sun Apr 13, 2014 4:15 am

I prefer this version:
#-----------------------------------------------------------------------------------------
# Scripting by
# Rextended
# Fixing Technologies
# MAKE ANY ALTERATIONS YOU WANT
#----------------------------------------------------------------------------------------- <- +1

# From RouterOS 6.? this script are unuseful, the system automaticaly stop the connection attempt if the master interface are not running

# Wasting no time, monitors only the PPPoE clients that are not Running, this obviates to check later if the PPPoE clients are Running or not.
# Check any interface used by PPPoE clients, not only the ethernets, if are running or not (like EoIP, bridge, etc.).
# If the Interface is running, enable the previous not running PPPoE.
# If the Interface is not running, write a warning on the log and disable the PPPoE for stop the connection attempts.

:foreach pppoe in=[/interface pppoe-client find where running=no] do={
 :local tmpName value=[/interface pppoe-client get $pppoe value-name=name];
 :local tmpInterface value=[/interface pppoe-client get $pppoe value-name=interface];
 :if ([/interface get $tmpInterface value-name=running]) do={
  :log info message=("Interface ".$tmpInterface." now is Running, Enabling ".$tmpName);
  /interface pppoe-client enable $pppoe;
 } else={
  :log warning message=("Interface ".$tmpInterface." not Running, Disabling ".$tmpName." - CHECK INTERFACE");
  /interface pppoe-client disable $pppoe;
 }
}
Last edited by rextended on Mon Apr 14, 2014 4:26 pm, edited 1 time in total.
 
User avatar
aacable
Member
Member
Posts: 435
Joined: Wed Sep 17, 2008 11:58 am
Location: ISLAMIC Republic of PAKISTAN
Contact:

Re: Disable PPPoE Dialer if the Ethernet Cable is not connec

Mon Apr 14, 2014 2:39 pm

Nice ONE :lol:
 
User avatar
danz9370
just joined
Topic Author
Posts: 22
Joined: Sun Mar 27, 2005 1:21 pm
Location: Philippines
Contact:

Re: Disable PPPoE Dialer if the Ethernet Cable is not connec

Mon Apr 14, 2014 6:49 pm

Nice ONE :lol:
at least he came up with something better? and you??
 
User avatar
aacable
Member
Member
Posts: 435
Joined: Wed Sep 17, 2008 11:58 am
Location: ISLAMIC Republic of PAKISTAN
Contact:

Re: Disable PPPoE Dialer if the Ethernet Cable is not connec

Tue Apr 15, 2014 6:09 am

Dear danz9370,

You got me all wrong. I didn't meant to criticize any one's work here.
By "Nice one" really means Good one, Keep up the good work.
I Thought in English, "nice one" means "nice one, good one" :lol:

I appreciate your spirit of sharing, also Rextended did good job by improving it.

BTW, howto increase someone's karma if I accidentally decrease it (PM not allowed so howto send msg to user also)?
 
User avatar
danz9370
just joined
Topic Author
Posts: 22
Joined: Sun Mar 27, 2005 1:21 pm
Location: Philippines
Contact:

Re: Disable PPPoE Dialer if the Ethernet Cable is not connec

Tue Apr 15, 2014 6:52 am

Dear danz9370,

You got me all wrong. I didn't meant to criticize any one's work here.
By "Nice one" really means Good one, Keep up the good work.
I Thought in English, "nice one" means "nice one, good one" :lol:

I appreciate your spirit of sharing, also Rextended did good job by improving it.

BTW, howto increase someone's karma if I accidentally decrease it (PM not allowed so howto send msg to user also)?
the laughing smiley makes your statement to be misunderstood. a simple smiley would be more appropriate. :)
 
User avatar
aacable
Member
Member
Posts: 435
Joined: Wed Sep 17, 2008 11:58 am
Location: ISLAMIC Republic of PAKISTAN
Contact:

Re: Disable PPPoE Dialer if the Ethernet Cable is not connec

Tue Apr 15, 2014 7:18 am

Noted 8)

Who is online

Users browsing this forum: No registered users and 36 guests