> For the complete documentation index, see [llms.txt](https://www.trentbauer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.trentbauer.com/guides/other-guides/cloudflare/dynamic-dns.md).

# Dynamic DNS

<table data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td>Time Required</td><td>5 Minutes</td></tr><tr><td>Difficulty</td><td>Easy</td></tr><tr><td>Required Knowledge</td><td>DNS, Cloudflare, Docker</td></tr></tbody></table>

If you have a dynamic DNS (your IP address changes), you can use a container to keep it in-sync with Cloudflare.

{% hint style="warning" %}
I would recommend against this unless there is a very specific use-case, eg a port forward for Plex or [game servers](/guides/installation-guides/pterodactyl/creating-a-new-wings-node.md#port-forward). It is best practice to hide as much information as you can behind Cloudflare, as any attacks security risks can be mitigated by them.

If you are using NGIX proxy manager or something else similar, you should still be able to run those through a [Zero Trust tunnel](/guides/other-guides/cloudflare/cloudflare-zero-trust.md)
{% endhint %}

## Prerequisites

* Domain managed by Cloudflare

## API key

First you will need to generate an API key with write access to your domain/s DNS.

1. Navigate to <https://dash.cloudflare.com/profile/api-tokens>
2. At API tokens, click on 'Create Token'
3. Select the 'Edit zone DNS' and set the below
   1. Give your token a name, eg "DDNS"

   2. Permissions:

      |      |     |      |
      | ---- | --- | ---- |
      | Zone | DNS | Edit |

   3. Zone Resources:

      |         |                                        |
      | ------- | -------------------------------------- |
      | Include | All Zones (or select specific domains) |
4. Click on 'Continue to Summary'
5. Click on 'Create token'
6. Save your API key to your password vault

## DDNS Container

### Deploy your Docker stack

You can use the below compose file,

{% @github-files/github-code-block url="<https://github.com/trentnbauer/Homelab/blob/main/docker-compose/ddns.yml>" %}

{% code title=".env" %}

```
$CLOUDFLARE_APIKEY=
$DOMAINS=
$PROXIED=false
```

{% endcode %}
