lgc-4 / one.com-ddns-python-script

A (relatively) simple python script to update one.com type A DNS records
GNU General Public License v3.0
20 stars 6 forks source link

To detect internet-loss #8

Closed AndreasSchutz closed 1 year ago

AndreasSchutz commented 1 year ago

Would it be a good idea to just ping one.com and abort if they do not answer?

lgc-4 commented 1 year ago

Great idea. But I figured it would probably be enough to just check for connection errors when fetching the IP or trying to log into one.com

https://github.com/lgc-4/one.com-ddns-python-script/commit/62a6c6d2024d8587fa587dade84aa61ce4f8d9ea should resolve this

AndreasSchutz commented 1 year ago

Yes that is neat!

For me I will add a test to reach one.com and if that fails five times I will toggle the power to my router. One of the big/silly problems I have is that my providers router can't propagate DNS updates from upstream to my clients after some heavy traffic has occurred (like streaming a film). So from time to time I will loose DNS fuctionality.

lgc-4 commented 1 year ago

That's very odd but I'm glad you found a solution that works for you!

By the way, the script should always exit with an error code if it wasn't successful for any reason so you can detect whether it was able to send the requests or not using some simple bash scripting

i.e.

$ python3 one_com_ddns.py && echo "script was successful" || echo "an error occured"

However, this does not detect why the script failed, only that it did, so it might not work for what you need.