update-api.rst 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 (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 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 secret token 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. .. _determine-ip-addresses:
  77. Determine IP addresses
  78. **********************
  79. The last ingredient we need for a successful update of your DNS records is your
  80. IPv4 and/or IPv6 addresses, for storage in the ``A`` and ``AAAA`` records,
  81. respectively.
  82. For IPv4, we will use the first IPv4 address it can find in the query string
  83. parameters ``myip``, ``myipv4``, ``ip`` (in this order). If none of them is
  84. set, it will use the IP that connected to the API, if a IPv4 connection was
  85. made. If no address is found or if an empty value was provided instead of an IP
  86. address, the ``A`` record will be deleted from the DNS.
  87. For IPv6, the procedure is similar. We check ``myipv6``, ``ipv6``, ``myip``,
  88. ``ip`` query string parameters (in this order) and the IP that was used to
  89. connect to the API for IPv6 addresses and use the first one found. If no
  90. address is found or an empty value provided instead, the ``AAAA`` record will
  91. be deleted.
  92. Update Response
  93. ```````````````
  94. If successful, the server will return a response with status ``200 OK`` and
  95. ``good`` as the body (as per the dyndns2 protocol specification). For error
  96. status codes, see above.
  97. dynDNS updates are subject to rate limiting. For details, see
  98. :ref:`rate-limits`.
  99. Examples
  100. ````````
  101. The examples below use ``<your domain>`` as the domain which is to be updated
  102. (which could be a custom domain or a dedyn.io domain like
  103. ``yourdomain.dedyn.io``) and ``<your authorization token>`` as an API token
  104. affiliated with the respective account (see :ref:`manage-tokens` for details.)
  105. ``1.2.3.4`` is used as an example for an IPv4 address, ``fd08::1234`` as a
  106. stand-in for an IPv6 address. Replace those (including the ``<`` and ``>``)
  107. with your respective values.
  108. Basic authentication with automatic IP detection (IPv4 **or** IPv6)::
  109. curl --user <your domain>:<your authorization token> https://update.dedyn.io/
  110. curl https://update.dedyn.io/?hostname=<your domain> \
  111. --header "Authorization: Token <your authorization token>"
  112. Basic authentication with forced use of IPv6 (will remove IPv4 address from the DNS)::
  113. curl --user <your domain>:<your authorization token> https://update6.dedyn.io/
  114. curl https://update6.dedyn.io/?hostname=<your domain> \
  115. --header "Authorization: Token <your authorization token>"
  116. Basic authentication with simultaneous update of IPv4 and IPv6::
  117. curl --user <your domain>:<your authorization token> \
  118. "https://update.dedyn.io/?myipv4=1.2.3.4&myipv6=fd08::1234"
  119. curl "https://update6.dedyn.io/?hostname=<your domain>?myipv4=1.2.3.4&myipv6=fd08::1234" \
  120. --header "Authorization: Token <your authorization token>"