infothrill / python-dyndnsc

dynamic dns (dyndns) update client with support for multiple protocols
https://pypi.org/project/dyndnsc/
MIT License
38 stars 17 forks source link

dyndnsc sends an update request even though the IP hasn't changed - thus nsupdate.info flags the domain #140

Closed eayin2 closed 3 years ago

eayin2 commented 3 years ago

Use appdirs (https://pypi.org/project/appdirs/) to store the current IPv6 and IPv4 locally in appdirs.user_data_dir("dyndnsc", "dyndnsc") (translates to /home/user/.local/share/dyndnsc) such that an update request is prevented if the locally stored IP is the same as new. Background is that nsupdate.info flags domains that send multiple update requests even thought the IP didn't change.

eayin2 commented 3 years ago

In the code I found an undocumented daemon implementation. Daemon runs by appending -d to dyndnsc. I think https://github.com/infothrill/python-dyndnsc/blob/59ef5f9e9980da98801df6ed07cc3186abfb0311/dyndnsc/core.py#L142 then only runs the updater if an IP has changed.

infothrill commented 3 years ago

Can you provide logs of the said behaviour? thx

eayin2 commented 3 years ago
DEBUG ArgumentParser(prog='dyndnsc', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
DEBUG Attempting to read configuration from ['/home/user/.local/pipx/venvs/dyndnsc/lib/python3.8/site-packages/dyndnsc/resources/presets.ini', '/home/user/.config/dyndnsc.ini']
DEBUG Successfully read configuration from ['/home/user/.local/pipx/venvs/dyndnsc/lib/python3.8/site-packages/dyndnsc/resources/presets.ini', '/home/user/.config/dyndnsc.ini']
DEBUG config file sections: ['preset:no-ip.com', 'preset:freedns.afraid.com', 'preset:nsupdate.info:ipv4', 'preset:nsupdate.info:ipv6', 'preset:dns.he.net', 'preset:dnsimple.com', 'preset:dnsdynamic.org', 'preset:hopper.pw:ipv4', 'preset:hopper.pw:ipv6', 'preset:dyn.com', 'preset:duckdns.org', 'dyndnsc', 'myconf_ipv4', 'myconf_ipv6']
DEBUG raw config for 'myconf_ipv4': {'updater': 'dyndns2', 'updater-url': 'https://ipv4.nsupdate.info/nic/update', 'detector': 'webcheck4', 'detector-family': 'INET', 'detector-url': 'https://ipv4.nsupdate.info/myip', 'detector-parser': 'plain', 'use_preset': 'nsupdate.info:ipv4', 'updater-hostname': 'userpc01.dnsupdate.info', 'updater-userid': 'userpc01.dnsupdate.info', 'updater-password': 'my-pass'}
DEBUG raw config for 'myconf_ipv6': {'updater': 'dyndns2', 'updater-url': 'https://ipv6.nsupdate.info/nic/update', 'detector': 'webcheck6', 'detector-family': 'INET6', 'use_preset': 'nsupdate.info:ipv6', 'updater-hostname': 'userpc01.dnsupdate.info', 'updater-userid': 'userpc01.dnsupdate.info', 'updater-password': 'my-pass'}
DEBUG Available plugins: []
DEBUG Enabled plugins: []
DEBUG collected_configs: {'myconf_ipv4': {'detector': [('webcheck4', {'family': 'INET', 'url': 'https://ipv4.nsupdate.info/myip', 'parser': 'plain'})], 'updater': [('dyndns2', {'url': 'https://ipv4.nsupdate.info/nic/update', 'hostname': 'userpc01.dnsupdate.info', 'userid': 'userpc01.dnsupdate.info', 'password': 'my-pass'})]}, 'myconf_ipv6': {'detector': [('webcheck6', {'family': 'INET6'})], 'updater': [('dyndns2', {'url': 'https://ipv6.nsupdate.info/nic/update', 'hostname': 'userpc01.dnsupdate.info', 'userid': 'userpc01.dnsupdate.info', 'password': 'my-pass'})]}}
DEBUG Initializing client for 'myconf_ipv4'
DEBUG IP detector uses address family <AddressFamily.AF_INET: 2>
DEBUG DynDnsClient initializer done
DEBUG Querying IP address from 'https://ipv4.nsupdate.info/myip'
DEBUG Starting new HTTPS connection (1): ipv4.nsupdate.info:443
DEBUG https://ipv4.nsupdate.info:443 "GET /myip HTTP/1.1" 200 14
DEBUG IPDetectorWebCheck.set_current_value(my-ipv4)
INFO userpc01.dnsupdate.info: dns IP 'None' does not match detected IP 'my-ipv4', updating
DEBUG Updating 'userpc01.dnsupdate.info' to 'my-ipv4' at service 'https://ipv4.nsupdate.info/nic/update'
DEBUG Starting new HTTPS connection (1): ipv4.nsupdate.info:443
DEBUG https://ipv4.nsupdate.info:443 "GET /nic/update?myip=my-ipv4&hostname=userpc01.dnsupdate.info HTTP/1.1" 200 5
DEBUG status 200, abuse
DEBUG Initializing client for 'myconf_ipv6'
DEBUG IP detector uses address family <AddressFamily.AF_INET6: 10>
DEBUG DynDnsClient initializer done
DEBUG Querying IP address from 'https://ipv6.nsupdate.info/myip'
DEBUG Starting new HTTPS connection (1): ipv6.nsupdate.info:443
DEBUG https://ipv6.nsupdate.info:443 "GET /myip HTTP/1.1" 200 36
DEBUG IPDetectorWebCheck6.set_current_value(my-ipv6)
INFO userpc01.dnsupdate.info: dns IP 'None' does not match detected IP 'my-ipv6', updating
DEBUG Updating 'userpc01.dnsupdate.info' to 'my-ipv6' at service 'https://ipv6.nsupdate.info/nic/update'
DEBUG Starting new HTTPS connection (1): ipv6.nsupdate.info:443
DEBUG https://ipv6.nsupdate.info:443 "GET /nic/update?myip=my-ipv6-string-encoded&hostname=userpc01.dnsupdate.info HTTP/1.1" 200 5
DEBUG status 200, abuse
infothrill commented 3 years ago

According to the log (I assume it was redacted for privacy), the public dns resolution does not return an IP address:

INFO userpc01.dnsupdate.info: dns IP 'None' does not match detected IP 'my-ipv6', updating

dns IP 'None' causes dyndnsc to perform an update, since it could not resolve the hostname, thus assuming it needs to be set.

Can you verify if this is correct by performing a manual DNS lookup on your hostname? ie dig +short $hostname

eayin2 commented 3 years ago

Correct, but I can't update because the FQDN is flagged. I unflagged it and could update it now. I wonder what caused it being flagged. I run dyndnsc in systemd every minute, maybe nsupdate.info was bothered about the lookup? Or maybe something else caused my client to send an update request multiple times, as I run dyndnsc for quiet some while and had no issues. So best to let it run as daemon now and see if they flag it again before we troubleshoot too much

infothrill commented 3 years ago

ok. Closing for now. Please feel free to re-open if there's more clarity about what happened. thx!