update-api.rst 7.5 KB

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