10% Off All Orders + Free Shipping
Use Coupon Code SCKBLACK2017
Hurry! Sale Ends 11/24/17
Layouts and Modeling – The Advantages of Modeling your Surveillance Camera Positions
October 20, 2014
Our Goofiest Security Camera Demo videos.
October 22, 2014

Setting up a DDNS Service using GoDaddy and 3rd Party DNS provider

logogodaddy

As you all know GoDaddy is one of the major Domain Registrars. You can simply click and in matter of minutes you can own a domain name. A lot of you want the ability to add a sub directory and point it to a Surveillance equipment, and thus give you access to your Recording Device by simply opening up your browser and imputing “http://mycctv.mydomainname.com”. By doing so, this will point to your recorder. You can also do this to host your own server, keeping in mind that the bandwidth from serving your own webpage can be large. Many of you already know what DNS is and how it relates the Domain name to an IP address, so that anyone trying to navigate to the Webpage or Server will get routed to the correct IP. This article will explain the process of setting up a DDNS service using GoDaddy and 3rd party DNS provider.

Your ISP will provide you with a Dynamic IP address, This means that the NODE in which your Modem will be connected to will get an IP that will change depending on the lease time that the NODE provides. This can be Hours, Days, or if you are lucky, a Year. This is why many people are using a DDNS service that allows a device to run a script that will update the Server with the correct IP address. This type of service does not come for free and many are looking for a method  that will allow them to do this without giving away money. This also helps to know how DNS works as well as learning a bit of code.

The steps to get Dynamic DNS are:

  • Register into a free DNS service that offers an API.
  • Configure the DNS server and add our domain.
  • Change the GoDaddy DNS provider to the new free DNS provider.
  • Create a script that checks if the IP address of the server has changed and if so, automatically update the DNS server IP.
  • Put the script in the CRON every 10 minutes

Lets start with registering into a free DNS service that offers an API. There are many that will provide this and we will be utilizing FreeDNS

Once you have signed up for an account we will have to configure the DNS server and add your domain.

Configure DNS server

This is where we will need to add our domain name. For this we need to click on “Domain” and fill the space with the information. Its very important to select Shared State to “Private”. The rest of the fields leave blank.

Once we have clicked on Submit, we will get the following:

“Domain DomainName.com has been added to the system.

Domain has been marked as BROKEN until the nightly check verifies the domain is properly delegated to afraid.org.”

This message comes from Godaddy not having the correct Server Names. Lets dive into this.

Changing the DNS with the new free DNS providers server Address.

DNS godaddy set

The Servers that you will need to add as “CUSTOM SERVERS” are NS1.AFRAID.ORG, NS2.AFRAID.ORG. Keep in mind this is is for FREEDNS.org, and so it may be different for your DNS provider. Once you have done this, it may take up a few hours to reflect onto your account.

Next we will have to write a script that will notify the DNS service with the new IP if it changes. There are many scripts for both Windows and Unix that allow us to update our IP. In all of them you just have to change the URL + ID assigned to us by FreeDNS in our account that we can get out of our control panel FreeDNS in DNS Dynamic menu. The address we have on Direct URL is what we will use in our scripts, copy it to the clipboard for pasting into the script that I put below.

#!/bin/bash
 
##############################################################################
#
#  application name: dnsactual
#  other files: dnsactual.conf (keeps the last updated ip)
#               dnsactual.log  (register date & time of the actualization)
#  Author: Ernest Danton
#  Date: 01/29/2007
##############################################################################
 
HOME="/home/dnsactual"
 
echo "#######################################" >> $HOME"/dnsactual.log"
echo `date` "--- Start ---" >> $HOME"/dnsactual.log"
if test -f $HOME"/dnsactual.conf"
then
    CacheIP=$(cat $HOME"/dnsactual.conf")
fi
# Sometimes wget does not return anything, which is called until the return
cont=0
while [ -z "$CurreIP" ]
do
        CurreIP=$(wget http://ipecho.net/plain  -o /dev/null -O /dev/stdout)        
        cont=`expr $cont + 1`
        echo `date` "Iteration number: " $cont >> $HOME"/dnsactual.log"
done
 
echo `date` "Current IP: $CurreIP Cached IP: $CacheIP" >> $HOME"/dnsactual.log"
 
if [ "$CurreIP" = "$CacheIP" ]
then
    # Both IP are equal
    echo "Update not required..." >> $HOME"/dnsactual.log"
else
    # The IP has change
    echo `date` "Updating http://free.afraid.org with IP:" $CurreIP >> $HOME"/dnsactual.log"
    msgerror=`wget http://freedns.afraid.org/dynamic/update.php?xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -o /dev/null -O /dev/stdout`
 
    echo `date` $msgerror >> $HOME"/dnsactual.log"
 
    SUBJECT="IP Address Has Changed on your DDNS"
    # Email To ?
    EMAIL="someone@gmail.com"
    # Email text/message
    EMAILMESSAGE=$HOME"/email.txt"
    echo "Changed the FreeDNS IP to $CurreIP " >>$EMAILMESSAGE
    # send an email using /bin/mail
    /usr/bin/mail -s "$SUBJECT" -a "From: BlogName<blogmail@blogname.com>" "$EMAIL" < $EMAILMESSAGE     echo `date` "Mail Sent: " $? >> $HOME"/dnsactual.log"
    rm $EMAILMESSAGE
 
fi
rm -f $HOME"/dnsactual.conf"
echo $CurreIP > $HOME"/dnsactual.conf"
echo `date` "--- End ---" >> $HOME"/dnsactual.log"

 

Once you have done this and uploaded it to the server, we will need to setup the CRON service script and this will run every ten minutes.

name@username:~$ sudo crontab -e

# FreeDNS actualizacion de IP de dynamic DNS
*/10 * * * * bash /home/user/dnsactual/dnsactual.sh

Once you have completed these steps you should set up your port forwarding on your router. Depending on your router is how you will need to setup your port forwarding rules. In my example I have a firewall and a complex network that is more restrictive than normal. I opened the ports for HTTP as well as for the Mobile. This can be found on the recorder’s Network tab under Connection. In this case I am only focusing on ports 80 for the (http) as well as TCP port (37777)

Screenshot (128)

Once you have done this and GoDaddy has updated the DNS servers to point to the correct server and your CRON script is running the Update script, you will have a free DDNS service. Of course this is for a more advanced user that has some knowledge when it comes to CRON, DNS, and others. This is why I did not go into detail as to what sections you need to change as it would mean that I would have a 3000 word article as opposed to a smaller one with just the necessary information to get you up and running. If you have any input for this article feel free and contact me. You can also contact me if you have an item that want to integrate with any of our systems.

Jose Malave
Jose Malave
IT Director. for Techpro Security Products - Security Camera King

Leave a Reply

Your email address will not be published. Required fields are marked *