Automatically restarting Cloudflared when internet is restored

I had a internesting issue this morning. We had a bad storm move though and we lost internet. I have all my routers, and pi-hole on UPS and protected. But the Cloudfared daemon would not service requests after the internet was restored. I had to manually stop and restart it. Before I restarted I was able to confirm that local DNS was being resolved from cache but anything upstream would hit the Cloudflared and there would be no return.

I was wondering if anyone has written a script that would test for a loss of internet on their pi-hole? I was thinking if I could detect this loss and restoration of internet I could then restart the cloudflard service.

Thanks…

Did you ever find a solution for this? The only thing keeping me on unbound on pfsense is that it always started working again as soon as internet is restored…

Yes I moved from the Cloudflared daemon to the dnscrypt proxy which uses the DNS over HTTPS for the Cloudflared service. Since doing this I have never had an issue where I had to restart dnscryptto re-establish connection to Cloudflared.

My pi.hole has been hands off now for almost 6 months and really happy.