Skip to content

Commit

Permalink
duckdns: add service
Browse files Browse the repository at this point in the history
This container includes cron and should be easier to use than the
current duck.sh script. After a test period this should completely
replace the current ./duck/duck.sh script.

Currently uses my fork of linuxserver/docker-duckdns to include
some needed pull-requests that are pending upstream pull-requests.

Depends on SensorsIot#553 to generate .env with IOTSTACK_UID and IOTSTACK_GID

Mkdocs and material versions updated to fix layout bug.
  • Loading branch information
ukkopahis committed May 18, 2022
1 parent 732889a commit 5f9e044
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 7 deletions.
10 changes: 10 additions & 0 deletions .templates/duckdns/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
duckdns:
container_name: duckdns
build: https://github.com/ukkopahis/docker-duckdns.git
network_mode: host
restart: unless-stopped
environment:
PUID: ${IOTSTACK_UID:?IOTSTACK_GID must be defined in ~/IOTstack/.env}
PGID: ${IOTSTACK_GID:?IOTSTACK_GID must be defined in ~/IOTstack/.env}
#TOKEN: define this in docker-compose.override.yml, see docs
#SUBDOMAIN: define this in docker-compose.override.yml, see docs
19 changes: 16 additions & 3 deletions docs/Basic_setup/Accessing-your-Device-from-the-internet.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,24 @@ If you have the choice, your router is to be preferred. That's because your rout

Nevertheless, your router may not support the Dynamic DNS service provider you wish to use, or may come with constraints that you find unsatisfactory so any behind-the-router technique is always a viable option, providing you understand its limitations.

A behind-the-router technique usually relies on sending updates according to a schedule. An example is a `cron` job that runs every five minutes. That means any router WAN IP address changes won't be propagated until the next scheduled update. In the event of network interruptions or service provider outages, it may take some time before everything is back in sync. Moreover, given that WAN IP address changes are infrequent events, most scheduled updates will be sending information unnecessarily, contributing unnecessarily to server load.
A behind-the-router technique usually relies on sending updates according to a schedule. An example is a `cron` job that runs every five minutes. That means any router WAN IP address changes won't be propagated until the next scheduled update. In the event of network interruptions or service provider outages, it may take close to ten minutes before everything is back in sync. Moreover, given that WAN IP address changes are infrequent events, most scheduled updates will be sending information unnecessarily.

> This seems to be a problem for DuckDNS which takes a beating because almost every person using it is sending an update bang-on five minutes.
### DuckDNS container

### DuckDNS client
The recommended and easiest solution is to install the Duckdns docker-container
from the menu. It includes the cron service and logs are handled by Docker.

For configuration see [Containers/Duck DNS]( ../Containers/Duckdns.md).

!!! note
This is a recently added container, please don't hesitate to report any
possible faults to Discord or as Github issues.

### DuckDNS client script { #duckdns-client }

!!! info
This method will soon be deprecated and then removed in favor of the
DuckDNS container.

IOTstack provides a solution for DuckDNS. The best approach to running it is:

Expand Down
82 changes: 82 additions & 0 deletions docs/Containers/Duckdns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Duck DNS

Duckdns is a free public DNS service that provides you with a domain name you
can update to match your dynamic IP-address.

This container automates the process to keep the duckdns.org domain updated
when your IP-address changes.

## References

* Register an account, add your subdomain and get your token from
[http://www.duckdns.org/](http://www.duckdns.org/)
* based on the linuxserver
[docker-duckdns](https://github.com/linuxserver/docker-duckdns) container

## Configuration

Create the file `~/IOTstack/docker-compose.override.yml` and place your Duckdns
token and chosen domain name there:

``` yaml title="docker-compose.override.yml"
version: '3.6'
services:
duckdns:
environment:
TOKEN: your-duckdns-token
SUBDOMAINS: subdomain
```
Observe that at least the initial update is successful:
``` console
$ cd ~/IOTstack
$ docker-compose up -d duckdns
$ docker-compose logs duckdns
...SNIP...
Retrieving subdomain and token from the environment variables
log will be output to docker log
Your IP was updated at Wed May 4 03:31:14 UTC 2022
...SNIP...
```

If there is a problem, check that the resulting effective configuration of
'duckdns:' looks OK:
``` console
$ cd ~/IOTstack && docker-compose config
```

### Domain name for the private IP

!!! note inline end "Example IP:s and domains"

``` mermaid
flowchart
I([Internet])
G("Router\npublic IP: 52.85.51.71\nsubdomain.duckdns.org")
R(Raspberry pi\nprivate IP: 192.168.0.100\nprivate_subdomain.duckdns.org)
I --- G --- |LAN| R
```

As a public DNS server, Duckdns is not meant to be used for private IPs. It's
recommended that for resolving internal LAN IPs you use the [Pi
Hole](Pi-hole.md) container or run a dedicated DNS server.

That said, it's possible to update Duckdns to your LAN IP. This may be
convenient if you have devices that don't support mDNS (.local) or don't want
to run Pi-hole. This is especially useful if you can't assign a static IP to
your RPi. No changes to your DNS resolver settings are needed.

First, as for the public subdomain, add the domain name to your Duckdns account
from their homepage. Then add a `PRIVATE_SUBDOMAIN` variable indicating this
subdomain:

``` yaml title="added variable to docker-compose.override.yml"
version: '3.6'
services:
duckdns:
environment:
TOKEN: ...
SUBDOMAINS: ...
PRIVATE_SUBDOMAIN: private_subdomain
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ extra_javascript:
- javascript/fix-codeblock-console-copy-button.js

markdown_extensions:
- attr_list
- pymdownx.highlight:
pygments_lang_class: true
- admonition
Expand Down
8 changes: 4 additions & 4 deletions requirements-mkdocs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Jinja2==3.0.3
Markdown==3.3.6
MarkupSafe==2.1.0
mergedeep==1.3.4
mkdocs==1.2.3
mkdocs==1.3.0
mkdocs-awesome-pages-plugin==2.7.0
mkdocs-material==8.2.3
mkdocs-material==8.2.13
mkdocs-material-extensions==1.0.3
mkdocs-redirects==1.0.3
packaging==21.3
Pygments==2.11.2
pymdown-extensions==9.2
Pygments==2.12.0
pymdown-extensions==9.4
pyparsing==3.0.7
python-dateutil==2.8.2
PyYAML==6.0
Expand Down

0 comments on commit 5f9e044

Please sign in to comment.