Double NAT custom DDNS script

  • ATTENTION! As of November 1, 2020, you are not able to reply to threads 6 months after the thread is opened if there are more than 500 posts in the thread.
    Threads will not be locked, so posts may still be edited by their authors.
    Just start a new thread on the topic to post if you get an error message when trying to reply to a thread.

Steffe

Regular Contributor
You're not completely right. The script saves your external ip and checks your current external ip against it. If the current external ip differs, a request to no-ip will be made. And only then.
It is generally bad to send a request to a website when it can be handled locally in the script.
Initially, e.g. after each router reboot, your external ip has not been stored, thus the script will send a request and store your external ip. Afterwards it will only update/send a request if you have a new ip.
 

Bob.Dig

Regular Contributor
Thank you for this.
I hope something like this will be integrated into stock-merlin for all of us in the future.
 

mmjlmjl

New Around Here
The script looks wonderful, however, I would like to use the free Asus ddns service in a double nat situation. Anyone knows a script that could do that? Is there any documentation on how the asus ddns api should be called?
 

Steffe

Regular Contributor
The script looks wonderful, however, I would like to use the free Asus ddns service in a double nat situation. Anyone knows a script that could do that? Is there any documentation on how the asus ddns api should be called?
Hello,

I have not been able to find any example/documentation of that...

@RMerlin Do you know if asus ddns service can be accessed through an api?
 

RMerlin

Asuswrt-Merlin dev
Hello,

I have not been able to find any example/documentation of that...

@RMerlin Do you know if asus ddns service can be accessed through an api?

No idea. Look at the ez-ipupdate sources to get an idea of how their API works.
 

chncar

Occasional Visitor
Hello,

Can I just log ddns messages in case of ext. IP change?

I set the interval to 10 min and the system log is now full of ddns messages.

thanks in advance.
 

sfx2000

Part of the Furniture
Features:
  • External IP lookup
  • Only perform DDNS update if external IP has changed
  • Automatically detect Carrier grade NAT(https://en.wikipedia.org/wiki/Carrier-grade_NAT) and perform external lookup
  • Logging to Asus log, or logfile
  • Custom update rate, i.e. possible check if external IP has changed each 10 mins instead for daily.

I worry about privacy here - GPDR and all the related stuff...

Nice script, that being said...

Code:
LogMe "CustomUpdateDDNS: Reported asus router ip: $ASUSIP"
if [[ -n "$(echo "$ASUSIP" | grep -E '^(10\.|100\.(6[4-9]|7[0-9]|8[0-9]|9[0-9]|1[0-2][0-9])\.|172\.(1[6789]|2[0-9]|3[01])\.|192\.0\.0\.|192\.168|198\.1[89])')" ]]; then
# check if we have a local ip. If true, then look up external ip
LogMe "CustomUpdateDDNS: Local ip detected"
# look up external ip
NEWIP=$(curl -s http://icanhazip.com/)
# backup ipcheck if first one fails
if [[ -z "$NEWIP" ]]; then
NEWIP=$(curl -s http://ipv4.myip.dk/api/info/IPv4Address | cut -d "\"" -f2)
fi
LogMe "CustomUpdateDDNS: Found external ip: $NEWIP"
else
NEWIP="$ASUSIP"
LogMe "CustomUpdateDDNS: External ip detected"
fi

Sources there - have they been vetted?
 

Steffe

Regular Contributor
Sure valid point. And, no - they have not been vetted. GDPR has recently approved and gone live - way later than the original script was written.

You're welcome to use your own source to look up the ip if you have a more "trusted one", or if you can suggest me one. Then I can update the script for everyone. Thank you.
 

Steffe

Regular Contributor
Sounds like they do the same, but this script uses noip.me for DNS provider not the asus one.
 

chncar

Occasional Visitor
I modified the script a bit that added some "###" at the front of the line with those "Logme "s i don't need. Now it is much better for me.

It is hard to remove bellowed lines in the router system log in case of Ext. IP not changed, isn't it? Now they are appeared in the log every 10 min as I set the interval.

Sep 2 16:20:00 crond[765]: USER admin pid 3488 cmd /jffs/scripts/ddns-start
Sep 2 16:20:02 ddns: Completed custom ddns update

Anyway, I am satisfied with this script.
 

Steffe

Regular Contributor
New version: https://pastebin.com/P18y0nS7 (will upload to github once asuswrt has been verified)

@Grisu: Added amazon as default ip lookup provider - i expect them to follow the law :) In any case. You can enter whomever you like. No default backup procider though.

@chncar: Please try this version. A silent mode has been added. It should only write in case ip has change. Please confirm. Sorry, crond and ddns is out my hand.

@mmjlmjl: Added asuswrt ddns in this version. Please check if it works - i cannot do that myself.

In all cases please add logs. E.g. execute manually sh -x ddns-start (remember to remove personal information.) Thank you.
 

chncar

Occasional Visitor
@Steffe
Loaded. So far so good. And sorry I am not good at PC code, so I just copied messages from the router system log.

(IP address is fake)
Sep 2 21:24:51 admin: CustomUpdateDDNS: Starting custom DDNS updater v3.0
Sep 2 21:24:51 admin: CustomUpdateDDNS: Reported asus router ip: 192.168.999.999
Sep 2 21:24:51 admin: CustomUpdateDDNS: Local ip detected
Sep 2 21:24:54 admin: CustomUpdateDDNS: Found external ip: 999.95.999.206
Sep 2 21:24:54 admin: CustomUpdateDDNS: (nochange) External IP address is current: 999.95.999.206
Sep 2 21:24:54 admin: CustomUpdateDDNS: Update not needed
Sep 2 21:24:54 ddns: Completed custom ddns update
Sep 2 21:24:54 admin: CustomUpdateDDNS: DDNS update complete

I set SILENT="false" for the 1st time run and will change to "true" after this posted.

My operator will change my ext. IP tomorrow night. Keep you informed.
 

Grisu

Part of the Furniture
New version: https://pastebin.com/P18y0nS7
Added asuswrt ddns in this version. Please check if it works - i cannot do that myself.
Could you answer if Asus ez-ipupdate is useing https or only http, or will we simply have to wait that the new version of ez-ipupdate will be implemented in firmwares (and maybe Merlins new test-build uses it from my 3rd link above)?
 

Steffe

Regular Contributor
I only know what is stated by rmerlin: "I need people to test a new version of ez-ipupdate that now supports HTTPS for updating your DDNS service (previously ez-ipupdate only supported HTTP - that's right, zero encryption...)"

You'll have to wait unfortunately.
Amazon+noip is https.
 

RMerlin

Asuswrt-Merlin dev
And if you wait a bit longer, I have a new solution that will make it no longer necessary to use a script to handle double NAT.
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top