Skip to content

alphabt/asuswrt-merlin-ddns-cloudflare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

Asuswrt-Merlin DDNS for CloudFlare

This is a custom shell script for Asuswrt-Merlin router firmware to update DDNS via CloudFlare for both IPv4 and IPv6.

Notice

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.

Prerequisite

This script uses Python so make sure you have it installed in your environment. One way is to install via Entware.

Setup

  1. 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 an AAAA record if you want to use IPv6.

  2. 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 an AAAA record setup in CloudFlare as instructed in step 1. Defaults to false.
  3. SSH to your router and place ddns-start under /jffs/scripts/

  4. Make sure it's executable chmod +x /jffs/scripts/ddns-start

  5. Log into the router web UI

    1. Go to Advanced Settings > WAN > DDNS
    2. Set Server to Custom
    3. Click the Apply button

References