Get a DDNS up and running with DuckDNS - Step by Step
2026-08-12
A step-by-step guide to using DuckDNS and cron to keep a dynamic public IP mapped to a hostname.
Tags: ddns / duckdns / networking
Understanding DDNS
DDNS stands for Dynamic DNS. It updates a DNS name in real time so that it points to a changing IP address. This is useful for devices without a static IP.
Static IPs and IP ranges can be expensive. DDNS provides a cost-effective alternative by linking a hostname to a dynamic IP address.
How DDNS works
To use DDNS, you need an account with a DDNS provider. A script or service on your device updates the DDNS provider with your current IP at regular intervals, keeping the hostname linked to the right address.
DuckDNS is free and relies on donations to keep its services running. If you find it useful, consider supporting DuckDNS on Patreon.
Setting up DuckDNS
-
Create an account and log in. Visit DuckDNS and log in or create an account.

-
Create a domain. Once logged in, create a domain and link it to your current public IP.

Automating IP updates with a script
DuckDNS provides a simple script to keep your domain updated. You can follow their guide or continue with the steps below.

-
Ensure
crontabis running:ps -ef | grep cr[o]n -
Check that
curlis installed:curl --versionIf it is not installed on Ubuntu or Debian, install it with:
sudo apt install curl -y -
Create a DuckDNS script. Navigate to your home directory and create a
duckdnsfolder:cd ~ mkdir duckdns cd duckdns touch duck.sh -
Edit the script. Open
duck.shwithnanoor your preferred editor and add:#!/bin/bash DOMAIN="EXAMPLE" TOKEN="TOKEN" echo url="https://www.duckdns.org/update?domains=$DOMAIN&token=$TOKEN&ip=" | curl -o ~/duckdns/duck.log -K -Replace
EXAMPLEwith your DuckDNS domain andTOKENwith the unique token shown at the top of the DuckDNS dashboard. -
Set permissions and schedule the script. Make it executable:
chmod +x ~/duckdns/duck.shOpen the crontab editor:
crontab -eAdd this line to run the script every five minutes:
*/5 * * * * ~/duckdns/duck.sh >/dev/null 2>&1 -
Run the script manually for the first time:
cd ~/duckdns/ ./duck.shCheck
duck.log. If it containsOK, the setup succeeded. If it containsKO, review the domain, token, permissions, and command before continuing.
Next steps
For example, you may want to set up port forwarding on your router to make effective use of the new DDNS hostname.