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 recordin CloudFlare for your domain. IP for the record can be anything since the script will overwrite it later anyway. Optionally add anAAAA recordif you want to use IPv6. -
Download ddns-start script and modify the following variables with your own settings:
Variable Description API_TOKENYour 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_IDYour Zone ID, hex16 string RECORD_NAMEYour DNS record name, e.g. host.example.com RECORD_TTLTTL for the record in seconds, defaults to 1 (auto) UPDATE_IPv6Set it to trueif you want the script to update the AAAA record. Make sure you have anAAAA recordsetup in CloudFlare as instructed in step 1. Defaults tofalse. -
SSH to your router and place
ddns-startunder/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
ServertoCustom - Click the
Applybutton
- Go to