What's new

Command Line Questions for Stock ASUS Firmware - RT AX86U Pro and DDNS

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

AndrewL733

Occasional Visitor
Hello,

I have an ASUS RT AX86U Pro running the latest stock firmware -- 3.0.0.6.102_34314. I would like to avoid running Merlin if possible.

My router is behind another ISP fiber router so I have a double NAT issue (I tried PPPOE but I lose my IP address periodically and never get a new one). The ASUS router has no problem getting my Public IP address with double NAT. However, the ASUS router doesn't notice if my Public IP Address changes (unless my ISP Router is rebooted or gets disconnected). Therefore, it's only a matter of time before my Public IP no longer matches what the ASUS router told my DDNS provider when the ASUS first booted up.

I have written a script that checks to see if my Public IP has changed. Long story short, I had to create a cron job that runs every 5 minutes, that runs an intermediate script that does nothing more than run the Public IP Check script. I could not run the Public IP Check script directly from cron because curl and wget were unable to fetch any information. Apparently, there are severe limitations on what you can do directly with a script called by cron. But so long as the intermediate script stays within the bounds of what you can do with cron, you can use that to call the script you actually want to run.

Anyway, now I want to force the ASUS router to update my DDNS provider if a change in Public IP is detected. I was hoping there was something like "service restart_ddns" but that doesn't seem to exist. Does anybody know what the command(s) would be. If there isn't any direct way to restart DDNS, do you have any other suggestions (besides rebooting the router, which would be a last resort)?

While I'm on the subject of ASUS command line options, I also have a couple of other questions:

1. The stock ASUS firmware doesn't have any sendmail or msmtp client for sending out email notifications. Has anybody been successful compiling msmtp for aarm64 and running it on the router? There is plenty of space to store a hefty binary on the jffs partition, and I'd rather not install entware on a separate USB stick.

2. I'm also looking for a command that force my router to switch from one WAN interface to another. I have Dual WAN enabled. It works okay for failover, but usually it doesn't fail back to the Primary WAN interface when that comes back up (in fact, the Primary often ends up being down and sometimes I have to remotely reboot my ISP router to make the ASUS see it again. But sometimes the Primary WAN just sits in Hot Standby while my Internet flows over a LTE Modem (my Secondary WAN). I wrote a script to detect which WAN interface I'm routing through, but now I'd like to force things to go back to the Primary when it's available..

Not to be insulting to the Asuswrt-Merlin folks but I have read through the "alternative" Dual WAN script that they tout as superior to the ASUS Dual WAN feature. I'm sure it took the author a long time to write it, and improve it, but it's so long and convoluted I just don't feel comfortable running it on my router. I like scripts under 30 or 40 lines max.
 
I was hoping there was something like "service restart_ddns" but that doesn't seem to exist. Does anybody know what the command(s) would be. If there isn't any direct way to restart DDNS, do you have any other suggestions
It should work if ddns is configured on the router. What do you see in the system log after running it?
 
Hi Dave,

Thanks for your reply.

I figured out why "service restart_ddns" wasn't doing what I expected after my script detected a new Public IP. I can see in the syslog that restart_ddns was returning

Oct 8 10:06:42 rc_service: service 30986:notify_rc restart_ddns
Oct 8 10:06:42 ddns: IP address, server and hostname have not changed since the last update.

Apparently, the ddns service looks at the nvram value stored at ddns_ipaddr in order to decide if the Public IP has changed, so now I have added to my script, upon detection of a new Public IP address:

nvram set ddns_ipaddr=$CurrentPublicIP
sleep 5
service restart_ddns

And that seems to get my IP address properly updated with my DDNS service

Now I just need to guard against a race condition in which somehow there is confusion about the nvram value "ddns_ipaddr" -- because the Router can update the ddns_ipaddr value when it detects a change, and now so can my script. After pulling the cable on my fiber ISP router (but not disconnecting the ISP router from the ASUS router), I just witnessed a momentary failover to my secondary WAN, and my script updated the CurrentPublicIP > ddns_ipaddr to be that of my LTE Router and restarted the ddns service, and then the ASUS Router managed to fail back to the Primary WAN and it updated ddns_ipaddr and estarted the ddns service. I just want to make sure the timing of such an occurrence won't cause something bad.

Trying to think this through, if my script runs within a second or two around the time failback occurs.
  • Script starts running and gets Secondary WAN (LTE Router) Public IP Address
  • Simultaeously, ASUS router detects Primary WAN (Fiber Router) is up and starts failback process
  • Script updates ddns_apaddr to "LTE Router Public IP Address" (which is actually now in Hot Standby) and restarts ddns service. I think ASUS Router will go along and do the update.
  • Failback completes and ASUS router updates ddns_ipaddr to "Fiber Router Public IP Address" and restarts ddns service
  • 5 minutes later, script notices CurrentPublicIP is actually "Fiber Router Public IP Address" and updates ddns_ipaddr and restarts ddns service. The question is, whether ASUS Router will actually restart the service or say "IP address hasn't changed since last update"?
Maybe I can solve this problem by using the NVRAM Value for ddns_ipaddr as my source of truth rather than writing the LastPublicIP to a file and comparing it to the CurrentPublicIP? Got to think about this.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

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