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.5k stars 221 forks source link

Allows update of private IP range #119

Closed tomcollis closed 2 years ago

tomcollis commented 3 years ago

The default (or example) URLs for getting your external IPv4 and IPv6 addresses are currently not working due to an expired certificate. I've changed mine to:

ipv4.icanhazip.com ipv6.icanhazip.com

Both the URLs above can be accessed over HTTP or HTTPS, they are supported by CloudFlare so should be very reliable.

Anyway, the problem this caused was every 10 minutes (the interval for my GoDNS), the following would happen:

1 - GoDNS checks IP address, fails to get current WAN address so uses the address on the local interface (docker 172.000.000.000) 2 - Checks the current DNS record, which is different to the address from step 1 3 - Tries to update CloudFlare via API to an IP address classed as internal (which thankfully fails because CloudFlare won't allow it)

This process repeats forever.

It would be great if GoDNS recognises an IPv4 or IPv6 an internal address and don't try to update and sends a different message via notifications (I'm currently using Telegram).

I think this is part bug and part enhancement.

Tom

TimothyYe commented 2 years ago

Thanks Tom, sorry for the late reply.

I've updated the default URL for getting IPV4 and IPV6 addresses.

For the bug you mentioned about, if the GoDNS fails to get WAN address, should output the error message, and wait until the next loop. I'm not sure how it gets the private IP from the local interface? Did you enable the ip_interface feature and configure the interface name?

tomcollis commented 2 years ago

@TimothyYe sorry, it's taken me a while to get a moment to have a look at my config. It has been working perfectly in the meantime. My config file is:

{ "provider": "Cloudflare", "login_token": "abc-token-123", "domains": [ { "domain_name": "domain.co.uk", "sub_domains": [ "stage", "*.test" ] } ], "ip_url": "http://ipv4.icanhazip.com", "ipv6_url": "http://ipv6.icanhazip.com", "ip_type": "IPv4", "interval": 600, "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.111 Safari/537.36", "ip_interface": "eth0", "socks5_proxy": "", "use_proxy": false, "debug_info": false, "notify": { "telegram": { "enabled": true, "bot_api_key": "123", "chat_id": "123", "message_template": "Domain *{{ .Domain }}* is updated to %0A{{ .CurrentIP }}", "use_proxy": false } } }

I haven't enabled the 'ip_interface' feature.

TimothyYe commented 2 years ago

Good to hear that, thanks for your feedback.