Disable PPPoE Dialer if the Ethernet Cable is not connected

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]
                }

       }

}

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;
 }
}

Nice ONE :laughing:

at least he came up with something better? and you??

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” :laughing:

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. :slight_smile:

Noted :sunglasses: