Dynamic DNS

The Mythic Beasts DNS API makes it very easy to implement dynamic DNS — a system for updating a DNS entry for a host that regularly changes its IP address.

The API provides a URL that will detect the IP address of the client and use that to set a DNS record.

API credentials

In order to use the DNS API for dynamic DNS, you will need to create some API credentials. This can be done using the API keys page in the control panel.

It is recommended that you create credentials that only have access to the hostname that you want to update. The screenshot below shows how to create an API key with access to A and AAAA records for myhost.example.com.

Making requests

To update the IP address for the record shown above, make a request to:

  • https://ipv4.api.mythic-beasts.com/dns/v2/dynamic/myhost.example.com

We suggest making a POST request, but GET or PUT requests will work too.

Providing credentials

The username and password for your API key can be provided as parameters to the request, called username and password respectively.

For example, if you are using curl, you can make the following request:

curl https://ipv4.api.mythic-beasts.com/dns/v2/dynamic/myhost.example.com -d username=KEYID -d password=SECRET

Using query paramaters

If you are using a dynamic DNS client that requires the username and password to be embedded in the URL, you can use query parameters:

  • https://ipv4.api.mythic-beasts.com/dns/v2/dynamic/myhost.example.com?username=KEYID&password=SECRET

Using HTTP basic auth

If you are using curl, we recommend using HTTP basic authentication, and putting the credentials in a .netrc file. For example, create a .netrc file in your home directory containing:

machine ipv4.api.mythic-beasts.com
login KEYID
password SECRET

You can now use the -n option to curl to use these credentials:

curl -n -X POST https://ipv4.api.mythic-beasts.com/dns/v2/dynamic/myhost.example.com

IPv4 vs IPv6

The above examples use an IPv4-only URL to access the API. This ensures that the API detects your IPv4 address if you have both v4 and v6 addresses, and will create or update an A record.

If you want to update a record based on your IPv6 address, simply use ipv6.api.mythic-beasts.com as the API hostname. This will create or update an AAAA record.