Table of Contents
Dynamic DNS (DDNS) is a method of automatically updating the DNS records of a domain name whenever the IP address changes. This is particularly useful for home networks or dynamic IP addresses provided by ISPs.
ddns-updater is a tool that supports many DNS providers, including desec.io, a free and open-source DNS service. We'll use Podman Quadlets to run ddns-updater as a systemd service, ensuring it starts automatically at boot and updates our DNS records whenever our IP address changes.
Kubefile
We have two containers in our pod, one for IPv4 and one for IPv6. The IPv4 container will update the DNS record for the IPv4 address, while the IPv6 container will do the same for the IPv6 address.
Depending on your provider the CONFIG
environment variable must be different.
On the IPv6 container the HEALTH_SERVER_ADDRESS
environment variable sets another port, because it is already used by the IPv4 container.
/opt/container/ddns-updater/kube.yaml
:
---
apiVersion: v1
kind: Pod
metadata:
labels:
app: ddns-updater
io.containers.autoupdate: registry
name: ddns-updater
spec:
containers:
- image: docker.io/qmcgaw/ddns-updater:latest
name: v4
env:
- name: LOG_LEVEL
value: INFO
- name: SERVER_ENABLED
value: "false"
- name: PERIOD
value: 5m
- name: CONFIG
value: >
{
"settings": [
{
"provider": "desec",
"domain": "ddns.example.com",
"token": "",
"ip_version": "ipv4",
"ipv6_suffix": ""
}
]
}
- image: docker.io/qmcgaw/ddns-updater:latest
name: v6
env:
- name: LOG_LEVEL
value: INFO
- name: SERVER_ENABLED
value: "false"
- name: HEALTH_SERVER_ADDRESS
value: "127.0.0.1:9998"
- name: PERIOD
value: 5m
- name: CONFIG
value: >
{
"settings": [
{
"provider": "desec",
"domain": "ddns.example.com",
"token": "",
"ip_version": "ipv6",
"ipv6_suffix": ""
}
]
}
Podman Quadlet
The quadlet file can be put under /etc/containers/sytemd/ddns-updater.kube
for rootfull podman or <rootless user>/.config/containers/systemd/ddns-updater.kube
for rootless podman.
[Install]
WantedBy=default.target
[Unit]
[Kube]
Yaml=/opt/container/ddns-updater/kube.yaml
Network=host
[Service]
# Restart service when sleep finishes
Restart=always
# Extend Timeout to allow time to pull the image
TimeoutStartSec=900
Reload systemd to recognize the new service:
# rootfull
sytemctl daemon-reload
# rootless
systemctl --user daemon-reload
Start the systemd service:
# rootfull
systemctl start ddns-updater
# rootless
systemctl --user start ddns-updater
View the status of the service:
# rootfull
systemctl status ddns-updater
# rootless
systemctl --user status ddns-updater
Show log of the service
podman logs ddns-updater-v4
podman logs ddns-updater-v6