LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

Using Free Dynamic DNS with afraid.org

afraid.org Dynamic DNSSometimes when I’m on the road, I want to connect to something at home.  To do that, I need to know my home IP, which changes periodically.  There are a couple ways I could accomplish this, but the method I use is to setup free dynamic DNS via afraid.org

To do this, you need to register for a free account at afraid.org.  If you’re the upstanding sort, you can get a paid-for membership and take advantage of various upgrades but for this example, a free account will serve.

Once you’ve logged in, head over to Subdomains and setup a record using one of afraid.org’s whimsical choices, such as chickenkiller.com, crabdance.com, strangled.net, or one of “Many many more available…”  And when they say “many many more” they really mean “many many many more” because there are over 44,000 domains you can subdomain on.

Yes, you can be silly-salacious-cheese.jumpingcrab.com if you want.  I mean, I haven’t checked that that specific subdomain is available, but it probably is.

Go ahead and setup any value you want for the A record because I’ll show you how to setup an automated update next.

Afraid.org MenuOn a Linux or BSD (or macOS or OpenSolaris or whatever Unixy OS you’re running at home), you can use a cron job provided by afraid.org.

After you create your subdomain, click on Dynamic DNS on the left-hand menu.

You’ll see a lot of explanatory language and notes to clients and scripts.  You’ll see there are an astonishing number of ways to update your afraid.org dynamic DNS.  You can login and do it through the web, use a username:password URL, use wget, or use curl.  We’re going to use wget, and we’re going to use it in the laziest way possible.

Go down to the list of your dynamic DNS subdomains at the bottom, and click “quick cron example”.

afraid.org detail

You’ll be taken to a text file which includes many lines of comments and commented-out examples.  But the two uncommented lines are what you want to look at:

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

This line is important because cron notoriously has a very bare-bones environment and various needed binaries won’t be found.

2,7,12,17,22,27,32,37,42,47,52,57 * * * * sleep 8 ; \
wget --no-check-certificate -O - https://freedns.afraid.org/dynamic/update.php?XXX >> /tmp/example.log 2>&1 &

(The “\” denotes a line break to make it read easier on our web site).

This line needs some parsing, and a bit of improvement.

The time specification may look funky – and yours will probably be different, with a different sleep.  I believe these are randomly generated to spread out the load from millions of clients around the world.  It’s interesting that updating every 5 minutes 24x7x365 is the expected norm.

Rather than this:

wget –no-check-certificate -O – https://freedns.afraid.org/dynamic/update.php?XXX >> /tmp/example.log 2>&1 &

I prefer this:

MAILTO=me@example.com
2,7,12,17,22,27,32,37,42,47,52,57 * * * * sleep 8 ; \
wget --no-check-certificate -O - https://freedns.afraid.org/dynamic/update.php?XXX >> /tmp/example.log

There are two reasons for this:

  1. Having an ampersand on this command doesn’t make any sense.  There’s no need to put a cron command “in the background” because it’s already in the background by definition.
  2. Setting the MAILTO various will put ALL output by jobs to that email address.  In this case, we’re redirecting ho-hum standard-routine messages to a log file (which could also be /dev/null), but any error messages will still be printed, and hence come to my email.  I don’t care if everything’s working fine, but I do want to know if it is failing.

And that’s it.  This job will run every 5 minutes (or whatever you specify) and keep your Dynamic DNS updated.  Enjoy!

raindog308

1 Comment

  1. Matthew Davids:

    Nice work!

    July 1, 2022 @ 4:29 am | Reply

Leave a Reply

Some notes on commenting on LowEndBox:

  • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
  • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
  • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

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