leamas / ddupdate

Update DNS Data for Dynamic IP Addresses
MIT License
40 stars 28 forks source link

Error updating ipv6 #21

Closed ruedigerkupper closed 5 years ago

ruedigerkupper commented 5 years ago

Using ddupdate with plugin "default-web-ip6" fails. I can see from the debug output that it successfully retrieves my IPv6 address, but then function "filter_ip" in main.py fails.

This is ddupdate from the Ubuntu .deb package (version 0.6.1).

Debug output follows:

Jun 03 13:35:09 reinhold systemd[1]: Starting Update DNS  data for this host...
Jun 03 13:35:09 reinhold ddupdate[1676]: DEBUG - Using config file: /etc/ddupdate.conf
Jun 03 13:35:09 reinhold ddupdate[1676]: INFO - Loglevel: DEBUG
Jun 03 13:35:09 reinhold ddupdate[1676]: INFO - Using hostname: reinhold.dynv6.net
Jun 03 13:35:09 reinhold ddupdate[1676]: INFO - Using ip address plugin: default-web-ip6
Jun 03 13:35:09 reinhold ddupdate[1676]: INFO - Using service plugin: dynv6.com
Jun 03 13:35:09 reinhold ddupdate[1676]: INFO - Service options:
Jun 03 13:35:09 reinhold ddupdate[1676]: INFO - Address options:
Jun 03 13:35:09 reinhold ddupdate[1676]: DEBUG - paths :/usr/lib/python3:/root/.local/share/ddupdate:/usr/local/share/ddupdate:/usr/share/ddupdate
Jun 03 13:35:09 reinhold ddupdate[1676]: DEBUG - Loaded 0 address and 0 service plugins from /usr/lib/python3
Jun 03 13:35:09 reinhold ddupdate[1676]: DEBUG - Loaded 0 address and 0 service plugins from /root/.local/share/ddupdate
Jun 03 13:35:09 reinhold ddupdate[1676]: DEBUG - Loaded 0 address and 0 service plugins from /usr/local/share/ddupdate
Jun 03 13:35:09 reinhold ddupdate[1676]: DEBUG - Loaded 7 address and 17 service plugins from /usr/share/ddupdate
Jun 03 13:35:09 reinhold ddupdate[1676]: INFO - Trying: https://now-dns.com/ip
Jun 03 13:35:09 reinhold ddupdate[1676]: DEBUG - trying https://now-dns.com/ip
Jun 03 13:35:09 reinhold ddupdate[1676]: DEBUG - Got response: 2a02:8070:b681:5500:88c2:2cdf:9ff3:44d
Jun 03 13:35:09 reinhold ddupdate[1676]: Traceback (most recent call last):
Jun 03 13:35:09 reinhold ddupdate[1676]:   File "/usr/bin/ddupdate", line 17, in <module>
Jun 03 13:35:09 reinhold ddupdate[1676]:     main.main()
Jun 03 13:35:09 reinhold ddupdate[1676]:   File "/usr/lib/python3/dist-packages/ddupdate/main.py", line 429, in main
Jun 03 13:35:09 reinhold ddupdate[1676]:     ip = filter_ip(opts.ip_version, ip)
Jun 03 13:35:09 reinhold ddupdate[1676]:   File "/usr/lib/python3/dist-packages/ddupdate/main.py", line 349, in filter_ip
Jun 03 13:35:09 reinhold ddupdate[1676]:     raise AddressError("No usable address")
Jun 03 13:35:09 reinhold ddupdate[1676]: ddupdate.ddplugin.AddressError: 'No usable address'
Jun 03 13:35:09 reinhold systemd[1]: ddupdate.service: Main process exited, code=exited, status=1/FAILURE
Jun 03 13:35:09 reinhold systemd[1]: ddupdate.service: Failed with result 'exit-code'.
Jun 03 13:35:09 reinhold systemd[1]: Failed to start Update DNS  data for this host.
leamas commented 5 years ago

Yes... Using ipv6 means manual configuration. The configuration file is in a standard installation ~/.config/ddupdate.conf. The corresponding manpage is ddupdate.confwhich basically just refers to ddupdate.

Here we can read about --ip-version. From your stackdump I guess that this is still v4, right? This should explain what's happening. In that case you could just change it to something sane -- using v4 with a ipv6 address is certainly problematic.

ruedigerkupper commented 5 years ago

Hi, thanks for the answer. I have configured ddupdate.conf correctly, as far as I can see (attached below). I get the same error with ip-version = v6 and ip-version = all (which should both work, as I understand). If I change address-plugin to default-web-ip, everything works (but it naturally updates my IPv4). Using default-web-ip6, I get the above error. So I really think it's a bug either in the adresser-plugin or in function filter-ip() or related.

Just a wild guess: Could it be that filter-ip() has a problem with shortened IPv6 addresses? As you see above, my address was reported as 2a02:8070:b681:5500:88c2:2cdf:9ff3:44d, which is really the same as 2a02:8070:b681:5500:88c2:2cdf:9ff3:044d, but leading zeros may be omitted in IPv6 quadruples. Could it be it chokes because the last quadrupel is just a triple?

Contents of my ddupdate.conf:

# Created by ddupdate-config at Mon Jun  3 13:16:30 2019
[update]
ip-version = all
loglevel = debug
address-plugin = default-web-ip6
service-plugin = dynv6.com
hostname = reinhold.dynv6.net
leamas commented 5 years ago

Confirmed. There is at least a bug in the addresser which returns a plain address instead of an object.

Could you please test the attached patch? 0001-plugins-default-web6-Fix-IpAddr-return-value-21.patch.gz

leamas commented 5 years ago

Nope. That patch is horribly wrong. Stay tuned...

leamas commented 5 years ago

OK, new try. Could you please make a test with a -v v6 command line option, like ddupdate -v v6 and report back?

I suspect that the value in the config file isn't parsed, but I have no ipv6 testbed readily available...

ruedigerkupper commented 5 years ago

Yep! That's it! ddupdate -v v6 and ddupdate -v all work as they should.

leamas commented 5 years ago

OK, some progress. Could you then try this patch, without any command line args?

EDIT: Remove broken patch.

leamas commented 5 years ago

too quick, again, patch broken. Stay tuned...

leamas commented 5 years ago

Revised patch, sort of works for me. Does it work for you?

0001-main-Don-t-forget-to-parse-ip-version-21.patch.gz

ruedigerkupper commented 5 years ago

No success, same error.

ruedigerkupper commented 5 years ago

(even if I change the default to v6)

leamas commented 5 years ago

This is, as they say, odd. When I apply this patch I can confirm that the value in ~/.config/ddupdate.conf is parsed.

Adding a new patch with a simple log statement. Can you check the value of ip-version printed after applying patch?

0001-main-Temporary-logging.patch.gz

ruedigerkupper commented 5 years ago

Hi! Sorry, I was referring to your original patch and missed that you had revised it. Indeed, your revised patch solves the issue! Great work, thanks a lot for helping out so quickly!

leamas commented 5 years ago

Fixed in [2ff7c32]. Thanks for reporting!