Commit 36b5ec4ece
Unsigned
Layout: unified · split
content/blog/2024-03-15-self-hosting-ddns-updater.md +43 −18
| @@ -4,19 +4,25 @@ title = "Self-Hosting DDNS Updater" | ||
| 4 | 4 | description = "A guide to self-hosting the DDNS Updater container." |
| 5 | 5 | +++ |
| 6 | 6 | |
| 7 |  | |
| 7 |  | |
| 8 | 9 | |
| 9 | [DDNS Updater](https://github.com/qdm12/ddns-updater) is a program to keep DNS A and/or AAAA records updated for multiple DNS providers. | |
| 10 | [DDNS Updater](https://github.com/qdm12/ddns-updater) is a program to keep DNS A | |
| 11 | and/or AAAA records updated for multiple DNS providers. | |
| 10 | 12 | |
| 11 | If you've read any of my other posts, you'll notice that I have been searching for and using a few different DDNS updating solutions for years. You'll also notice that I love any projects that offer a Docker Compose solution. | |
| 13 | If you've read any of my other posts, you'll notice that I have been searching | |
| 14 | for and using a few different DDNS updating solutions for years. You'll also | |
| 15 | notice that I love any projects that offer a Docker Compose solution. | |
| 12 | 16 | |
| 13 | 17 | Luckily, DDNS Upater fits both of these preferences. |
| 14 | 18 | |
| 15 | 19 | ## Installation |
| 16 | 20 | |
| 17 | To get started, always make sure to review the project's [README](https://github.com/qdm12/ddns-updater/blob/master/README.md). I'll be documenting my steps below, but they may have changed by the time you read this. | |
| 21 | To get started, always make sure to review the project's | |
| 22 | [README](https://github.com/qdm12/ddns-updater/blob/master/README.md). I'll be | |
| 23 | documenting my steps below, but they may have changed by the time you read this. | |
| 18 | 24 | |
| 19 | The first step is to set up the directories and files required for the project. | |
| 25 | The first step is to set up the directories and files required for the project. | |
| 20 | 26 | |
| 21 | 27 | ```sh |
| 22 | 28 | mkdir ~/ddns-updater |
| @@ -26,7 +32,9 @@ touch ~/ddns-updater/data/config.json | ||
| 26 | 32 | |
| 27 | 33 | ### Configuration |
| 28 | 34 | |
| 29 | The main configuration you need to update is the `data/config.json` file. There is a large list of supported providers in the README, but I'm going to use Cloudflare in this example. | |
| 35 | The main configuration you need to update is the `data/config.json` file. There | |
| 36 | is a large list of supported providers in the README, but I'm going to use | |
| 37 | Cloudflare in this example. | |
| 30 | 38 | |
| 31 | 39 | ```sh |
| 32 | 40 | nano ~/ddns-updater/data/config.json |
| @@ -35,17 +43,27 @@ nano ~/ddns-updater/data/config.json | ||
| 35 | 43 | When setting up the configuration for Cloudflare, you'll need the following: |
| 36 | 44 | |
| 37 | 45 | - Required Parameters |
| 38 | - `"zone_identifier"` is the Zone ID of your site from the domain overview page | |
| 39 | - `"host"` is your host and can be `"@"`, a subdomain or the wildcard `"*"`. See [this issue comment for context](https://github.com/qdm12/ddns-updater/issues/243#issuecomment-928313949). | |
| 46 | - `"zone_identifier"` is the Zone ID of your site from the domain overview | |
| 47 | page | |
| 48 | - `"host"` is your host and can be `"@"`, a subdomain or the wildcard `"*"`. | |
| 49 | See [this issue comment for | |
| 50 | context](https://github.com/qdm12/ddns-updater/issues/243#issuecomment-928313949). | |
| 40 | 51 | - `"ttl"` integer value for record TTL in seconds (specify 1 for automatic) |
| 41 | - One of the following ([how to find API keys](https://developers.cloudflare.com/fundamentals/api/get-started/)): | |
| 52 | - One of the following ([how to find API | |
| 53 | keys](https://developers.cloudflare.com/fundamentals/api/get-started/)): | |
| 42 | 54 | - Email `"email"` and Global API Key `"key"` |
| 43 | 55 | - User service key `"user_service_key"` |
| 44 | - API Token `"token"`, configured with DNS edit permissions for your DNS name's zone | |
| 56 | - API Token `"token"`, configured with DNS edit permissions for your DNS | |
| 57 | name's zone | |
| 45 | 58 | - Optional Parameters |
| 46 | 59 | - `"proxied"` can be set to `true` to use the proxy services of Cloudflare |
| 47 | - `"ip_version"` can be `ipv4` (A records), or `ipv6` (AAAA records) or `ipv4 or ipv6` (update one of the two, depending on the public ip found). It defaults to `ipv4 or ipv6`. | |
| 48 | - `"ipv6_suffix"` is the IPv6 interface identifier suffix to use. It can be for example `0:0:0:0:72ad:8fbb:a54e:bedd/64`. If left empty, it defaults to no suffix and the raw public IPv6 address obtained is used in the record updating. | |
| 60 | - `"ip_version"` can be `ipv4` (A records), or `ipv6` (AAAA records) or `ipv4 | |
| 61 | or ipv6` (update one of the two, depending on the public ip found). It | |
| 62 | defaults to `ipv4 or ipv6`. | |
| 63 | - `"ipv6_suffix"` is the IPv6 interface identifier suffix to use. It can be | |
| 64 | for example `0:0:0:0:72ad:8fbb:a54e:bedd/64`. If left empty, it defaults to | |
| 65 | no suffix and the raw public IPv6 address obtained is used in the record | |
| 66 | updating. | |
| 49 | 67 | |
| 50 | 68 | ```conf |
| 51 | 69 | { |
| @@ -65,7 +83,8 @@ When setting up the configuration for Cloudflare, you'll need the following: | ||
| 65 | 83 | } |
| 66 | 84 | ``` |
| 67 | 85 | |
| 68 | Once you have configured the provider of your choice, correct the file and directory permissions and ownership. | |
| 86 | Once you have configured the provider of your choice, correct the file and | |
| 87 | directory permissions and ownership. | |
| 69 | 88 | |
| 70 | 89 | ```sh |
| 71 | 90 | cd ~/ddns_updater |
| @@ -79,7 +98,8 @@ chmod 400 data/config.json | ||
| 79 | 98 | |
| 80 | 99 | ### Docker Compose |
| 81 | 100 | |
| 82 | After creating the project structure, let's create the `docker-compose.yml` file. | |
| 101 | After creating the project structure, let's create the `docker-compose.yml` | |
| 102 | file. | |
| 83 | 103 | |
| 84 | 104 | ```sh |
| 85 | 105 | nano ~/ddns_-pdater/docker-compose.yml |
| @@ -123,18 +143,22 @@ services: | ||
| 123 | 143 | restart: always |
| 124 | 144 | ``` |
| 125 | 145 | |
| 126 | After configuring your preferences in the `docker-compose.yml`, launch the container. | |
| 146 | After configuring your preferences in the `docker-compose.yml`, launch the | |
| 147 | container. | |
| 127 | 148 | |
| 128 | 149 | ```sh |
| 129 | 150 | cd ~/ddns-updater |
| 130 | 151 | sudo docker-compose up -d |
| 131 | 152 | ``` |
| 132 | 153 | |
| 133 | If you've launched this on your local machine, you can launch `localhost:8097` in your browser to see the results. | |
| 154 | If you've launched this on your local machine, you can launch `localhost:8097` | |
| 155 | in your browser to see the results. | |
| 134 | 156 | |
| 135 | 157 | ### Nginx Reverse Proxy |
| 136 | 158 | |
| 137 | If you launched this service on a server, other machine, or just want to access it remotely via a domain name, you can use Nginx as a reverse proxy to expose the service publicly. | |
| 159 | If you launched this service on a server, other machine, or just want to access | |
| 160 | it remotely via a domain name, you can use Nginx as a reverse proxy to expose | |
| 161 | the service publicly. | |
| 138 | 162 | |
| 139 | 163 | Start by creating the Nginx configuration file. |
| 140 | 164 | |
| @@ -162,7 +186,8 @@ server { | ||
| 162 | 186 | } |
| 163 | 187 | ``` |
| 164 | 188 | |
| 165 | Here's a full example that uses my Authelia authentication service to require authentication before someone can access the web page. | |
| 189 | Here's a full example that uses my Authelia authentication service to require | |
| 190 | authentication before someone can access the web page. | |
| 166 | 191 | |
| 167 | 192 | ```conf |
| 168 | 193 | server { |