TimothyYe / godns

A dynamic DNS client tool that supports AliDNS, Cloudflare, Google Domains, DNSPod, HE.net & DuckDNS & DreamHost, etc, written in Go.
https://timothyye.github.io/godns/
Apache License 2.0
1.49k stars 218 forks source link

The strangest thing (wrong public IP) #222

Closed gitwittidbit closed 8 months ago

gitwittidbit commented 8 months ago

Describe the bug
Just started using GoDNS and it is working well so far. Except for one strange bug: Every 25 minutes it notices that my public IP has changed to some wrong IP address (and updates the DNS records accordingly). After 5 more minutes it notices that the IP has changed again to the actual IP address (and updates the DNS records accordingly). So I am guessing that one of the services GoDNS polls (via round robin) is providing the wrong IP address but when I poll them manually, all of them provide the correct IP address. My problem is: In the logs I cannot see from which service the wrong information is coming. Otherwise I would just eliminate it from the list. Is there a way to have GoDNS put this info in the logs?

The frequency of this issue

Steps to Reproduce
Plain vanilla setup. Just modified the example config.json to include my DNS (and Pushover) credentials. Oh, and BTW: I also changed the URL for "ip4.seeip.org" to "seeip.org" because the ssl certificate expired on ip4.seeip.org.

Your GoDNS configuration
{ "provider": "Cloudflare", "password": "", "login_token": "xxxxx", "domains": [ { "domain_name": "example.com", "sub_domains": ["@", "*"] } ], "ip_urls": [ "https://api.ipify.org", "https://myip.biturl.top", "https://seeip.org", "https://ipecho.net/plain", "https://api-ipv4.ip.sb/ip", "https://api.ip.sb/ip" ], "ipv6_urls": ["https://ipify.org"], "ip_type": "IPv4", "interval": 300, "resolver": "8.8.8.8", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.11> "ip_interface": "eth0", "socks5_proxy": "", "use_proxy": false, "debug_info": false, "proxied": false, "notify": { "pushover": { "enabled": true, "token": "xxx", "user": "xxx", "message_template": "", "device":"", "title":"", "priority": 0, "html": 1 }, "mail": { "enabled": false, "smtp_server": "", "smtp_username": "", "smtp_password": "", "smtp_port": 25, "send_from": "", "send_to": "" } }, "webhook": { "enabled": false, "url": "http://localhost:5000/api/v1/send", "request_body": "{ \"domain\": \"{{.Domain}}\", \"ip\": \"{{.CurrentIP}}\", \"ip_type\": \"{{.IPType}}\" }" } }

Expected behavior
GoDNS does not notice a change of my public IP that does not actually happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Additional context
I can definitely rule out that my IP does change every 25 minutes and then back after 5 more minutes.

gitwittidbit commented 8 months ago

Okay, figured it out myself:

As mentioned, I had changed the ip of one of the "whatismyip"-services. I replaced it with the url that company behind the service gave me. I had not thought about it, but the url contained a path component that requests the IP address in json format.

Apparently, GoDNS expects just the plain IP and when it receives anything else, this is still interpreted as an IP address. The json formatting in my case apparently was interpreted as a (different) IP address and this is where the wrong IP address came from.

After I removed the path component requesting json format, the service gave me the plain IP address and the issue is gone.

TimothyYe commented 8 months ago

Glad to hear that you've found the root cause.

TimothyYe commented 8 months ago

I think I can optimize this part, to check the online IP format, if it's not the plain IP format, GoDNS could output the error message.