update-api.rst 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. .. _update-api:
  2. IP Update API
  3. ~~~~~~~~~~~~~
  4. In case you want to dig deeper, here are the details on how our IP update API
  5. works. We provide this API to be compatible with
  6. most dynDNS clients. However, we also provide a RESTful API that is
  7. more powerful and always preferred over the legacy interface described here.
  8. Please note that when using HTTPS (which we highly recommend), outdated setups
  9. (such as TLS < 1.2) are not supported. If you encounter SSL/TLS handshake
  10. issues, you may have to update your dynDNS client and/or libraries used by it
  11. (such as OpenSSL).
  12. **Note:** Out of mercy for legacy clients (especially old routers), we still
  13. accept unencrypted requests for this service. We **urge** you to **use HTTPS
  14. whenever possible**.
  15. Update Request
  16. ``````````````
  17. An IP update is performed by sending a ``GET`` request to ``update.dedyn.io``
  18. via IPv4 or IPv6. To enforce IPv6, use ``update6.dedyn.io``. The path
  19. component can be chosen freely as long as it does not end in ``.ico`` or
  20. ``.png``. HTTPS is recommended over HTTP.
  21. When the request is authenticated successfully, we use the connection IP
  22. address and query parameters to update your domain's DNS ``A`` (IPv4) and
  23. ``AAAA`` (IPv6) records. The new records will have a TTL value of 60 seconds
  24. (that is, outdated values should disappear from DNS resolvers within that
  25. time).
  26. .. _update-api-authentication:
  27. IP Update Authentication
  28. ************************
  29. You can authenticate your client in several ways. If authentication fails, the
  30. API will return a ``401 Unauthorized`` status code.
  31. Preferred method: HTTP Basic Authentication (with token)
  32. --------------------------------------------------------
  33. Encode your username and token secret (provided during registration) in the
  34. ``Authorization: Basic ...`` header. This is the method virtually all dynDNS
  35. clients use out of the box.
  36. **Important:** If your dynDNS client asks for a *password*, do not enter your
  37. account password (if you have one). Instead, enter your token!
  38. HTTP Token Authentication
  39. ------------------------------------------
  40. Send an ``Authorization: Token ...`` header along with your request, where
  41. ``...`` is the token secret issued at registration (or manually created later).
  42. Query string method (discouraged)
  43. ---------------------------------
  44. Set the ``username`` and ``password`` query string parameters (``GET
  45. ?username=...&password=...``).
  46. **Important:** We **strongly discourage** using this method as it comes with a
  47. subtle disadvantage: We log all HTTP request URLs for a few days to facilitate
  48. debugging. As a consequence, this method will cause your token secret to end
  49. up in our log files in clear text. The method is provided as an emergency
  50. solution where folks need to deal with old and/or crappy clients. If this is
  51. the case, we suggest looking for another client.
  52. Determine Hostname
  53. ******************
  54. To update your IP address in the DNS, our servers need to determine the
  55. hostname you want to update. To determine the hostname, we try the following
  56. steps until there is a match:
  57. - ``hostname`` query string parameter, unless it is set to ``YES`` (this
  58. sometimes happens with dynDNS update clients).
  59. - ``host_id`` query string parameter.
  60. - The username as provided in the HTTP Basic Authorization header.
  61. - The username as provided in the ``username`` query string parameter.
  62. - After successful authentication (no matter how), the only hostname that is
  63. associated with your user account (if not ambiguous).
  64. If we cannot determine a hostname to update, the API returns a status code of
  65. ``400 Bad Request`` (if no hostname was given but multiple domains exist in
  66. the account) or ``404 Not Found`` (if the specified domain was not found).
  67. Subdomains
  68. ----------
  69. The dynDNS update API can also be used to update IP records for subdomains.
  70. To do so, make sure that in the above list of steps, the first value
  71. provided contains the full domain name (including the subdomain).
  72. Example: Your domain is ``yourdomain.dedyn.io``, and you're using HTTP Basic
  73. Authentication. In this case, replace your authentication username with
  74. ``sub.yourdomain.dedyn.io``. Similarly, if you use the ``hostname`` query
  75. parameter, it needs to be set to the full domain name (including subdomain).
  76. To update more than one domain name, please see
  77. :ref:`updating-multiple-dyn-domains`.
  78. .. _determine-ip-addresses:
  79. Determine IP Address(es)
  80. ************************
  81. The last ingredient we need for a successful update of your DNS records is your
  82. IPv4 and/or IPv6 addresses, for storage in the ``A`` and ``AAAA`` records,
  83. respectively.
  84. For IPv4, we check the query string parameters ``myip``, ``myipv4``, ``ip``
  85. (in this order) for IPv4 addresses to record in the database.
  86. Multiple IP addresses may be given as a comma-separated list.
  87. When the special string ``preserve`` is provided instead, the configuration
  88. on record (if any) will be kept as is.
  89. If none of the parameters is set, the connection's client IP address will be
  90. used if it is an IPv4 connection; otherwise the IPv4 address will be deleted
  91. from the DNS.
  92. IP deletion can also be forced by providing an empty value (e.g. ``myipv4=``).
  93. For IPv6, the procedure is similar.
  94. We check the ``myipv6``, ``ipv6``, ``myip``, ``ip`` query string parameters
  95. (in this order) and the IP that was used to connect to the API for IPv6
  96. addresses and use the first one found.
  97. Both the multi-IP syntax and the ``preserve`` rule apply as above.
  98. If nothing is found or an empty value provided, the ``AAAA`` record will be
  99. deleted.
  100. When using the ``myip`` parameter, a mixed-type list of both IPv4 and IPv6
  101. addresses may be given.
  102. Update Response
  103. ```````````````
  104. If successful, the server will return a response with status ``200 OK`` and
  105. ``good`` as the body (as per the dyndns2 protocol specification). For error
  106. status codes, see above.
  107. dynDNS updates are subject to rate limiting. For details, see
  108. :ref:`rate-limits`.
  109. Examples
  110. ````````
  111. The examples below use ``<your domain>`` as the domain which is to be updated
  112. (which could be a custom domain or a dedyn.io domain like
  113. ``yourdomain.dedyn.io``) and ``<your authorization token>`` as an API token
  114. affiliated with the respective account (see :ref:`manage-tokens` for details.)
  115. ``1.2.3.4`` is used as an example for an IPv4 address, ``fd08::1234`` as a
  116. stand-in for an IPv6 address. Replace those (including the ``<`` and ``>``)
  117. with your respective values.
  118. Basic authentication with automatic IP detection (IPv4 **or** IPv6)::
  119. curl --user <your domain>:<your token secret> https://update.dedyn.io/
  120. curl https://update.dedyn.io/?hostname=<your domain> \
  121. --header "Authorization: Token <your token secret>"
  122. Basic authentication with forced use of IPv6 (will remove IPv4 address from the DNS)::
  123. curl --user <your domain>:<your token secret> https://update6.dedyn.io/
  124. curl https://update6.dedyn.io/?hostname=<your domain> \
  125. --header "Authorization: Token <your token secret>"
  126. Basic authentication with simultaneous update of IPv4 and IPv6::
  127. curl --user <your domain>:<your token secret> \
  128. "https://update.dedyn.io/?myipv4=1.2.3.4&myipv6=fd08::1234"
  129. curl "https://update6.dedyn.io/?hostname=<your domain>?myipv4=1.2.3.4&myipv6=fd08::1234" \
  130. --header "Authorization: Token <your token secret>"