|
| 1 | +# Duck DNS |
| 2 | + |
| 3 | +Duckdns is a free public DNS service that provides you with a domain name you |
| 4 | +can update to match your dynamic IP-address. |
| 5 | + |
| 6 | +This container automates the process to keep the duckdns.org domain updated |
| 7 | +when your IP-address changes. |
| 8 | + |
| 9 | +## Configuration |
| 10 | + |
| 11 | +First, register an account, add your subdomain and get your token from |
| 12 | +[http://www.duckdns.org/](http://www.duckdns.org/) |
| 13 | + |
| 14 | +Either edit `~/IOTstack/docker-compose.yml` or create a file |
| 15 | +`~/IOTstack/docker-compose.override.yml`. Place your Duckdns token and |
| 16 | +subdomain name (without .duckdns.org) there: |
| 17 | + |
| 18 | +``` yaml title="docker-compose.override.yml" |
| 19 | +version: '3.6' |
| 20 | +services: |
| 21 | + duckdns: |
| 22 | + environment: |
| 23 | + TOKEN: your-duckdns-token |
| 24 | + SUBDOMAINS: subdomain |
| 25 | +``` |
| 26 | +
|
| 27 | +Observe that at least the initial update is successful: |
| 28 | +
|
| 29 | +``` console |
| 30 | +$ cd ~/IOTstack |
| 31 | +$ docker-compose up -d duckdns |
| 32 | +$ docker-compose logs -f duckdns |
| 33 | +...SNIP... |
| 34 | +duckdns | Sat May 21 11:01:00 UTC 2022: Your IP was updated |
| 35 | +...SNIP... |
| 36 | +(ctrl-c to stop following the log) |
| 37 | +``` |
| 38 | + |
| 39 | +If there is a problem, check that the resulting effective configuration of |
| 40 | +'duckdns:' looks OK: |
| 41 | +``` console |
| 42 | +$ cd ~/IOTstack && docker-compose config |
| 43 | +``` |
| 44 | + |
| 45 | +### Domain name for the private IP |
| 46 | + |
| 47 | +!!! note inline end "Example public/private IP:s and domains" |
| 48 | + |
| 49 | + ``` mermaid |
| 50 | + flowchart |
| 51 | + I([Internet]) |
| 52 | + G("Router\npublic IP: 52.85.51.71\nsubdomain.duckdns.org") |
| 53 | + R(Raspberry pi\nprivate IP: 192.168.0.100\nprivate_subdomain.duckdns.org) |
| 54 | + I --- |ISP| G --- |LAN| R |
| 55 | + ``` |
| 56 | + |
| 57 | +As a public DNS server, Duckdns is not meant to be used for private IPs. It's |
| 58 | +recommended that for resolving internal LAN IPs you use the [Pi |
| 59 | +Hole](Pi-hole.md) container or run a dedicated DNS server. |
| 60 | + |
| 61 | +That said, it's possible to update a Duckdns subdomain to your private LAN IP. |
| 62 | +This may be convenient if you have devices that don't support mDNS (.local) or |
| 63 | +don't want to run Pi-hole. This is especially useful if you can't assign a |
| 64 | +static IP to your RPi. No changes to your DNS resolver settings are needed. |
| 65 | + |
| 66 | +First, as for the public subdomain, add the domain name to your Duckdns account |
| 67 | +by logging in from their homepage. Then add a `PRIVATE_SUBDOMAINS` variable |
| 68 | +indicating this subdomain: |
| 69 | + |
| 70 | +``` yaml |
| 71 | +version: '3.6' |
| 72 | +services: |
| 73 | + duckdns: |
| 74 | + environment: |
| 75 | + TOKEN: ... |
| 76 | + SUBDOMAINS: ... |
| 77 | + PRIVATE_SUBDOMAINS: private_subdomain |
| 78 | +``` |
| 79 | +
|
| 80 | +## References |
| 81 | +
|
| 82 | +* uses ukkopahis' [fork](https://github.com/ukkopahis/docker-duckdns) based on |
| 83 | + the linuxserver |
| 84 | + [docker-duckdns](https://github.com/linuxserver/docker-duckdns) container |
0 commit comments