Automate updating a [[DNS and DDNS - (Dynamic) Domain Name System|DDNS]] (e.g. for [[Home VPN Server with WireGuard]]).
**Browser**
- Create Account https://www.duckdns.org
- Add Domain Name
**Local**
Set up update bash script in arbitrary dir. Find your generated token and add in the following script.
```bash
#!/bin/bash
# Get public IPv4
IPV4=$(curl -s https://ipv4.icanhazip.com)
# Get public IPv6 (if available)
IPV6=$(curl -s https://ipv6.icanhazip.com)
# Update DuckDNS
curl "https://www.duckdns.org/update?domains=myserver&token=YOUR-TOKEN&ip=$IPV4&ipv6=$IPV6" \
-o ~/duckdns/duck.log
```
Running this should put OK in the specified `.log` file. To automatically run this periodically, set up a timer service and an update service via [[systemctl - systemd CLI|systemctl]] under the [[etc Directory - System Configs|etc directory]] (`/etc/systemd/system`).
```bash
# duckdns.service
[Unit]
Description=DuckDNS Updater
[Service]
ExecStart=/home/your-user/duckdns/duck.sh
```
```bash
# duckdns.timer
[Unit]
Description=Runs DuckDNS script every 5 minutes
[Timer]
OnBootSec=1min
OnUnitActiveSec=5min
Unit=duckdns.service
[Install]
WantedBy=timers.target
```
Enable via
```bash
sudo systemctl enable --now duckdns.timer
```
If only one of the [[IP Address, IPv4, IPv6, ULA and Subnet Mask|IPs]] is supposed to be updated, simply remove from the script. To make sure the other one is not set, specify `&clear=true` at the end of the [[URL - Uniform Resource Locator|URL]].