I started from here and with
@Steffe help over 2 years ago, and now my ddns script has close to 3000 lines
and everythign is merged into it. It even works at Raspberrry Pi
So, I wish to share some ideas.
Important: when in DoubleNAT, the only way to be sure of your WAN IP address is to read it from your modem. External reading (e.g. icanhazip.com) will hide many problems from you! I never use external read any more!
Recently, providers started introducing private WAN IP addresses starting with 10. or 100 (CGN and Shared Address space RFC6598 and similar). If you get them, incoming VPN or ssh will not work.
How to read from the modem? I could telnet to one older and reboot it that way. Newer ones are stupid, I must steal data from their wep pages. For ZTE it is easy, for Huawei is quite complicated. Method varies by the modem. My router reboots my modems directly when there is a problem with them.
For the DDNS servers, I propose ones almost nobody heard of: dynu.com and duckdns.org. Free for 5 names, work for e-mail too, ttl is <90 sec. No need to force updates (I have had single address for 88 days without the need for updates). I am using them for years and they work perfectly. My VPN clients are set to autoamtically use 3 DDNS providers should there be a problem. Third one is twodns.de but they do not help if you need e-mail (MX) and over last years, they had problems twice. But are excellent as a third backup.
I have incorporated tests if Internet is actually alive and if my 3 networks can communicate with each other. These test required my ddns script to be run by cru every 5 minutes. Side benefit: I become free from Asus if it will run the script or forget to do so when it was needed. This happend sometimes on my routers.
Asus router can sometimes forget to start ddns script. Do not ask me why. I have added to one other computer (Raspberry Pi) on the same netork to check every 12 minutes if ddns script is running, and if it is not, RPi will run it. Not often, but my routers sometime mess up their cru which runs my ddns-start.
So, to fix this, it is enough for a RPi to to check if cru entry is well, and if it is not, run the program.
Code:
ssh router@192.168.1.1 (cru l | grep "ddns-start" 1>&-) || { /jffs/scripts/ddns-start; } '
How this helps? I added into my ddns script to build its own cru entry if it is not present. My script become a program I call DoubleDDNS, adjust name as you like, and it is set to run every 5 minutes.
Code:
[ ! "$(cru l | grep DoubleDDNS)" ] && cru a DoubleDDNS "03-59/5 * * * * /jffs/scripts/ddns-start"
Since everything is logged, my script can make statistics how long did I have a WAN IP addresses, how many problems did I have and which and similar. On several ocassions, thanks to my stats, I noticed problems before my provider did and by reporting them, forced my provider to fix them quicker.
I hope this may give someone usefull ideas.