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.
Code: Select all
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]
}
}
}