How to Setup DuckDNS on a Raspberry Pi!

  • Post author:
  • Post last modified:November 2, 2022
  • Post category:Raspberry Pi
  • Reading time:5 mins read

Today we are going to look at how to setup DuckDNS on a Raspberry Pi.

DDNS is a way to automatically update a name server (in this case, DuckDNS) in real-time with your external IP address. There are many reasons why you might need a DDNS hostname, with one of the most common being creating a VPN Server. In this tutorial, we will run through the commands to setup DDNS on a Raspberry Pi.

Instructions – DuckDNS Raspberry Pi

Before you start the setup tutorial, ensure that you have navigated to and setup a user account. We will be using the domain and token that exist on that page

1. SSH into your Raspberry Pi. If you aren’t sure how, you can find our tutorial here.

2. After you SSH in, we need to make a directory and then create a file in that directory that will run at a scheduled time (created in later steps).

mkdir duckdns
cd duckdns
making duckdns folder and creating a new file

3. We’re now going to place a script in this file that will run at a scheduled interval. The script needs to have the domains you are using (from DuckDNS) added to it.

adding the file to automatically update the ddns hostname
echo url="[YOUR_DOMAIN]&token=[YOUR_TOKEN]&ip=" | curl -k -o ~/duckdns/duck.log -K -

4. We now need to change the permissions of these files and access crontab to schedule this script to run every five minutes. Crontab is a task schedular that automates certain commands.

chmod 700
crontab -e
changing the permissions of the script created and editing the crontab

5. Paste the contents of the file below in the crontab file.

*/5 * * * * ~/duckdns/ >/dev/null 2>&1
adding folder to the cron to automatically run

8. The job will now run every five minutes. We will test it, and assuming it works, start the cron service. If you receive OK after running this command, the process worked properly. If you receive KO, you have an error somewhere in your script file or you did not give the file the proper permissions.

cat duck.log
sudo service cron start
starting the cron service


This is a very simple and straight forward process, but we will be building on top of this in future tutorials. Ensuring that you are connecting to your external IP address is very important when you use services that require your external IP address.

If you’re interested in using your new DDNS to setup a WireGuard VPN, check out our tutorial here!

Please share if this helped you!

You are currently viewing How to Setup DuckDNS on a Raspberry Pi!

This Post Has 25 Comments

  1. rapi

    i setup and all looks ok

    but i am a really noob so what can i do now with the url if i put this in browser i got message “You don’t have permission to access this resource.” i want to call from the internet to my raspberry pi

    1. WunderTech

      Well, all this does is display your external IP address so if you open a command prompt and type “nslookup” you should get your external IP address. From there, you can use it for a ton of different things.

Comments are closed.