alphabt / asuswrt-merlin-ddns-cloudflare Goto Github PK
View Code? Open in Web Editor NEWCloudFlare DDNS update script for Asuswrt-Merlin
CloudFlare DDNS update script for Asuswrt-Merlin
With this ddns-start script I know I can configure one DNS Record Name to work correctly.
I have a few domains at Cloudflare that I point at my router.
I run a nginx server configured with the domains on the router and it handles the domains.
How may I be able to configure multiple DNS Record Names to work correctly?
For example, domainone.org, domaintwo.com, domainthree.net all point to my router and I would like this script to accommodate them.
Currently only one domainone.org can update automatically.
Any advice is appreciated.
(OSX) (RT-AC66U_380.70_0.trx)
I could not successfully SSH into the router so I telnet'd and
touch /jffs/scripts/ddns-script
and
nano /jffs/scripts/ddns-script
after this I filled out variables accordingly.
I got to the "Applying Settings" screen as I hit "Save" - left it over night, but still on the same screen.
correctly updates a record but turns off proxied to dns only
Then why it is not described in the README
file?
Just wasted serval hours to debug this script
TTL is in seconds and not minutes. And the minimum TTL is 2 hours (7200 seconds) or else the API will reject it.
This script was erroring without any error messages until I started debugging with manual values, where I could finally see what the issue was. I suspect the API might've changed the TTL from seconds to minutes recently, as I had this same script going without any issue earlier this year.
Hello, I have a need, but I don't know how to modify the script. My network environment has an IPv6 public network address, but no IPv4 public network address, I want DDNS to update only IPv6. Want the script to give the user an option to UPDATE_IPv4.
I was wondering if you had tried this with the new Restricted API keys Cloudflare has in BETA? Here is an example POST:
curl -i -X POST "https://api.cloudflare.com/client/v4/zones//purge_cache"
-H "Authorization: Bearer "
-H "Content-Type: application/json"
--data '{"purge_everything":true}'
We may be able to change the curl commands to use the new Restricted API and limit exposure to a hack instead of using the Global API key. What do you think?
FYI: https://community.cloudflare.com/t/restricted-api-keys/13647/106
My router stopped updating my IP to Cloudflare a while back, but I never looked at the issue until recent after having to try to connect to my house externally. After a lot of troubleshooting, I finally figured out that the ${1} was not returning my IP, so the router was not pulling it for some reason. After looking over the original documentation at Merlin's github https://github.com/RMerl/asuswrt-merlin.ng/wiki/Custom-DDNS I figured out that it could be caused by double NAT, so I updated the script and viola. Below is what I updated, hope it helps.
Added this variable to the top
DNS_QUERY_SITE="https://myip.dnsomatic.com/" # Site used to get external DNS if router isn't able to pull it due to double NAT
Added the IF block to test if IPv4 is null, and if so then query external site to obtain IP, also updated the logger to in the failure to include IP as that's how I figured the issue out.
# Update IPv4
#Get IPv4 from Router otherwise from external source
IPv4=${1}
if [ -z "$IPv4" ]; then
IPv4="$(curl -fs4 $DNS_QUERY_SITE)"
logger "IP ${IPv4} obtained external source $DNS_QUERY_SITE"
else
logger "IP ${IPv4} obtained by router"
fi
A_RECORD_IDS=$(get_dns_record_ids $RECORD_NAME A $API_TOKEN $ZONE_ID)
for A_RECORD_ID in $A_RECORD_IDS; do
RESPONSE="$(update_dns_record $RECORD_NAME $A_RECORD_ID A $IPv4 $RECORD_TTL $API_TOKEN $ZONE_ID)"
echo $RESPONSE | grep '"success":\ *true' >/dev/null
if [ $? -eq 0 ]; then
logger "Updated A record for ${RECORD_NAME} to ${IPv4}"
else
logger "Unable to update A record for ${RECORD_NAME} with ${IPv4}"
RESULT=false
fi
done
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.