This is a custom shell script for Asuswrt-Merlin router firmware to update DDNS via CloudFlare for both IPv4 and IPv6.
If you use Asuswrt-Merlin version 384.7 or above you can leverage a new way to update DDNS. More info can be found at https://github.com/RMerl/asuswrt-merlin.ng/wiki/DDNS-services. This method is likely more robust and flexible.
This script uses Python so make sure you have it installed in your environment. One way is to install via Entware.
-
Add an
A record
in CloudFlare for your domain. IP for the record can be anything since the script will overwrite it later anyway. Optionally add anAAAA record
if you want to use IPv6. -
Download ddns-start script and modify the following variables with your own settings:
Variable Description API_TOKEN
Your API Token generated from the User Profile 'API Tokens' page. I recommend creating a token with minimal access to limit exposure:
Permission: Zone > DNS > EDIT
Zone Resources: Include > Specific Zone > <your zone>ZONE_ID
Your Zone ID, hex16 string RECORD_NAME
Your DNS record name, e.g. host.example.com RECORD_TTL
TTL for the record in seconds, defaults to 1 (auto) UPDATE_IPv6
Set it to true
if you want the script to update the AAAA record. Make sure you have anAAAA record
setup in CloudFlare as instructed in step 1. Defaults tofalse
. -
SSH to your router and place
ddns-start
under/jffs/scripts/
-
Make sure it's executable
chmod +x /jffs/scripts/ddns-start
-
Log into the router web UI
- Go to
Advanced Settings
>WAN
>DDNS
- Set
Server
toCustom
- Click the
Apply
button
- Go to