1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

[Solution] ASUSwrt DDNS updater script that works with multi-NAT

Discussion in 'ASUSWRT - Official' started by Wallace, Jul 3, 2018.

  1. Wallace

    Wallace Occasional Visitor

    Joined:
    Jun 30, 2018
    Messages:
    15
    I am sharing a shell script to use the free DDNS service for your ASUSwrt device.
    The available DDNS hostname is [your-hostname].asuscomm.com

    This solution will work with Access Point (AP) mode, when the web ui does not allow DDNS configuration.

    DDNS update script:
    update-ddns-asuswrt.sh
    1. Enable SSH on ASUSwrt device.
    2. Update [your-hostname] with your preferred hostname in update-ddns-asuswrt.sh
    3. Use scp to upload update-ddns-asuswrt.sh to ASUSwrt device, execute this from your computer (macbook) while connected to ASUSwrt device:
      Code:
      scp update-ddns-asuswrt.sh [asus-device-ip]:/jffs/
      For Windows users, see Transfer Files Using PuTTY
    4. SSH to ASUSwrt device, execute this from your computer (macbook) while connected to ASUSwrt device:
      Typically [username] is admin.
      Code:
      ssh [username]@[asus-device-ip]
    5. For Windows users, see Using PuTTY SSH
    6. Execute the following commands on the ASUSwrt device over the SSH connection:
      Code:
      cru a 1 "*/5 * * * *" /jffs/update-ddns-asuswrt.sh
    7. Verify the cronjob is created:
      Code:
      cru l
      Output:
      Code:
      */5 * * * * /jffs/update-ddns-asuswrt.sh #1#
    8. This cronjob runs every 5 minutes, check the logfile to monitor the cronjob:
      Code:
      tail -f /tmp/var/log/syslog.log
    • Optional: If cronjob is not running, reload the crond process:
      Code:
      echo admin > /tmp/var/spool/cron/crontabs/cron.update
    Hope this helps!
     
    Last edited: Jul 5, 2018
    Grisu likes this.
  2. Please support SNBForums! Just click on this link before you buy something from Amazon and we'll get a small commission on anything you buy. Thanks!
  3. Grisu

    Grisu Very Senior Member

    Joined:
    Aug 28, 2014
    Messages:
    506
    THANKS a lot!

    THAT what I am waiting for 5 years !!!

    Will try it on weekend and report back whether I got it, seems to be a noob proof manual, hope I get it. Never done anything with scripts and no Linux experience.
    Best requirements to be a tester.
     
  4. Adrian Knight

    Adrian Knight Regular Contributor

    Joined:
    Jun 2, 2018
    Messages:
    54
    Step 5. Better you use "cru l" since maybe the admin account name has been changed.
     
    Grisu and Wallace like this.
  5. Wallace

    Wallace Occasional Visitor

    Joined:
    Jun 30, 2018
    Messages:
    15
    Thanks for the good suggestion!
    I have made the changes.
     
  6. Grisu

    Grisu Very Senior Member

    Joined:
    Aug 28, 2014
    Messages:
    506
    Is there a possibility to run this script from an USB-stick as I use only asuswrt because of Aimesh or is even jffs possible on asuswrt?
     
  7. kfp

    kfp Very Senior Member

    Joined:
    Jun 26, 2014
    Messages:
    633
    You can run the script from whichever path you choose, including from an USB drive.
     
  8. Grisu

    Grisu Very Senior Member

    Joined:
    Aug 28, 2014
    Messages:
    506
    Thanks, could you please advice me how to do, never did something like that, know only how to telnet or SSH to the router and execute given commands, linux and its world is something very strange to me.
    What would I have to change in the above perfect manuel for USB usage.
     
    Last edited: Jul 3, 2018
  9. kfp

    kfp Very Senior Member

    Joined:
    Jun 26, 2014
    Messages:
    633
    Just change /jffs to /tmp/mnt/sda1

    Your USB drive might mount to a different path
     
    Grisu likes this.
  10. Grisu

    Grisu Very Senior Member

    Joined:
    Aug 28, 2014
    Messages:
    506
    this command gave a failure:
    /tmp/home/root# tail -f /tmp/var/log/update_ddns_asuswrt.log
    tail: can't open '/tmp/var/log/update_ddns_asuswrt.log': No such file or directory
    tail: no files

    IP lookup not updated at the moment (after 10 min. now).

    I edited "update-ddns-asuswrt.sh" with my x1x2x3x4x5.asuscomm.com, put it on a FAT stick which is seen on USB2.0 but no ftp activated or something else.
    Then entered this commands in SSH:
    scp update-ddns-asuswrt.sh to /tmp/mnt/2GB_stick/
    cru a 1 "*/5 * * * *" /tmp/mnt/2GB_stick/update-ddns-asuswrt.sh
    cru l
    # correct output: */5 * * * * /tmp/mnt/2GB_stick/update-ddns-asuswrt.sh #1#
    tail -f /tmp/var/log/update_ddns_asuswrt.log
    # wrong output: can't open '/tmp/var/log/update_ddns_asuswrt.log': No such file or directory
    # wrong output: tail: no files
    echo admin > /var/spool/cron/crontabs/cron.update

    Sorry for being completely lost.
     
  11. rrQssQrr

    rrQssQrr New Around Here

    Joined:
    May 14, 2018
    Messages:
    5
    Make sure you have the "execute" bit turned on for the script ..

    chmod +x /tmp/mnt/2GB_stick/update-ddns-asuswrt.sh
     
    Wallace likes this.
  12. Wallace

    Wallace Occasional Visitor

    Joined:
    Jun 30, 2018
    Messages:
    15
    Is there a way to log rotate in ASUSwrt firmware?
     
  13. kfp

    kfp Very Senior Member

    Joined:
    Jun 26, 2014
    Messages:
    633
    Not the answer you’re looking for but perhaps you can use ‘logger’ which writes to the syslog instead of piping it to a custom file?
     
    Wallace likes this.
  14. Wallace

    Wallace Occasional Visitor

    Joined:
    Jun 30, 2018
    Messages:
    15
    Thanks for the input.
    update-ddns-asuswrt.sh updated to use system logger.
     
    kfp likes this.
  15. Grisu

    Grisu Very Senior Member

    Joined:
    Aug 28, 2014
    Messages:
    506
    sorry does not work for me.

    IP seems to be seen correct but not updated to asus-DDNS, public_IP and MYIP is same as on modem 62.46.xxx.xxx:
    [email protected]:/tmp/mnt/2GB_stick# sh ./update-ddns-asuswrt.sh
    PUBLIC_IP : '62.46.xxx.xxx'
    DDNS_IP : '62.47.yyy.yyy'
    /tmp/myip : 62.46.xxx.xxx
    MYIP : '62.46.xxx.xxx'
    ez-ipupdate Version 3.0.11b5
    Copyright (C) 1998-2001 Angus Mackay.
    read_input ret: 1
    read_input ret: 1
    Update failed. (203)

    used this command for testing update
    [email protected]:/tmp/mnt/2GB_stick# /usr/sbin/ez-ipupdate -S dyndns -i eth0 -a 62.46.xxx.xxx -h my_name.asuscomm.com -A 2 -s nwsrv-ns1.asus.com
    ez-ipupdate Version 3.0.11b5
    Copyright (C) 1998-2001 Angus Mackay.
    read_input ret: 1
    read_input ret: 1
    Update failed. (203)

    so this line seems for me to fail.

    Shall I try different name.asuscomm.com?
    I set it before with this router and another modem in bridge-mode and is registered to me.
    http://iplookup.asus.com shows old IP 62.47.. which I had weeks ago with this test.

    Syslog showing something confusing to me as there is additional 60 to my_name, is that correct?
    Jul 4 12:10:05 update-ddns-asuswrt.sh[4100]: Public IP changed
    Jul 4 12:10:05 update-ddns-asuswrt.sh[4100]: Updating my_name.asuscomm.com to new IP: 62.46.xxx.xxx
    Jul 4 12:10:05 ddns update: ez-ipupdate: starting...
    Jul 4 12:10:05 ddns update: g_asus_ddns_mode == 2
    Jul 4 12:10:05 ddns update: connected to nwsrv-ns1.asus.com (103.10.4.108) on port 80.
    Jul 4 12:10:08 ddns update: Asus update entry:: return: HTTP/1.1 203 |myname.asuscomm.com|myname60.asuscomm.com^M Date: Wed, 04 Jul 2018 10:10:05 GMT^M Server: Apache^M X-Powered-By: PHP/5.6.30^M Content-Length: 0^M Content-Type: text/html; charset=UTF-8^M ^M
    Jul 4 12:10:08 ddns update: retval= 1, ddns_return_code (,203)
    Jul 4 12:10:08 ddns update: asusddns_update: 1
    Jul 4 12:10:08 ddns update: exit_main
     
  16. Wallace

    Wallace Occasional Visitor

    Joined:
    Jun 30, 2018
    Messages:
    15
    "my_name.asuscomm.com" is not a valid hostname.
    Underscores (_) are not allowed in hostnames.
     
  17. Grisu

    Grisu Very Senior Member

    Joined:
    Aug 28, 2014
    Messages:
    506
    it's only a placeholder for my real username (only some characters).

    Router is set to AP-mode with IP from modem-DHCP.

    Last command will produce failure too:
    echo admin > /var/spool/cron/crontabs/cron.update
    Jul 4 16:45:01 crond[288]: admin: No such file or directory

    For test loaded merlin A2 and get failure too, jffs enabled and reboot:
    scp update-ddns-asuswrt.sh to /jffs/
    cp: can't stat 'to': No such file or directory
     
    Last edited: Jul 4, 2018
  18. Wallace

    Wallace Occasional Visitor

    Joined:
    Jun 30, 2018
    Messages:
    15
    Try without "-i eth0" option, your device might not have "eth0" interface.
    Code:
    /usr/sbin/ez-ipupdate -S dyndns -a 62.46.xxx.xxx -h your-hostname.asuscomm.com -A 2 -s nwsrv-ns1.asus.com
     
  19. Grisu

    Grisu Very Senior Member

    Joined:
    Aug 28, 2014
    Messages:
    506
    same error with Merlin and jffs

    Your first command doesn't work, gives error:
    Code:
    scp update-ddns-asuswrt.sh to /jffs/
    correct I think without "to":
    scp update-ddns-asuswrt.sh /jffs/

    I think there is a eth0 on my RT-AC68U (got little help to find this):
    eth0: Broadcom BCM47XX 10/100/1000 Mbps Ethernet Controller 6.37.14.126 (r561982)
    eth1: Broadcom BCM4360 802.11 Wireless Controller 6.37.14.126 (r561982)
    eth2: Broadcom BCM4360 802.11 Wireless Controller 6.37.14.126 (r561982)

    Suggestion: will it need any port forward on my modem to update IP?

    Another interesting thing: my system time shows 19:49:30 and cron-job ran with error and time stamp 19:50:08, so about a half minute before system time?!?
     
    Last edited: Jul 4, 2018
  20. kfp

    kfp Very Senior Member

    Joined:
    Jun 26, 2014
    Messages:
    633
    That command is no meant to be copy and pasted, it’s more an instruction. It’s just transferring the EDITED script (with name of your choosing for domain name) to the router.

    All Most* devices have eth0, that’s the WAN/Internet port.

    Edit: PPPoE might not

    You won’t need port forwarding anywhere for this. Do you mean modem or router?

    Half minute before or after system time? The error timestamp looks to be LATER than the system timestamp, not sure what you’re trying to say here.
     
    Last edited: Jul 4, 2018
  21. Grisu

    Grisu Very Senior Member

    Joined:
    Aug 28, 2014
    Messages:
    506
    sorry, thought 'Code:' would really mean code and not instruction.

    I mean modem (modem-router of course, bridge not possible) which is on the line.

    So script with "-i eth0" should be fine, is it that what you want to say?

    Sys-log is running 1/2 minute before system time so it shows later time stamp like clock is running earlier than system clock.
    But before or late, maybe only my broken english - sorry for that!
    In my opinion it should be system time and not something around, thats all I wanted to say.
    I am wondering to get recent time stamps from the future ... like my router knows what will happen in a minute, should bet on horse races with it ...

    Does it have a separate RTC?
     
    Last edited: Jul 4, 2018
Please support SNBForums! Just click on this link before you buy something from Amazon and we'll get a small commission on anything you buy. Thanks!