How to install DuckDNS

DuckDNS is perfect free dynamic DNS service that does not require manually updating your up tp 5 free dynamic DNS domain names. It is easy to setup the shell script to do this for you via crontab.

To install DuckDNS, first create one directory to store your DuckDNS update script and one for DuckDNS log. In this example the update script is stored in the existing scripts directory under /home. But the log directory needs to be created.

# mkdir /var/log/duckdns

Now open vim editor to create the script:

# cd /home/scripts
# vim duck_dns.sh

Paste the following line and make sure to edit highlighted parts exampledomain  needs to be fqdn (i.e. hysteria.duckdns.org) and the token you can find under your account.

echo url="https://www.duckdns.org/update?domains=exampledomain&token=aht8d0fg-424a-13rb-ce1g-d289614a37f2&ip=" | curl -k -o /var/log/duckdns/duck.log -K -

In case you are updating multiple domains (up to 5), separate each domain with coma and no space (i.e. hysteria.duckdns.org,amnesia.duckdns.org,insomnia.duckdns.org).

Close the script and make it executable:

# chmod 700 duck_dns.sh

Edit the crontab:

# crontab -e

and paste the following like. Remember to update your path to reflect location of your dns update script.

*/5 * * * * /home/scripts/duck_dns.sh >/dev/null 2>&1

Save and exit. Now run the script:

# ./duck_dns.sh

You should receive output similar to this:

 % Total % Received % Xferd Average Speed Time  Time  Time    Current
Dload Upload Total Spent Left Speed
100 2 0 2 0 0 2 0 --:--:-- --:--:-- --:--:-- 2

Check that the log does not contain any errros:

# cat /var/log/duckdns/duck.log

If everythings is OK you should get only work OK in the log file.

If your crontab service is not started, start it now:

# systemctl start cron 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.