What's new

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!

Forcing update can be done in 2 ways.
1. In router gui under WAN->DDNS click Apply
2. SSH to the router and execute sh /jffs/scripts/ddns-start
 
As i can see, ddns-started is only Called at the end of a DDNS update process.
Maybe I want to use wan-event, Called after an event related to the WAN interface occurs.??
 
What to put on chmod?
And how to edit the script?
I'm really newbie at this
 
What to put on chmod?
And how to edit the script?
I'm really newbie at this

Once you ssh to the router run command chmod +x /jffs/scripts/ddns-start. This will make the script executable. As for editing the file you can use vi or nano editors. Find out on web how to use it. nano is easy to use.
1. cd /jffs/scripts
2. nano ddns-start
3. Edit the file. You can copy paste and edit
4. Save the file using ctrl-o and then ctrl-x

Done.
 
It didn't worked as expected:

Code:
Mar 13 01:28:12 rc_service: httpd 1000:notify_rc restart_ddns #when i set to custom DNS
Mar 13 01:28:12 custom_script: Running /jffs/scripts/service-event (args: restart ddns)
Mar 13 01:28:12 start_ddns: update CUSTOM , wan_unit 0
Mar 13 01:28:12 custom_script: Running /jffs/scripts/ddns-start (args: 192.168.1.2)
Mar 13 01:28:14 ddns: Completed custom ddns update #correctly updated
Mar 13 01:28:48 DualWAN: skip single wan wan_led_control - WANRED off # i forced an IP update from ISP
Mar 13 01:29:07 WAN_Connection: WAN was restored. #new IP assigned
Mar 13 01:29:07 rc_service: wanduck 927:notify_rc stop_ntpd
Mar 13 01:29:07 custom_script: Running /jffs/scripts/service-event (args: stop ntpd)
Mar 13 01:29:07 rc_service: wanduck 927:notify_rc start_ntpd
Mar 13 01:29:07 rc_service: waitting "stop_ntpd" via wanduck ...
Mar 13 01:29:08 custom_script: Running /jffs/scripts/service-event (args: start ntpd)
Mar 13 01:29:08 ntpd: Started ntpd
As you can see, as the WAN as restored (new IP assigned), it didn't update my external IP address
 
It didn't worked as expected:

Code:
Mar 13 01:28:12 rc_service: httpd 1000:notify_rc restart_ddns #when i set to custom DNS
Mar 13 01:28:12 custom_script: Running /jffs/scripts/service-event (args: restart ddns)
Mar 13 01:28:12 start_ddns: update CUSTOM , wan_unit 0
Mar 13 01:28:12 custom_script: Running /jffs/scripts/ddns-start (args: 192.168.1.2)
Mar 13 01:28:14 ddns: Completed custom ddns update #correctly updated
Mar 13 01:28:48 DualWAN: skip single wan wan_led_control - WANRED off # i forced an IP update from ISP
Mar 13 01:29:07 WAN_Connection: WAN was restored. #new IP assigned
Mar 13 01:29:07 rc_service: wanduck 927:notify_rc stop_ntpd
Mar 13 01:29:07 custom_script: Running /jffs/scripts/service-event (args: stop ntpd)
Mar 13 01:29:07 rc_service: wanduck 927:notify_rc start_ntpd
Mar 13 01:29:07 rc_service: waitting "stop_ntpd" via wanduck ...
Mar 13 01:29:08 custom_script: Running /jffs/scripts/service-event (args: start ntpd)
Mar 13 01:29:08 ntpd: Started ntpd
As you can see, as the WAN as restored (new IP assigned), it didn't update my external IP address
The problem I see is your script ddns-start is passing your local IP to DDNS server.
Running /jffs/scripts/ddns-start (args: 192.168.1.2)

You have to modify the script and provide DDNS provider your WAN IP. Look at the script I gave you. You will see a line

IP="$(curl -fs4 https://myip.dnsomatic.com/)"

This retrieves WAN IP and then I call DDNS provider API and pass the WAN IP

curl --silent "https://www.duckdns.org/update?domains=$SUBDOMAIN&token=$TOKEN&ip=$IP" >/dev/null 2>&1

Any other code you may have put in service-event for DDNS you need to remove it.

You have to do similar thing as well. When the code is working properly you can verify that
1. It completes without error
2. Access DDNS provider web page and you should see your WAN IP there.
 
But now you need a reliable way to detect the public IP change from behind your double-NAT, so you can trigger ddns automatically.
 
But now you need a reliable way to detect the public IP change from behind your double-NAT, so you can trigger ddns automatically.
That’s already build in to Merlin firmware if using custom method and ddns-start script. This is in wiki documents written by Merlin.
As I mentioned when firmware detects WAN IP change it calls ddns-start script.
 
That’s already build in to Merlin firmware if using custom method and ddns-start script. This is in wiki documents written by Merlin.
As I mentioned when firmware detects WAN IP change it calls ddns-start script.
I guess it’s late for me and my thinking is slowing down, but how will DDNS get triggered if the router’s own WAN IP (which is not the public IP) does not change?
 
That’s already build in to Merlin firmware if using custom method and ddns-start script. This is in wiki documents written by Merlin.
As I mentioned when firmware detects WAN IP change it calls ddns-start script.
Maybe its built in, but it doesn't work.
Because when WAN ip changes it doesn't detect.

Simpliest way - I set up a cron job every 5 minutes to update the IP on dsomatic :)
 
So, I created a cron job each 10 minutes to run this script, and it works very well.
Code:
USERNAME=NAME
PASSWORD=PASS
HOSTNAME=all.dnsomatic.com
CURRENTIP="$(curl -fs4 https://myip.dnsomatic.com/)"

/usr/sbin/curl -k --silent -u "$USERNAME:$PASSWORD" "https://updates.dnsomatic.com/nic/update?hostname=$HOSTNAME&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG&&myip=$CURRENTIP" > /dev/null
if [ $? -eq 0 ]; then
  /sbin/ddns_custom_updated 1
else
  /sbin/ddns_custom_updated 0
fi

Howver, sometimes I get response "abuse" and the IP doesn't update, as i'm abusing the server. So, I came up with an ideia, but as I dont know which programming language is that and I dont know it very well, I need something like that (i'll put in red what I want to do). If everyone can write that script for me, that'd be wonderfull!!!

USERNAME=NAME
PASSWORD=PASS
HOSTNAME=all.dnsomatic.com
CURRENTIP="$(curl -fs4 https://myip.dnsomatic.com/)"
IPONDOMAIN = get the IP that the domain is currently pointing at

if CURRENTIP different than IPONDOMAIN then
/usr/sbin/curl -k --silent -u "$USERNAME:$PASSWORD" "https://updates.dnsomatic.com/nic/u...=NOCHG&mx=NOCHG&backmx=NOCHG&&myip=$CURRENTIP" > /dev/null

if [ $? -eq 0 ]; then
/sbin/ddns_custom_updated 1
else
/sbin/ddns_custom_updated 0
fi
ELSE
print_message_on_log "Nothing to update"
end if


Thanks!
 
Code:
IPONDOMAIN="$(nslookup my.example.com | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' | awk 'NR>2')"

Code:
if [ "$CURRENTIP" != "$IPONDOMAIN” ]; then
Perfect dave, thank you so much!

And how to write the "else", "end if" and how to write a message to router log (so I can read them on log page)?
 
Perfect dave, thank you so much!

And how to write the "else", "end if" and how to write a message to router log (so I can read them on log page)?
I wouldn’t want a log message every 5 minutes in the syslog just to say nothing happened.
Code:
else
  logger -t myddnsscript.sh "Nothing to update"
fi
 
I wouldn’t want a log message every 5 minutes in the syslog just to say nothing happened.
Code:
else
  logger -t myddnsscript.sh "Nothing to update"
fi
Yes, it's just to test right now to see if it runs ok! :)

thank you sir.!!!

Right now I have a 5 minutes message saying it's updated... So the idea is stop it :)
 
Which programming language is this? So I can study a bit...
 
It is not a good behave to update every 5-10 minutes. You will be banned very soon. Cache your ddns update and ONLY update when it's changed. {ok post 31}
 
Last edited:
It is not a good behave to update every 5-10 minutes. You will be banned very soon. Cache your ddns update and ONLY update when it's changed. {ok post 31}
Yes, i just managed, with Help from Dave, to do that.

First i do a nslookup for my domain. If my current ip is the same as nslookup, doesn't do nothing. If it's different, than updates.
 
Yes, i just managed, with Help from Dave, to do that.

First i do a nslookup for my domain. If my current ip is the same as nslookup, doesn't do nothing. If it's different, than updates.
What address do you lookup? okey your ddns name..........
 
Last edited:

Similar threads

Latest 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