reconnect pppoe if gateway wrong

Good afternoon, I have a problem with the pppoe connection, for some reason that my provider is unaware of when it has a connection drop, it is connecting to the wrong gateway, what happens when this happens is that it does not access pages, but I can ping via ip; I have 4 more mikrotik that the same problem occurs and I can access them externally normally when this occurs, I have to manually reconnect; would it be possible to do it automatically? If the connection does not take the correct gateway the connection is automatically reconnected.

Mikrotik CRS326-24G-2S+

The tool you need is scripting.

/system scheduler add name=pppoe-watchdog start-time=startup interval=1m on-event={:if ((([/interface pppoe-client monitor pppoe-out1 once as-value]->“remote-address”) <> ip.of.proper.gw) and ([:len [/ip firewall address-list find list=pppoe-delay]] = 0)) do={/interface pppoe-client disable pppoe-out1 ; /interface pppoe-client enable pppoe-out1 ; /ip firewall address-list add list=pppoe-delay address=0.0.0.0 timeout=5m}}

Good morning,

Thank you so much!