It's common for Internet service providers (ISPs) to rotate the IP addresses assigned to a specific household. If you run devices or services at home that need to point to an IP address, such as smart home systems or running your own servers, this means that you would need to update them every time your IP address changes. Dynamic DNS aims to solve this issue by automatically updating the domain's DNS record whenever your IP address changes.
Fastmail offers Dynamic DNS for customers who have a custom domain with the DNS hosted at Fastmail.
How to set up Dynamic DNS in Fastmail
Please note that you will need admin access in order to make the necessary changes.
Step 1: Create an API token
The first step is to create an API token. For general information about API tokens, please see our help page here.
You can create the API token by following these steps:
- Log in to the Fastmail web interface and go to the Settings → Privacy & Security screen.
- Find the Connected apps & API tokens section. Click Manage API tokens.
- Click New API token.
- A Verify it's you box may appear. Enter your password and click Continue. (For more information, see our Password-protected actions help page.)
- Enter a name to identify this API token. (Make sure it's something you will be able to read and understand in the future, in case you need to review or revoke access.)
- In the Type section, select Dynamic DNS. (This option will not appear if your Fastmail account does not have a custom domain.)
- Click Generate API token.
The next page will display your new API token. Copy and paste the token into a safe place before you click the Done button in your Fastmail settings, as you will not be able to see it again.
Step 2: Create a Dynamic DNS entry
Next, you will need to create a Dynamic DNS entry for your domain.
- Go to the Settings → Domains screen and click the domain.
- In the DNS section, click Customise DNS.
- Scroll down to the end of the screen, where you will see a blank DNS entry. Under Type, change the type to Dynamic DNS.
- Under Domain, enter the desired subdomain.
- Click Add to add the DNS record. Be sure to click Save.
Step 3: Update your Dynamic DNS client (DynDNS2)
The final step will be to update your Dynamic DNS client by pointing it to us:
https://api.fastmail.com/dynamicdns/update
Exact steps will vary based on the client you're using. Please refer to the documentation for your client if this information is needed.
We support the common DynDNS2 API for both A and AAAA records. This can be automated with a tool like ddclient.
DynDNS2 uses HTTP Basic authentication, with your regular Fastmail username as the username and the API token as the password.
As an example, this is what a working config for ddclient 3.10 would look like:
# /etc/ddclient.conf ssl=yes protocol=dyndns2 server=api.fastmail.com login=hannah_martin@teachdev.io password=******** home.teachdev.io
ssl=yes is required to prevent sending credentials in plaintext. Keep the config owned by root and with permissions set to 600.
You can use the following table as a reference for how each myip and myipv6 combination updates your A and AAAA records.
| Request | Result |
|---|---|
myip=<ipv4> |
Sets A, whatever family the connection is |
myipv6=<ipv6> |
Sets AAAA, whatever family the connection is |
myip= over IPv4 |
Sets A from source_ip
|
myip= over IPv6 |
badip |
myipv6= over IPv6 |
Sets AAAA from source_ip
|
myipv6= over IPv4 |
badip |
myip= and myipv6=
|
badip one family can never resolve |
myip omitted |
A preserved |
myipv6 omitted |
AAAA preserved |
| both omitted |
source_ip sets whichever family it belongs to |
Alternate simple API for crontab
We also offer a simple API, so self-hosters can automate updates with a cron job:
https://api.fastmail.com/dynamicdns/simple/<domain>/<token>/
Be sure to replace <domain> with the domain from the Dynamic DNS entry you created in Step 2, and replace <token> with your API token from Step 1. No username is needed.
If you prefer to explicitly set the IP address, you can do so:
https://api.fastmail.com/dynamicdns/simple/<domain>/<token>/<ip-address>
Be sure to replace <ip-address> with your IP address. This can be done with IPv4 or IPv6.
With this API, the response body is always empty. The result is carried in the status code:
-
204: the record is set, whether or not it changed. -
400: we couldn’t parse the hostname or the address. -
401: the token is wrong. -
404: that name has no Dynamic DNS record.