Showing posts with label Dynamic DNS. Show all posts
Showing posts with label Dynamic DNS. Show all posts

Thursday, 8 October 2009

Problem with DynamicDNS and SSH or Sever PART2 - Practice in BASH

Ok, if I am clear with theory, I can start with practice.


  • Domain - that was the easiest part, you can choose between DYNDNS or NO-IP, both are providing the same service domain assigning to dynamic DNS, I`ve chosen , they are providing better service.

  • Second I thought, I need something telling my server to see for domain, with every day changing IP. One way every day assigning the new born address or do some automation script


Of course the script would be the best solution, and for LINUX we have an option BASH scripting, easy and work`s on any Linux distro. I will explain how I`ve come to final script but here is the solution.

First we need to write write it in the /etc/cron.hourly/dyndns (the name of file)



:$ sudo gedit /etc/cron.hourly/dyndns

You can choose nano if you like it.

There are two different versions BASH (I mentioned) or Pyton. Use whichever you want from below, but make sure the file name is dyndns without extension (no .py) because the scripts in cron.hourly won't run if they have an extension;


#!/bin/bash
# Set the user-name and password for the dyndns account
USERNAME=
PASSWORD=
# Set the system being used to either static or dynamic DNS
SYSTEM=dyndns
# Set the hostname for the record to change
DYNHOST=
# Set whether to wildcard the DNS entry, i.e. *.$DYNHOST
WILDCARD=OFF
############################################
## DO NOT EDIT ANYTHING BEYOND THIS POINT ##
############################################
if [ -z "$DYNDNS" ]; then
DYNDNS="$DYNHOST"
fi
if [ -z "$DNSWILD"]; then
DNSWILD="$WILDCARD"
fi
LOOKUP=`host $DYNHOST | awk '{print $4}'`
MYIP=`curl -s http://www.ipchicken.com | awk '/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/ {print $1}'`
# Do the work
if [ "$LOOKUP" = "$MYIP" ]; then
echo "No change in DNS entry."
else
echo `lynx -auth=${USERNAME}:${PASSWORD} -source "http://members.dyndns.org:8245/nic/update?system=${SYSTEM}&hostname=${DYNDNS}&myip=${MYIP}&wildcard=${DNSWILD}"`
fi



This version works, but not in all cases, be careful and test when you upgrade or reinstall you Linux distro, it could not work properly.
An remember to set configuration for dyndns.com, so your dynamic IP address is updated properly in time period 60 mins.
Article inspired by http://webupd8.blogspot.com.

Problem with DynamicDNS and SSH or Sever PART1 - theory.

Hi, just a two months ago I started a new company, offering new and innovative type of services "Remote office assistant" . Early in the begining I`ve got an Idea to set up a server in my as a base, situated in my office.
At first stage brilliant idea - have server, switch it on, install LINUX and let`s go.

Hey guys not so easy, my ISP company offered only Dynamic DNS support or (as they said) almost impossible to jump to static IP, except to pay 10 times more a month. OK, that was not a solution, but I did not gave up, after some research and road back to theory I found out:


  • First, what says definition of Dynamic DNS - DNS is a method, protocol, or network service that provides the capability for a networked device, such as a router or computer system using the Internet Protocol Suite, to notify a domain name server to change, in real time (ad-hoc) the active DNS configuration of its configured host names, addresses or other information stored in DNS. A popular application of dynamic DNS is to provide a residential user's Internet gateway that has a variable, often changing, IP address with a well known host name resolvable by network applications through standard DNS queries;

  • Second - Conclusion from theory, this is something that changes, not static, so almost impossible to assign to server or even desktop, if you want your deals with ssh and network based solutions;

  • Third - once again back to theory now lets see functions. The user of DNS may be supplied with a different IP address every time an Internet connection to the service provider is made, so there is no stable address to connect to. If a DDNS service is used to associate a fixed address to a device, then the user can, for example, establish a Virtual Private Network (VPN) to the network using that address. As a detailed example, the IP address can be 123.234.111.112 one day, 123.124.45.15 the next, but the DDNS address will always be, say, myhome.ddns.org. A remote control program such as VNC server can be left running on a machine in the network; the user can connect to the network by establishing a password-protected VPN to myhome.ddns.org, then connect to the machine using a VNC client program;

  • Fourth - last. So From this we need a some third party service provider, who can assign an domain to may always changing IP addresses.


I`ve finnished with my theory, inspired from wikipedia article , thats it for today. I will continue with practical issues soon on PART2.