Since your ISP assigns a dynamic IP address to your home connection, you cannot simply set a static DNS record. Instead, you must use Dynamic DNS (DDNS). This guide explains how to configure your Ubuntu server to automatically update Cloudflare whenever your IP address changes.
If you purchased your domain from a different registrar (e.g., Namecheap, GoDaddy), you must point it to Cloudflare.
bob.ns.cloudflare.com).Before automating the process, create a placeholder record in the Cloudflare Dashboard.
Your server needs permission to edit your DNS records.
Include > Specific zone >
Your Domain.We will use ddclient, a standard utility for updating Dynamic DNS.
sudo apt update
sudo apt install ddclient libio-socket-ssl-perl
Open the configuration file using nano:
sudo nano /etc/ddclient.conf
Delete the existing content and paste the following. Be sure to replace the placeholders with your actual data:
# Configuration for Cloudflare DDNS
ssl=yes
use=web, web=https://cloudflare.com/cdn-cgi/trace
protocol=cloudflare
zone=yourdomain.com
login=token
password=YOUR_API_TOKEN_HERE
yourdomain.com
Run a debug test to ensure it can connect and update the IP:
sudo ddclient -daemon=0 -debug -verbose -noquiet
Look for a SUCCESS message in the output.
sudo systemctl restart ddclient
sudo systemctl enable ddclient
Your domain now points to your home IP, but your router blocks incoming traffic by default. You must forward ports to your Ubuntu server.
192.168.1.1).