# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.trentbauer.com/guides/other-guides/cloudflare/dynamic-dns.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
