Configuring DDNS on OpenWrt
Since IPv4 resources are very abundant in North America, purchasing a home network plan in Canada typically comes with a public IP. However, ISPs frequently change IP addresses. DDNS binds your home’s public IP to your domain name, so you can always find your home regardless of IP changes.
Prerequisites
-
A domain name
-
A public IP address
-
Some packages:
- ddns-scripts-cloudflare
- luci-app-ddns
- drill
Configuration Steps
-
First, create an A record in Cloudflare. Choose a domain like
vpn.kyxie.me. The IP address can be anything for now, as it will be overwritten by DDNS later. Set Proxy status to DNS only (no proxy).
-
Click here to create a dedicated API token.
-
Select “Edit Zone DNS” and click “Use Template”.
-
Configure as shown below:
-
After generating the API token, save it carefully as it will only be displayed once.
-
Go to OpenWrt β Service β Dynamic DNS β Services and add a ddns_ipv4. Below is the detailed configuration. Note: you must install ddns-scripts-cloudflare first to find cloudflare.com-v4 in the DDNS Service provider dropdown.
ddns: "Enabled": true "Lookup Hostname": "vpn.kyxie.me" "IP address version": "IPV4-Address" "DDNS Service provider": "cloudflare.com-v4" "Domain": "[email protected]" "Username": "Bearer" "Password": "Your API Token" "Use HTTP Secure": true "Path to CA-Certificate": "/etc/ssl/certs" -
If OpenWrt is your main router, DDNS resolution should work now. However, if OpenWrt is a bypass router, the WAN port won’t know the public IP. We need to get the public IP from an external website. Go to Service β Dynamic DNS β Services β ddns_ipv4 β Edit β Advanced Settings β IP address source and select “URL”. For URL to detect, you can use the default IPv4 URL:
http://checkip.dyndns.com
-
DDNS configuration is now complete. Even if your ISP changes your public IP, your domain will still work.
-
After configuration, you can check Cloudflare to see if the IP has been updated.