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 2024 3 minute read By Kevin McAleer Share this article on Table of Contents What is Dynamic DNS?Why Use Dynamic DNS for Self-Hosting?PrerequisitesSetting Up a DDNS Client on Raspberry PiStep 1: Choose a DDNS ProviderStep 2: Install a DDNS ClientOption 1: Setting Up No-IPOption 2: Setting Up DuckDNSConfiguring Your RouterStep 1: Enable Port ForwardingStep 2: Test AccessAdditional Security: SSL/TLS Certificates with Let’s EncryptConclusion Tags: Raspberry Pi Dynamic DNS Self-Hosting WordPress Ghost Nginx Difficulty: intermediate Category: raspberrypi Home Blog Setting up dynamic dns on a raspberry pi for self hosting 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 2024 | 3 minute read | By Kevin McAleer | Share this article on 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: No-IP DuckDNS DynDNS 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. Liked this article? You might like these too. 10 Projects for your Raspberry Pi Pico If you've just got a new Raspberry Pi Pico and you're looking for some inspiration, then you've come to the right place. Here is a collection of projects that you can build with your Raspberry Pi Pico. Raspberry Pi Telegraf Setup with Docker "Learn how to set up Telegraf on your Raspberry Pi with Docker to monitor system metrics and integrate with popular time-series databases like InfluxDB or Prometheus." Raspberry Pi WordPress Setup with Docker Learn how to turn your Raspberry Pi into a WordPress server using Docker, allowing for an easily manageable and portable WordPress installation. Raspberry Pi WireGuard VPN Setup with Docker Learn how to set up a secure WireGuard VPN on your Raspberry Pi using Docker, allowing remote access to your home network securely and easily. Raspberry Pi MotionEye Camera Setup with Docker Learn how to set up MotionEye on your Raspberry Pi with Docker to turn it into a network camera server, perfect for monitoring home security or creating a DIY surveillance system. Raspberry Pi Ghost Setup with Docker Transform your Raspberry Pi into a Ghost blogging platform using Docker. This guide covers the setup process and configuration for a personal Ghost site.
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 2024 3 minute read By Kevin McAleer Share this article on Table of Contents What is Dynamic DNS?Why Use Dynamic DNS for Self-Hosting?PrerequisitesSetting Up a DDNS Client on Raspberry PiStep 1: Choose a DDNS ProviderStep 2: Install a DDNS ClientOption 1: Setting Up No-IPOption 2: Setting Up DuckDNSConfiguring Your RouterStep 1: Enable Port ForwardingStep 2: Test AccessAdditional Security: SSL/TLS Certificates with Let’s EncryptConclusion Tags: Raspberry Pi Dynamic DNS Self-Hosting WordPress Ghost Nginx Difficulty: intermediate Category: raspberrypi
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: No-IP DuckDNS DynDNS 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.