
Setting Up Dynamic DNS on a Raspberry Pi for Self-Hosting
A step-by-step guide to setting up Dynamic DNS on a Raspberry Pi for self-hosting services like WordPress, Ghost, or an Nginx server.
15 November 20243 minute read
By Kevin McAleer
Share this article on
Table of Contents
- What is Dynamic DNS?
- Why Use Dynamic DNS for Self-Hosting?
- Prerequisites
- Setting Up a DDNS Client on Raspberry Pi
- Step 1: Choose a DDNS Provider
- Step 2: Install a DDNS Client
- Option 1: Setting Up No-IP
- Option 2: Setting Up DuckDNS
- Configuring Your Router
- Step 1: Enable Port Forwarding
- Step 2: Test Access
- Additional Security: SSL/TLS Certificates with Let’s Encrypt
- Conclusion
Setting Up Dynamic DNS on a Raspberry Pi for Self-Hosting
A step-by-step guide to setting up Dynamic DNS on a Raspberry Pi for self-hosting services like WordPress, Ghost, or an Nginx server.

What is Dynamic DNS?
Dynamic DNS (DDNS) is a service that maps your dynamic public IP address to a domain name. This is useful when hosting services like WordPress, Ghost, or an Nginx server at home, as it allows you to access your Raspberry Pi using a consistent domain name, even if your ISP changes your IP address.
Why Use Dynamic DNS for Self-Hosting?
- Consistent Access: A DDNS service keeps your domain name updated with your public IP address.
- Ease of Use: No need to remember changing IP addresses.
- Remote Access: Makes self-hosted services accessible from anywhere.
Prerequisites
- A Raspberry Pi running Raspberry Pi OS.
- A registered account with a DDNS provider (e.g., No-IP, DuckDNS, DynDNS).
- Your Raspberry Pi must be accessible from the internet via port forwarding.
- A domain name (if required by your DDNS provider).
Setting Up a DDNS Client on Raspberry Pi
Step 1: Choose a DDNS Provider
Popular free and paid DDNS providers include:
Create an account with your preferred provider and configure a hostname. For example, myhome.ddns.net
.
Step 2: Install a DDNS Client
Depending on your chosen provider, you’ll need to install a DDNS client. For this guide, we’ll cover No-IP and DuckDNS.
Option 1: Setting Up No-IP
-
Install the No-IP Client:
sudo apt update sudo apt install noip2
-
Configure No-IP:
Run the following command and enter your No-IP account details when prompted:
sudo noip2 -C
-
Start the No-IP Client:
After configuring, start the client with:
sudo noip2
-
Check the Status:
Verify that the No-IP client is running:
sudo noip2 -S
Option 2: Setting Up DuckDNS
-
Install DuckDNS Client:
DuckDNS doesn’t require a specific client. Instead, use a script. Navigate to your home directory:
cd ~
-
Download the DuckDNS Script:
Create a script file:
nano duckdns.sh
Add the following content, replacing
<TOKEN>
and<DOMAIN>
with your DuckDNS token and subdomain:echo url="https://www.duckdns.org/update?domains=<DOMAIN>&token=<TOKEN>&ip=" | curl -k -o ~/duckdns.log -K -
-
Make the Script Executable:
chmod +x duckdns.sh
-
Automate Updates with Cron:
Open the crontab editor:
crontab -e
Add the following line to run the script every 5 minutes:
*/5 * * * * ~/duckdns.sh
Configuring Your Router
Step 1: Enable Port Forwarding
Log in to your router’s admin interface and forward the following ports to your Raspberry Pi’s local IP:
- Port 80 (HTTP) for web servers like WordPress or Ghost.
- Port 443 (HTTPS) for secure web access.
- Any other ports required by your application.
Step 2: Test Access
Use your DDNS domain (e.g., http://myhome.ddns.net
) to access your Raspberry Pi from an external network. If configured correctly, your DDNS domain should point to your Raspberry Pi’s public IP address.
Additional Security: SSL/TLS Certificates with Let’s Encrypt
-
Install Certbot:
Install Certbot to obtain free SSL certificates:
sudo apt update sudo apt install certbot python3-certbot-nginx
-
Obtain a Certificate:
Run the following command, replacing
<DOMAIN>
with your DDNS domain:sudo certbot --nginx -d <DOMAIN>
-
Renew Certificates Automatically:
Add a cron job to renew the certificates automatically:
crontab -e
Add this line:
0 3 * * * certbot renew --quiet
Conclusion
Setting up Dynamic DNS on your Raspberry Pi allows you to self-host services like WordPress, Ghost, or an Nginx server with a consistent domain name. With DDNS and port forwarding, your Raspberry Pi becomes a powerful tool for hosting accessible, secure applications.