What is DuckDNS?

Duck DNs is a dynamic DNS service.  If you have a home IP address that chnages occasionally, or often, and you're wanting to run any kind of homelab or servers that you may want to reach from ourside your home network, then you have a few options, but the easiest (IMO) is a dynamic DNS service.  DuckDNS is a free service, at least  for the reasons that we'll be utilizing it.

Essentially, you register a DuckDNS url (example.duckdns.org) for your home, and then run a service in docker inside your home LAN, that keeps track of your current public IP address, and updates that IP to the DNS of your registered DuckDNS URL(s).

So, if your ISP, or happen-stance, causes your IP to change, you will still have access to your homelab via the registered URL.

What you'll need

  • Docker-CE and / or Docker Compose installed and ready to go.  
  • Portainer installed and running on our Docker server (optional)
  • NGinX Proxy Manager installed and running on our Docker server (optional)
  • A DuckDNS Account
  • DuckDNS URL
  • DuckDNS API Token

Docker-CE / Docker-Compose Install

Before you attack this particular problem, know that there are other routes to running DuckDNS.  If you have Home Assistant running already, then there is a DuckDNS add on you cona configure and run through HA instead (if you prefer), but today we'll be focused on running it in Docker, as it's a very low resource container, and iti gives you so much back.

I have several tutorials already out there on installing and setting up Docker and Dockeer-Compose, but I also have a script for Ubuntu, Debian, and I believe CentOS to install it as well.

You can get the script from github here:

bmcgonag/docker_installs
Docker and Docker-Compose install scripts for various linux distros and versions - bmcgonag/docker_installs

You can check out the Video tutorial for installing Docker, Docker-Compose, and NGinX Proxy Manager here:

If you'd like to use Portainer-CE (a GUI based docker management tool), then you can easily install it in Docker-CE with the following steps.

Open a Terminal to the machine you have installed Docker-CE on, and run these commands:

docker volume create portainer_data
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

After running those two commands, go to your host machine IP address, on port 9000, and create your Portainer-CE admin account.

For instance, I went to http://192.168.7.125:9000 as this is the IP of my host machine.

Installing DuckDNS

In the video, I show you how to install DuckDNS through both the CLI (Command Line Interface) using docker-compose, as well as through Portainer-CE.

Check the video timestamps to jump to the method you prefer.

Here, I'll be giving the text instructions for doing so via the Cli only.

Step 1

Go to https://duckdns.org and create an account.  Once created you'll see a Token.  You'll need this token in the following steps.  First, however, enter a subdomain name in the input box, and click the green "add domain" button.

If your subdomain is available, you'll get a success message and see it listed on your account page.

Create as many subdomains as you like.  FOr instance, if you have a Jellyfin server, you might want to create one called "jf-bill" (if your name was bill), and see if jf-bill.duckdns.org is available.  If so, you can now use that subdomain, in combination with NGinX Proxy Manager, to access your Jellyfin media from outside your home network through https.  Nice, right?

Once you have the subdomains you want, head back to the terminal of the machine where you're hosting the Docker-CE install.

From your home directory, create a new folder called "duckdns":

mkdir duckdns

Change into that directory

cd duckdns

and create a new file called "docker-compose.yml"

nano docker-compose.yml

Inside this file, paste the following:

version: "2.1"
services:
  duckdns:
    image: ghcr.io/linuxserver/duckdns
    container_name: duckdns
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Chicago
      - SUBDOMAINS=<your-subdomain>.duckdns.org
      - TOKEN=<your token>
      - LOG_FILE=false
    volumes:
      - /home/<your-host-machine-user>/duckdns/config:/config
    restart: unless-stopped

into that file.  Use CTRL + C or CMD + C to copy it, and then use CTRL + Shift + V to paste into the terminal, ro CMD + V on MacOS.

Now, change the TZ=America/Chicago to your timezone.

Change the <your-subdomain> to the subdomain you created on the DuckDNS website.

If you created multiple subdomains, just add them all on this line with comma separation, like this:

hotzone.duckdns.org,jericho.duckdns.org,media-home-srver.duckdns.org

If you only created one, just put the one.

Next, copy your token from the DuckDNS account page, and paste it into the docker-compose.yml file in place of the <your token> text.

Finally, change the volume path on the left side of the colon ':' to match your user home directory path.

Save the file with CTRL + O, then press Return / Enter, then use CTRL + X to exit nano.

Now, you can pull down and start DuckDNS by running the command:

docker-compose up -d

Give it time to get everything setup and started, then you can check the logs with the command:

docker logs duckdns

As long as you don't see errors, and it show logs, you should be set and ready to go.  Just re-run the above command to refresh the log output.

That's it.  You're up and running with dynamic dns, and you should now be able to access your hoem IP from the subdomain.duckdns.org you created.

Routing inside my LAN

If you want to route your subdomain(s) to specific servers / applications inside your LAN, you'll want to next setup your NGinX Proxy Manager to handle the requests coming in for your DuckDNS subdomain(s).  

Definitely check out the video I posted above about "Putting it all together" to get more on NGinX Proxy Manager, as well as the end of the video for this post.