DreamHost vs. Dynamic DNS

DreamHost is one of the top five web hosting companies according to Lifehacker. That is the main reason why I chose and went with them for my web hosting. The first five hours after I transferred and registered my domain with them was hell. BUT, BUT customer service chat was very helpful and did not fail me at all with every problems that I had. Of course, after I registered my domain with them I wanted to do my dynamic DNS so I can access services and my server at home. It took awhile for the DNS to propagate but it is now working and that is why my blog is up as well!

So why do I want dynamic DNS and what is its benefits to me?

I defined dynamic DNS on my Introduction post as a method of linking your domain name with your changing IP address. I have Cox as my Internet Service Provider and of course I do not have a static IP at home so my IP address changes and I honestly do not know when. It all  depends on your ISP’s setup.  Now, I do have some services and two servers running at home. It is very convenient for me to have dynamic DNS setup so I can access all those services and my servers. For example, I can easily connect to my servers via SSH (Security Shell). I use different programs depending what operating system I am on like on Windows I use Putty. Having dynamic DNS constantly updating my domain, I do not have to worry about what IP address to use to connect to my home network, I will just use my domain name and it will direct to my home IP address. It would be such a pain to figure out what your IP address is and update it in your domain every time.

I am going to show you one method on setting up a dynamic DNS for your DreamHost domain. Since I have an Ubuntu Server at home, I decided to go with perl script. Why? Because it is easy to setup. If you have Windows, it will work too but you just have to install ActivePerl. Let’s get started!

1. Install Perl, if you do not have it yet.

You can either go to your Ubuntu Software Center and search for perl.

Ubuntu Software Center

 

or if you prefer using terminal.

sudo apt-get install perl

 

2. We need to go to our DreamHost’s panel. From the menus to the left, under DreamHost, go to Web Panel API. You will see a lot of functionality but we only need a couple. First box is comment, go ahead and label your API. We are going to check three things.

 dns-add_record

 dns-list_records

 dns-remove_record

or if you like you can just check one,

 All dns functions

on the very bottom, click “Generate a new API Key now!” 

You will then see your API Key, date it was created, comment, and what functions it has access to. If you make a mistake like I did at first, you would have to destroy it and re-make it. Take note of where this API is because we will go back to it later to copy the API key.

3. Since we are already on DreamHost, we are going to add an A record, it is used to point a hostname to an IP address. This is where our IP address will go.

Under Domains, click Manage Domains. You will then see the list of your domains. Now, choose or create a domain that you will want to be updated with your IP address. For example, update.hostname.com. Once you created or chosen, click DNS. From here we are going to add a custom DNS record.

Screenshot from 2014-02-02 00:32:12

 

Put the hostname you want dynamic DNS on.

 

Name: (yourhostname)

Leave the type as A record.

Type: A

As for the value, you can put any IP address here and it will take it. What I do here is, I put 127.0.0.1 so I can check if the script is working if it changed to my IP address.

Value: 127.0.0.1

and click “Add Record Now!”

 

4. We’re going back to Ubuntu and we are going to download the script.

DreamCLI.zip

DreamDNS.tar.bz2

Both are perl scripts but I used the tar.bz2 version. If you prefer downloading it from the origin, you can do so. Here’s the link. It is located at the very bottom.

Now it is up to you where you will place the file. I just saved it in my home folder.

You will then extract the file. I used my Terminal to do it.

tar xjf dreamdns.tar.bz2

This command will extract the file where the tar.bz2 file is.

5. Time to edit the file dreamdns.pl or dreamcli.pl. Go to the directory you saved the file. Again, if you have a desktop GUI, you can use that or Terminal whichever you prefer.

I usually use the terminal so let’s use that.

sudo vi /path/where/saved/dreamdns.pl

Now there are instructions inside this text file so if you want to follow that you can do so.  I used the file dreamdns.pl to specify which line I edited.

First we are going to add your domain that we added an A record a while ago. If you forgot which one it was, go back to your DreamHost’s manage domains. Be aware that your entries should be in single quotations or you will get an error later on.

Line 95

my $domain = ‘mydns.com’;

Next would be adding your username which will be the email you used to register for your DreamHost account.

Line 99

my $username = ’email@email.com’;

The next will be our API key that we created a while ago. Go back to your Web Panel API and copy the API key for the DNS service that we created.

Line 103

my $apikey = ‘M**************O’;

Lastly, we are going to set the script to run as daemon in the background so you do not have to worry about it every time your computer is on. You do not have to have it in quotations. Just set it to 1.

Line 114

my $daemonize = 1;

This step is OPTIONAL.

on the file the default update interval is an hour and I wanted to change it to thirty minutes (1800s)

Line 118

my $interval = 1800;

Save the file.

6. From the Terminal, go to the folder where the script is saved.

Run the command and this will run the script we just edited.

./dreamdns.pl

If you have no errors, it should look like this.

S388BP~7.PNG

 

If the script did not have any error and if you everything right, the A record on your DreamHost domain will now have your IP address instead of the 127.0.0.1. This is a good time to check it before proceeding.

If you get an error like this

SWUX92~8.PNG

Be sure to install libwww-perl.

sudo apt-get install libwww-perl

and then try it again!

 

7. Now if everything is working, all we have to do is set it up so it will start every time your computer boots up.

From Terminal, we are going to edit /etc/rc.local.

sudo vi /etc/rc.local

Add this line. be sure to add this line before the line “exit 0”

/path/to/script/dreamdns.pl –daemon

Replace the path where you saved your script. Do not forget –daemon.

Save the file.

Reboot!

You can also check the process if it is running by using htop command. Search for “dream” it should direct you to it. If you found it in htop, it is running. And check your domain’s A record as well to double check.

You are done setting up your Dynamic DNS!

If you have any questions or comments, feel free to write below. If you like my contents, subscribe!

makkugasho

 

Source: http://www.joshlange.net/dreamapi/dreamcli/

2 Replies to “DreamHost vs. Dynamic DNS”

  1. I have updated the script, due to issues with more recent versions of perl. You may want to update your links so they reference version 0.3. The new version is linked from the original source you have listed above.

    1. I am looking at the script and I can’t find the $domain from the last version. I know you can specify it through CLI but I would rather put it in the script. Maybe I’m just blind. Mind helping? Thanks

Leave a Reply to Makkugasho Cancel reply

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