OpenWrt Forum Archive

Topic: no-ip.com won't accept http forced update to prevent 60-day IP expire

The content of this topic has been archived on 28 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

...if your IP stays the same.

Openwrt backfire with ddns-scripts
ISP gives you dynamic IP
DDNS provider: no-ip.com

If you have set up your router like this, in some cases, its ddns will inevitably expire in 60 days.

Explanation:
Dynamic DNS feature offered by no-ip.com has 60-day expire period, which means if you don't update a host's IP in 60 days it will be deleted.
Well it seems fair enough, but there is a catch I have not noticed.

This 'update' they are talking about does not include "request with the same IP"

Many home routers are operated on dynamic IP environment, but the IP they get almost never get changed, because we don't usually power off our routers. I believe this is rather common situation. If you have this nearly-static IP situation and are using no-ip.com through ddns-scripts, it will expire in 60 days because any http update request, even forced update, won't be counted as an 'update' because the IP provided with the request is same as the already registered one.

If your IP doesn't get changed, ddns-scripts' forced_interval option is useless with no-ip.com and won't prevent its deletion in 60 days which is very annoying and, in some cases, dangerous if you don't know about it.

Any corrections or recommendations are welcome.


* FYI, via their web site, any update, even without any changes, counts as an update, so 60-day countdown is reset.

(Last edited by test011 on 13 Mar 2011, 07:58)

patched on my router.
When force update, the script would update a reversed ip(ex. 1.2.3.4 -> 4.3.2.1) first.
After 5 second, it would update origin ip to ddns server.
patch is here.

====================================
diff --git a/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh b/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh
index 0c5718b..2bcdfdb 100755
--- a/usr/lib/ddns/dynamic_dns_updater.sh
+++ b//usr/lib/ddns/dynamic_dns_updater.sh
@@ -308,6 +308,18 @@ do
                final_url=$(echo $final_url | sed s/"\[HTTPAUTH\]"/"$username${password:+:$password}"/g )
                final_url=$(echo $final_url | sed s/"\[IP\]"/"$current_ip"/g )

+               if [ $force_interval_seconds -lt $time_since_update ]
+               then
+                       reversed_ip_final_url=$(echo $final_url | sed -e "s/\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)/\4.\3.\2.\1/" )
+                       
+                       verbose_echo "update with reversed ip to make force successfully (*workaround*)"
+                       verbose_echo "updating with url=\"$reversed_ip_final_url\""
+               
+                       reversed_ip_update_output=$( $retrieve_prog "$reversed_ip_final_url" )
+                       verbose_echo "Reversed IP Update Output:"
+                       verbose_echo "$reversed_ip_update_output (temp)"
+                       sleep 5
+               fi

                verbose_echo "updating with url=\"$final_url\""
====================================

Nicely done, I applied here too smile

Thanks for the patch !!!

Here is a version of the patch updated for Attitude Adjustment.
Note that the IP address is altered in a way guaranteed to change it -- not reversed as in the backfire patch.

==============================================
--- /usr/lib/ddns/dynamic_dns_updater.sh-fromAttitudeAdjustment    2013-03-08 07:54:59.000000000 -0800
+++ /usr/lib/ddns/dynamic_dns_updater.sh    2013-10-14 19:33:14.000000000 -0700
@@ -100,7 +100,7 @@

if [ "x$use_https" = "x1" ]
then
-    retrieve_prog="/usr/bin/curl "
+    retrieve_prog="/usr/bin/curl -s "
    if [ -f "$cacert" ]
    then
        retrieve_prog="${retrieve_prog}--cacert $cacert "
@@ -109,7 +109,7 @@
        retrieve_prog="${retrieve_prog}--capath $cacert "
    fi
else
-    retrieve_prog="/usr/bin/wget -O - ";
+    retrieve_prog="/usr/bin/wget -q -O - ";
fi

service_file="/usr/lib/ddns/services"
@@ -305,24 +305,30 @@
                final_url=$(echo $final_url | sed s^"$replace_name"^"$replace_value"^g )
            fi
        done
-        final_url=$(echo $final_url | sed s^"\[HTTPAUTH\]"^"${username//^/\\^}${password:+:${password//^/\\^}}"^g )
-        final_url=$(echo $final_url | sed s/"\[IP\]"/"$current_ip"/g )
-
-
+        site_url=$(echo $final_url | sed s^"\[HTTPAUTH\]"^"${username//^/\\^}${password:+:${password//^/\\^}}"^g )
+        if [ "$current_ip" = "$registered_ip" ];then
+            #update with a bogus ip to convince DDNS provider that the name is "in use"
+            oldIFS=$IFS; IFS='.'; set -- $current_ip; IFS=$oldIFS
+            bogus_ip="$((($1+1)&255)).$2.$3.$4"
+            final_url=$(echo $site_url | sed s/"\[IP\]"/"$bogus_ip"/g )
+            verbose_echo "altering $current_ip with url=\"$final_url\""
+            update_output=$( $retrieve_prog "$final_url" ) || {
+                verbose_echo "bogus update failed"
+                sleep $retry_interval_seconds
+                continue
+            }
+            verbose_echo "Bogus Update Successful:  $update_output"
+        fi
+        final_url=$(echo $site_url | sed s/"\[IP\]"/"$current_ip"/g )
        verbose_echo "updating with url=\"$final_url\""

        #here we actually connect, and perform the update
-        update_output=$( $retrieve_prog "$final_url" )
-        if [ $? -gt 0 ]
-        then
+        update_output=$( $retrieve_prog "$final_url" ) || {
            verbose_echo "update failed"
            sleep $retry_interval_seconds
            continue
-        fi
-
-        verbose_echo "Update Output:"
-        verbose_echo "$update_output"
-        verbose_echo ""
+        }
+        verbose_echo "Update Output:  $update_output"

        #save the time of the update
        current_time=$(monotonic_time)

Could you tell me how to perfom this patch? I've searched for the solution in documentation, but I didn't get the solution.

-Do I have to save this text as noip.patch and run "patch noip.patch"? Or do I have to use quilt? Also "patch" and "quilt" are not installed on my TL-WR1043ND with Attitude Adjustment.

-Would it also be possible to update the dynamic_dns_updater.sh manually? In this case should I remove all lines with - and add the lines with +? What should I do with the lines where is nothing in front?

It would be really cool, if you could tell me how to perfom this update in the easiest way.

Thank you very much!

Or you could just click the link they email you to prevent it expiring... It's not that hard.

qasdfdsaq wrote:

Or you could just click the link they email you to prevent it expiring... It's not that hard.

sure, it is. Because you get it every 30 days and have only 7 days time to click the link. So, if you are on holidays or sth. your domain would be gone. Also I really like to know, how to apply this kind of patches generally, because I like to lern the process..

While an automated script may be handy if you are unable to check your emails at least once every month, you are still technically violating their TOS.

(Last edited by qasdfdsaq on 27 May 2014, 00:22)

qasdfdsaq wrote:

While an automated script may be handy if you are unable to check your emails at least once every month, you are still technically violating their TOS.

Thank you very much, qasdfdsaq. Your posts are really helpful and solving the Problem.. Btw. you have to check your Mails at least once a week. wink

*push* Could anybody give me a little hint? Thank you very much!

The updated patch by Brent to version of ddns-scripts 1.0.0-23 is:

--- dynamic_dns_updater.sh.orig    2014-12-24 11:15:03.000000000 +0100
+++ dynamic_dns_updater.sh    2014-12-24 11:19:03.064175651 +0100
@@ -102,7 +102,7 @@

#some constants

-retrieve_prog="/usr/bin/wget -O - ";
+retrieve_prog="/usr/bin/wget -q -O - ";
if [ "x$use_https" = "x1" ]
then
    /usr/bin/wget --version 2>&1 |grep -q "\+ssl"
@@ -116,7 +116,7 @@
            retrieve_prog="${retrieve_prog}--ca-directory=${cacert} "
        fi
    else
-        retrieve_prog="/usr/bin/curl "
+        retrieve_prog="/usr/bin/curl -s "
        if [ -f "$cacert" ]
        then
            retrieve_prog="${retrieve_prog}--cacert $cacert "
@@ -310,25 +310,34 @@
                final_url=$(echo $final_url | sed s^"$replace_name"^"$replace_value"^g )
            fi
        done
-        final_url=$(echo $final_url | sed s^"\[HTTPAUTH\]"^"${username//^/\\^}${password:+:${password//^/\\^}}"^g )
-        final_url=$(echo $final_url | sed s/"\[IP\]"/"$current_ip"/g )
+    site_url=$(echo $final_url | sed s^"\[HTTPAUTH\]"^"${username//^/\\^}${password:+:${password//^/\\^}}"^g )
+    if [ "$current_ip" = "$registered_ip" ];then
+      #update with a bogus ip to convince DDNS provider that the name is "in use"
+      oldIFS=$IFS; IFS='.'; set -- $current_ip; IFS=$oldIFS
+      bogus_ip="$((($1+1)&255)).$2.$3.$4"
+      final_url=$(echo $site_url | sed s/"\[IP\]"/"$bogus_ip"/g )
+      verbose_echo "altering $current_ip with url=\"$final_url\""
+      update_output=$( $retrieve_prog "$final_url" ) || {
+        verbose_echo "bogus update failed"
+        sleep $retry_interval_seconds
+        continue
+      }
+      verbose_echo "Bogus Update Successful:  $update_output"
+    fi
+    final_url=$(echo $site_url | sed s/"\[IP\]"/"$current_ip"/g )


        verbose_echo "updating with url=\"$final_url\""

        #here we actually connect, and perform the update
-        update_output=$( $retrieve_prog "$final_url" )
-        if [ $? -gt 0 ]
-        then
+    update_output=$( $retrieve_prog "$final_url" ) || {
            syslog_echo "update failed, retrying in $retry_interval_seconds seconds"
            verbose_echo "update failed"
            sleep $retry_interval_seconds
            continue
-        fi
+    }
        syslog_echo "Update successful"
-        verbose_echo "Update Output:"
-        verbose_echo "$update_output"
-        verbose_echo ""
+    verbose_echo "Update Output:  $update_output"

        #save the time of the update
        current_time=$(monotonic_time)

I've used the cmtsij version because I've found it much more simple. I've edited the sh file directly over ssh. Everything working great!!! Now my domain wont expire anymore! smile

Can anyone provide a link to this script please?
Im currently running somewhat latest opernwrt from CC trunk and the built in ddns script doesnt seem to have this patch. Thus the force update doesnt work for me.Thanks

The discussion might have continued from here.