Friday, July 7, 2017

Dynamic DNS with Cloudflare, ddclient, and DNS-O-Matic (with Multiple Domains)

It's been a very long time since I've updated this blog.  For a while I've kept a separate one,, but the home server I've been using to host it failed about a year ago.  I will be getting AJfox back up and running at some point, or I'll port the posts to this site, I haven't decided yet.

Anyway, this topic is about how to configure dynamic DNS with Cloudflare, using DNS-O-Matic and ddclient.

Reason for this post

There were plenty of guides on getting Dynamic DNS up and running with cloudflare, and one or two with DNS-O-Matic, but absolutely none for multiple domains.  If you've found this guide by a google search, I'm assuming you already know at least what Dynamic DNS and Cloudflare are, if not you can check out the basics here: Replacing DynDNS with CloudFlare DDNS

I was trying to set up an easy way to set the DNS for multiple domains (e.g. and, which doesn't seem to be covered anywhere online.

What is DNS-O-Matic?

To answer this question, let me quote someone who explains it better than I:
DNS-O-Matic is a service from OpenDNS for distributing dynamic DNS updates to supported authoritative DNS services. Cloudflare is one of the supported services. Source: Using DNS-O-Matic dynamic DNS updates with Cloudflare 

And what is ddclient?

ddclient is a daemon that periodically updates your DNS information to a Dynamic DNS service.  I've seen plenty of guides where people have been trying to get it working with Cloudflare, but it apparently requires patching the standard version to get it working correctly, I wasn't able to.

Instead, I set up ddclient to sync with DNS-O-Matic, and then set DNS-O-Matic to sync with Cloudflare.

With that out of the way, let's get down to business!

Step 1: Register accounts with Cloudflare and DNS-O-Matic

If you're reading this, you probably already have a cloudflare account.  If not, check out Cloudflare's Getting Started page to see how to sign up.  DNS-O-Matic is very easy, just head over to their website and sign up.

Step 2: Configure ddclient

That depends on what linux distribution you're using.  For me, with Gentoo, I just had to run:
emerge --ask ddclient

On Debian-based systems it would be:
apt-get install ddclient

Step 3: Configure Cloudflare

This is probably the weirdest part.  The problem with DNS-O-Matic is that it will only support one A-record across all domains.  As I've mentioned, every guide I've seen recommends that you create a hostname called "dynamic" (ergo; however, DNS-O-Matic literally will not allow you to create the same hostname even for different domains (e.g. 

Here's what I did:

Generate a random string for every domain you have
Any supported random string generator will work; for simplicity's sake I used the Random Letter Sequence Generator and set the length of each sequence to 16.  One feature that I liked in this generator was the ability to generate several strings at once.  For two of my domains, I generated two strings:
  • sjnuuqvibcmvycpa
  • bghpdqbwupqqdpmp
Create an A record with the random string that points to any IP address
For each domain, you'll have to create an A record with that random string.  This record can point to any IP address (I used

Here's what it looks like in Cloudflare for
Type Name Value
A sjnuuqvibcmvycpa points to

Create two CNAMEs for root and www

You'll want to create a CNAME for your root domain pointing to the A record and a WWW CNAME pointing to the root domain like so:
Type Name Value
CNAME is an alias of
CNAME www is an alias of

Once you're done, you should have something like this:

Afterwards, do the same thing for the other domain, using the other random string.

Step 4: Configure DNS-O-Matic:

This part is pretty straightforward.

Get Cloudflare API Key
First, you'll need your Global Cloudflare API.  Log into Cloudflare and click on your name in the top-right corner, then go to Settings.  From there, scroll down to API Key and under Global API Key click on View API Key.  This is your secret API key that DNS-O-Matic needs for logging into Cloudflare.

Add Cloudflare Service in DNS-O-Matic
You'll do this for every domain that you own:
  1. Log into DNS-O-Matic and click on Your Services, then Add a service.
  2. Select Cloudflare from the drop down menu
  3. Enter your cloudflare email address under Email
  4. Enter your API Token under API Token
  5. Enter your domain's random string (from above) under Hostname
  6. Enter your domain under Domain
You can use the same API and cloudflare email, but you must use a different string for Hostname and Domain for each domain.  Here's what I have (note: not using my real cloudflare email):

Step 5: Configure ddclient

The configuration file is located at: /etc/ddclient.conf

You'll want to put something like this (be sure to change the USERNAME and PASSWORD to your DNS-O-Matic credentials):
use=web,,    \
protocol=dyndns2,                \
login=USERNAME,                  \
password=PASSWORD                \

That's it!  You can test to see if this configuration worked by manually running ddclient from the command line:
ddclient -daemon=0 -debug -verbose -noquiet

In my case it did:

Good luck!

Tuesday, June 10, 2014

The flooding situation in Rutherford (with video/rant)

My backyard got flooded again this morning.  This is happening more and more often, so I decided to take some pictures.

There's a terrible flooding situation in Rutherford, a small neighborhood in New Castle County, outside Newark, Delaware.  Due to the Christiana Hospital (who insisted to the residents of this neighborhood that it wouldn't affect us), the pipes for Rutherford are backed up and overloaded.

Tuesday, February 21, 2012

Final Update on Dvorak

Hello everyone, this is my final update on the Dvorak Series.  On December 26, 2010, I decided to switch to the Dvorak keyboard layout.  You can go read my posts on the progression.

Well, today, I decided to take a typing test, and here are the results:
Yes, you read that right: 103 wpm.  I'm officially up to my QWERTY speed.
Here is a pretty nice log of what I've done since the switch:
Time ElapsedWords Per Minute (WPM)
1 Day5 WPM
5 Days15 WPM
2 Weeks40 WPM
9 Months85 WPM
13 Months103 WPM

You know, it took about 8 or 9 years to reach 100+ wpm with QWERTY.  It took a little over 1 year with Dvorak.  Will this limit be my ceiling?  I doubt it, but I'm pretty happy with this speed at the moment.

I highly encourage using the Dvorak layout, and I'm happy to say it was well worth learning!

That is all!

Saturday, October 15, 2011

HTML5-Compliant YouTube Embedding

Today I was updating my fathers site, Home Tips With Jim to be HTML5-compliant.  It was pretty much just a matter of removing the center tag and target="_blank" from the links -- or so I thought.

I'm putting this out there for anyone that may run into the problem in the future; while trying to use YouTube's new iframe embed system to embed my father's playlist into the page, I ran into two problems spit out by the W3 Validator:
Attribute allowfullscreen not allowed on element iframe at this point.
The frameborder attribute on the iframe element is obsolete. Use CSS instead.
After some quick research, I found the solution; apparently frameborder is depreciated, and allowfullscreen is not fully implemented.
The solution, was to remove those two elements, and replace the frameborder one with CSS.  So, if anyone else runs into this problem, go into the
<iframe> tag, and change this part:
frameborder="0" allowfullscreen
To this:
style="border: none"

You can now view the source to the HTWJ site, and see how it's been fixed.

Wednesday, October 5, 2011

How to create a desert

Hi everyone, assuming there's actually someone out there that reads this blog.

I thought I'd blog about something that's been on my mind for awhile now, though it may not be on others: how does one create a desert?  I'm not talking about a desert-themed terrarium or a panorama, I literally mean how would someone create a physical desert?

Let me explain.  Back when I was growing up, my family lived in this nice little house that we rented.  When we first moved there, the backyard had lush green grass, it was a really nice yard.  By the time we moved, all of that grass was gone, nothing could grow, nothing would live.  The dirt became more of a "dust" or "sand" texture; it didn't hold water, it couldn't hold life.  What happened in this yard, on a small scale, is what's called Desertification.

Desertification is primarily what has happened in the Midwest of the United States, and it is currently happening in Asia.  It's why the huge Sahara Desert used to be ocean, and why places in China that were lush green fields just 20 years ago are baron wastelands.

So my question is, how would I create a desert?  It seems once the process of desertification starts, it "snowballs" into an unstoppable force, turning entire landscapes into a desert.  On other words.....
How does this:
 Become this:

Step 1: Overgraze
Probably the best way to kill fertile land, is to overgraze.  With so many animals trampling the land and eating the vegetation, it isn't hard to figure out why the land actually dies.  I'm sure people that own large, outdoor dogs can probably agree with me, if their dog pen ended up becoming bare dirt.

Step 2: Dig
Back when we had that old yard growing up, I would dig things up there on a daily basis.  I would try to dig my own "streams" try to excavate rocks.  All of this constant digging seemed to make the land more "arid" and loose; eventually it became almost like a sand.

Step 3: Irrigate
It seems kinda odd that irrigating the land would actually contribute to killing it, but this seems to be the going consensus.  I remember during the summer, I would tie a hose to the top of my sliding board set, and I'd dig streams going from the huge mud puddle in my yard, all the way through to the back in the woods.

Step 4: Overfarm.
Overfarming is also a major contribution to desertification.  It's true that the runoff from farming could hurt the dirt, but when plants grow, they are constantly sucking nutrients out of the earth.  usually when the plant dies, the nutrients goes back into the dirt, but if the entire plant is harvested, those nutrients will never go back in.

It's simple, really.  If you want to kill your land, simply trample the dirt, dig a lot, irrigate, and overfarm.  It's what happened in the Dust Bowl, it's what's happening in China.  No go out there, and create some deserts! :D

Sunday, September 4, 2011

My new website and other updates

It's been quite awhile since I had a chance to update this blog, been busy IRL, but I thought I'd at least give an update with what I've been doing.

Currently in my fourth year at college, leading the school's programming team again, and also working on some new websites of mine.

Also, for those who are interested, here is a quick update on that Dvorak Keyboard Layout.  It's been about nine months since I made that switch, and I'm up to 89-95wpm again.  Yes, it's not the 100+ wpm I had before, but hold fast, I'm slowly getting there.

Anyways, to the website.  I've recently created a pretty funny website, called  It's pretty much a website with a ton of funny (and for some, seizure-inducing, so watch out) flash loops.  The whole website is written in C, of course, and not php.  I've also been slowly but surely working on the groundwork for the website,, which will be another type of blog I'll be working on, so keep and eye out for that.

I will try to update this blog when I can though, I'm currently working on an article on desertification (what, you thought I only knew about programming?), if I can ever get around to finish it....

On an unrelated note, Home Tips With Jim is started to get pretty awesome, and there are plenty of new episodes; check out my dad's new website: for the latest playlist.

NOTE: This is part of a series, check the next entry here! 

Monday, May 30, 2011

Why your website should be written in C, not PHP

It's been awhile since I updated this blog, been pretty busy IRL.  Just recently got back from a Longsword Course with ARMA, in Ohio, was very nice, and I learned a lot.  I've also been playing the silver market recently; there's a pretty nice blog that I follow.  If you're looking for an interesting perspective on precious metals, check this guy at Along the Watchtower; he seems to know his stuff.

Okay, back to the point of this post. 

I have studied several scripting and programming languages; off the top of my head, I know Ada, C, C++, Fortran77, FORTH, Perl, PHP, Python, Java, and JavaScript.  Which language do I prefer, though?  C.

Now, for the record, just so you do know that there are plenty of sites written using something other than PHP.  Any website ending in .cgi are usually written in a compiled language.  I have came across some sites that are written in C++ before, and Deltapsi Studios, my good friend Stephan's site, is written in C, with mysql support and everything.

Anyway, more and more people in today's world are designing websites in PHP.  After all, as one of my professors would say, "PHP is built for the web!"  Maybe that's why Facebook uses PHP
Addendum 08/27/11: Actually it seems like Facebook wrote their site in PHP, then used software to convert it into a complied language, since interpreted PHP wouldn't be able to hold up the site.

C, on the other hand, I keep finding people consider it a low-level language that is only used by the hard-core programming.  One of those "hard to learn" languages that take millions of lines of code to get things done.

Despite the above accusations, you will find that C is actually a very good language.  It is an easy language to learn, and if programmed correctly, easy to understand, and by default, C is one of the fastest-executing programming languages out there, and when optimized, it can blow almost anything out of the water.  Check the end of my switch() vs elseif benchmarks post.  PHP took 8.169889 milliseconds to traverse my last test, whereas C took 0.01267 milliseconds.

Maybe you're thinking, "Okay, PHP takes 8ms and C takes 0.01ms.  A millisecond isn't that long."  There are two points I should make.  First, if you do the math between those two times, you find that C's switch() executed almost 645 times faster than PHP.  This in a matter of speaking, makes C about 64,500% faster than PHP!  Now THAT, is a speed difference.
And even then, while a millisecond may not seem that much to you, if you're having your web application serving hundreds or thousands or millions of requests, the speed difference will add up, and while the websites designed in C will be happily treading down the road, you'll find your PHP-site stalling and lagging while the preprocessor parses for your people.  For the virtual machine guys out there, if you want to get technical, ASP.NET or JSP should theoretically run faster than PHP.

Okay, so C is faster, C is more efficient, and I'm telling you that C is easier.  "But Anthony!" you cry, "What about the sessions and the cookies and the hash map arrays and the typeless variables, and my strings, and HTML output, and..."  Yes, yes.  By this point, you realize that PHP was indeed designed for the web, hence it will have a ton of web-design libraries that are not in the Standard C Library.  This means that if you want to use mysql, you will have to get the MySql Library and do your queries in C.  If you want sessions, you will have to find a session system for C, or write your own.

Yes, you will have to have "type" your variables, that is, using "int iNumber = 3;" instead of "$Number = 3;" and you will loose those hashmap/linked list arrays that everyone seems to love so much, though if you look at that previous benchmark, you'd find the hashmaps in PHP executing pretty slowly as well.  This is due to the slow nature of a hashmap, which is not in the scope of this entry, and just remember, in C, you can implement radix tables or something much, much, faster than hashmaps.

As for cookies, GET, and POST, it's really not that hard.  Below, you can read the get/post/cookie receiving that I used, in my C-web application, as well as the sessions system:

» Click to show Spoiler - click again to hide... «

There is a downfall, however in C, and that is how horrible it handles strings.  After all, with the happy-go-lucky $mystring = "Hi everyone!"; how can you go wrong?  In PHP, to concat a string, all you have to do is:
"Hi " . "Everyone!"
I believe.  Everyone knows that C-strings are slow.  Try to concat a string in C multiple times, and you'll quickly find that it has to traverse the string in strlen() every single time strcat() is called.  If String A and String B are 256 characters, and you strcat() them, when you try to concat the new string, it will be twice as slow.  Strings are a mess in C.  So what did I do?  I wrote a new string library, that handles strings like Pascal does:

struct string_t
  size_t len, /*Size of string to '\0' */
         max; /*Size of the total string*/
  char* str;

What's the point of the above structure?  Those that know C will probably be going "OH!", and for those who don't...  I'm storing the length of the string in my actual string.  You'll notice a HUGE increase in performance once strlen() can return the length with "str->len" instead of "for(s=str;*s;++s);"
So now, I can do,
string_t* mystr = mystr_create(256); //Make a string that can hold 256 characters.
mystr_concat(mystr, "Hello World!");
Was that so hard?

"What about outputting text?"  What about it?  It is true that in PHP, you can do:
<p>The number is: <?php echo $number ?></p>
Or whatever it is you do, but in C, I can just do:
printf("<p>The number is: %d<p/>", number);

What I'm doing, is simply embedding the HTML into the c-code, instead of embedding the c-code into the HTML.
(NOTE: Stephan, if you're reading this, no, I do not actually use printf..)

So in short, anything written in PHP can be written in C (even if you don't feel like writing the systems yourself, there's a good chance you can find a libcgi worth using), and PHP is slow (very slow).  Now, I can go over and discuss