update-api.rst 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. IP Update API
  2. ~~~~~~~~~~~~~
  3. In case you want to dig deeper, here are the details on how our IP update API
  4. works. We provide this API to be compatible with
  5. most dynDNS clients. However, we also provide a RESTful API that is
  6. more powerful and always preferred over the legacy interface described here.
  7. Please note that when using HTTPS (which we highly recommend), outdated setups
  8. (such as TLS < 1.2) are not supported. If you encounter SSL/TLS handshake
  9. issues, you may have to update your dynDNS client and/or libraries used by it
  10. (such as OpenSSL).
  11. Update Request
  12. ``````````````
  13. An IP updates is performed by sending a GET request to ``update.dedyn.io`` via
  14. HTTP or HTTPS. The path component can be chosen freely as long as it does not
  15. end in ``.ico`` or ``.png``.
  16. You can connect via IPv4 or IPv6. To enforce IPv6, use ``update6.dedyn.io``.
  17. Please be aware that while we still accept unencrypted requests, we **urge**
  18. you to use HTTPS. For that reason, we also send an HSTS header on HTTPS
  19. connections.
  20. .. _update-api-authentication:
  21. IP Update Authentication
  22. ************************
  23. You can authenticate your client in several ways. If authentication fails, the
  24. API will return a ``401 Unauthorized`` status code.
  25. Preferred method: HTTP Basic Authentication (with token)
  26. --------------------------------------------------------
  27. Encode your username and token (provided during registration) in the
  28. ``Authorization: Basic ...`` header. This is the method virtually all dynDNS
  29. clients use out of the box.
  30. **Important:** If you dynDNS client asks for a *password*, do not enter your
  31. account password (if you have one). Instead, enter your token!
  32. HTTP Token Authentication
  33. ------------------------------------------
  34. Send an ``Authorization: Token ...`` header along with your request, where
  35. ``...`` is the token issued at registration (or manually created later).
  36. Query string method (discouraged)
  37. ---------------------------------
  38. Set the ``username`` and ``password`` query string parameters (``GET
  39. ?username=...&password=...``).
  40. **Important:** We **strongly discourage** using this method as it comes with a
  41. subtle disadvantage: We log all HTTP request URLs for a few days to facilitate
  42. debugging. As a consequence, this method will cause your secret token to end
  43. up in our log files in clear text. The method is provided as an emergency
  44. solution where folks need to deal with old and/or crappy clients. If this is
  45. the case, we suggest looking for another client.
  46. Determine Hostname
  47. ******************
  48. To update your IP address in the DNS, our servers need to determine the
  49. hostname you want to update (it's possible to set up several domains). To
  50. determine the hostname, we try the following steps until there is a match:
  51. - ``hostname`` query string parameter, unless it is set to ``YES`` (this
  52. sometimes happens with dynDNS update clients).
  53. - ``host_id`` query string parameter.
  54. - The username as provided in the HTTP Basic Authorization header.
  55. - The username as provided in the ``username`` query string parameter.
  56. - After successful authentication (no matter how), the only hostname that is
  57. associated with your user account (if not ambiguous).
  58. If we cannot determine a hostname to update, the API will return a ``404 Not
  59. Found`` status code. If the selected hostname is not eligible for dynamic
  60. updates, we will return ``403 Forbidden``. This usually happens if you try
  61. updating a hostname that is not under the ``dedyn.io`` domain. If you are
  62. affected by this and would like to use another domain, please contact support.
  63. .. _determine-ip-addresses:
  64. Determine IP addresses
  65. **********************
  66. The last ingredient we need for a successful update of your DNS records is your
  67. IPv4 and/or IPv6 addresses, for storage in the ``A`` and ``AAAA`` records,
  68. respectively.
  69. For IPv4, we will use the first IPv4 address it can find in the query string
  70. parameters ``myip``, ``myipv4``, ``ip`` (in this order). If none of them is
  71. set, it will use the IP that connected to the API, if a IPv4 connection was
  72. made. If no address is found or if an empty value was provided instead of an IP
  73. address, the ``A`` record will be deleted from the DNS.
  74. For IPv6, the procedure is similar. We check ``myipv6``, ``ipv6``, ``myip``,
  75. ``ip`` query string parameters (in this order) and the IP that was used to
  76. connect to the API for IPv6 addresses and use the first one found. If no
  77. address is found or an empty value provided instead, the ``AAAA`` record will
  78. be deleted.
  79. Update Response
  80. ```````````````
  81. If successful, the server will return a response with status ``200 OK`` and
  82. ``good`` as the body (as per the dyndns2 protocol specification). For error
  83. status codes, see above.
  84. dynDNS updates are subject to rate limiting. For details, see
  85. :ref:`rate-limits`.
  86. Examples
  87. ````````
  88. The examples below use ``<your domain>.dedyn.io`` as the domain which is to be updated and
  89. ``<your authorization token>`` as an API token affiliated with the respective account.
  90. (See :ref:`manage-tokens` for details.) ``<1.2.3.4>`` is used as an example for an IPv4 Address,
  91. ``<fd08::1234>`` as a standin for an IPv6 address. Replace those (including the ``<`` and ``>``)
  92. with your respective values.
  93. Basic authentication with automatic IP detection (IPv4 **or** IPv6)::
  94. curl --user <your domain>.dedyn.io:<your authorization token> https://update.dedyn.io/
  95. curl https://update.dedyn.io/?hostname=<your domain>.dedyn.io \
  96. --header "Authorization: Token <your authorization token>"
  97. Basic authentication with forced use of IPv6 (will remove IPv4 address from the DNS)::
  98. curl --user <your domain>.dedyn.io:<your authorization token> https://update6.dedyn.io/
  99. curl https://update6.dedyn.io/?hostname=<your domain>.dedyn.io \
  100. --header "Authorization: Token <your authorization token>"
  101. Basic authentication with simultaneous update of IPv4 and IPv6::
  102. curl --user <your domain>.dedyn.io:<your authorization token> \
  103. "https://update.dedyn.io/?myipv4=1.2.3.4&myipv6=fd08::1234"
  104. curl "https://update6.dedyn.io/?hostname=<your domain>.dedyn.io?myipv4=1.2.3.4&myipv6=fd08::1234" \
  105. --header "Authorization: Token <your authorization token>"