Hi Folks! It has been long time, I have not posted anything since December. Actually I had to do many things. I was battling upkeep of Company Servers and upgrading them. But during that time I learned many things and I would like to share with you all. In this post I will introduce you about dynamic DNS, which saves you hassle of persistently changing of your Router IP by ISP. What is Dynamic DNS ? Dynamic DNS (DDNS) is a service that maps Internet domains name to IP addresses. It is similar Internet Domain Name service(DNS) but some differences. Unlike DNS that allows mapping static IP to domain name and domain name to static IP, Dynamic DNS maps your domain name to your dynamic IP. By doing that even though, your IP changes you will access your home router with the your domain name that you choose. And you will be able to access your IP camera or IoTs. But Unlike DNS service that you configure it only once for one domain name, DDNS needs to be informed each time IP has changed. But do be afraid.:) There are many Dynamic DNS services on the internet enterprise or free. In this post I will introduce you about free dynamic dns, which I am currently using it.–duckns Duck DNS is free dynamic domain name services. You can signup with your google, twitter, facebook or reddit account. After successfully login, duckdns create a token for you. You will update your new IP with this token so keep it secret.(Figure-1)
Also write your domain name you choose in to the box with the name domain.(Figure-2)
Almost done.We have just couple of things to do. As I mention before, we have to feed dynamic DNS service with the new IP, each time IP changes. To do so, I wrote a shell script which pools every 5 minutes to check if IP changes. For more information you can visit the link. https://www.duckdns.org/install.jsp You can tweak the shell script for your own purpose. (If you use this script do not forget to replace XYXY, xxxxxxxx-yyyy-xxxx-yyyy-zzzzzzzzzzzz and mail addresses with yours!) Edited: To execute script below every 5 minutes, we need to add the script on a crontab.
*/5 * * * * ipchecker.sh
#!/bin/bash newip=$(curl -s ifconfig.co) oldip=$(head ip.txt) echo "old:$oldip" echo "new:$newip" if [ "$oldip" != "$newip" ] ; then echo "$newip" > ip.txt /usr/bin/mail -s "oldIP:$oldip/NewIP:$newip" firstname.lastname@example.org < ip.txt #do not forget to create a folder with the name "duckdns" #$mkdir ~/duckdns echo url="https://www.duckdns.org/update?domains=XYXY&token=xxxxxxxx-yyyy-xxxx-yyyy-zzzzzzzzzzzz&ip=" | curl -k -o ~/duckdns/duck.log -K - res=$? if [ "$res" -eq 0 ] ; then /usr/bin/dig XYXY.duckdns.org +short | /usr/bin/mail -s "DuckDNS IP changed" email@example.com else /usr/bin/mail -s "DuckDNS Error!" firstname.lastname@example.org<. fi fi