Power Outages: Using DynDNS Pro To Get Updates Faster Than Your Power Company Can

11.02.2011 By

As many of you know, the northeastern portion of the United States experienced a major winter storm this past weekend. As a result of the early snowfall, millions of people lost power at their homes and businesses — Dyn and its employees included. While this event did not have any negative effect on our services to customers, many Dyners have been staying with other employees, friends and family who do have power and heat.

However, we’ve noticed that the local power companies do not always provide timely updates on when the lights will go back on. After a few hours or days in the dark, many people start asking two questions:

  1. When is power going to be restored to my area?
  2. Does my home currently have power?

The answer to the first question is often up to your power company. Hopefully, their emergency response teams provide accurate Estimates-to-Recovery (ETR). To answer the second question, through a clever use of our DynDNS Pro service, you can set up a quick script to check from any smartphone on whether your home or business has power (and Internet).

To accomplish this, you’ll need a few things.

  1. A DynDNS Pro account
  2. A computer, router or other device on your local network updating your IP address to the Dyn’s systems.
  3. A computer running a web server which can be accessed outside of your network (such as Apache) and optionally, some sort of scripting language. In this example, I use PHP.
    1. Note: The computer needs to be set to auto-restart after a power failure (this can be set in BIOS on a PC or on a Mac in System Preferences/Energy Saver on your computer)
    2. An HTML file or other script loaded on your webserver which you can access from outside your network.
    3. A smartphone or computer on a completely different network with Internet access to check your DynDNS Pro host name.

Let’s get started

The basic principle is that once your home or business’ power has been restored, your computer will turn on automatically and start the webserver. Along with this, your Internet provider (cable or DSL modem) and networking equipment should also turn on once power is restored. Note that I am making the broad assumption that your Internet service comes online at the same time as power, which may not always be the case.

When your computer or router turns on, it should then update your new IP address with Dyn’s systems. Once everything is up and running, you can then point a web browser from your smartphone or another computer to your DynDNS host name and path where you installed the HTML file or script.

If all goes well, you will see something like this:

Dyn - Power On

Hooray, your power and Internet are on! In my example (see code below), I also wanted to know how long the power has been on.

If the power is still off, you will see something like this:

Dyn - Power Off

Unfortunately, you will still need to be nice to your hosts for at least a few more hours.

The Code

I’m a finance guy who knows just enough PHP to be dangerous. So I crafted the following basic script to let me know if the power is on. I put this into an index.php file so that I could know how long my server has been turned on.

	//Script to get server uptime
  	$shellcommand = shell_exec('uptime');
  	$uptime = explode(' up ', $shellcommand);
  	$uptime = explode(',', $uptime[1]);
  	$uptime = $uptime[0].', '.$uptime[1];

  	echo ('Server uptime: ' . $uptime . '');

Other Uses

Obviously, you don’t need to only use a web server. Dyn has many customers who use DynDNS Pro accounts to access weather stations, web/security cameras, home automation and other services. If you use your DynDNS Pro account for any other service and can access these remotely, you’ll also know your home has power.

Good luck and on behalf of Dyn and all of its employees, we hope you and your family get your power restored soon (if not already) if you were affected by this weekend’s storm.

  • Michael Taylor

    For some reason I like that the code includes “Uptime = Explode”

    • David G

      Or you can just connect to your modem’s Remote Admin address (which of course you have enabled). I happen to have a fixed IP but of course you can also use DynDNS to connect to home.

  • ABell

    I think the simplest way is with screen sharing software — If you can see your home screen, the power is back on.

  • David DePiano

    ABell: Yes, that would work to. As I mentioned, any service where you can reach your machine from outside your home would server the purpose (web, ssh, screen sharing, file sharing, etc). I prefer to not share my desktop screen for security reasons, but there are many secure desktop sharing apps out there. I liked this solution as it is low bandwidth, doesn’t require any additional mobile apps, and was quick and easy to setup.

  • ABell

    Screen sharing is easy for me, David — I have a ShareTool server running on my home machine all the time which is a) is secure, and b) will accept my domain name (via Dyn) as input.

    • David DePiano

      ABell: Nice! Glad to hear you are using a Dyn tool to help you out. I’ve heard good things about ShareTool. Best Regards.

  • http://profiles.google.com/nelson.butterworth Nelson Butterworth

    I have Webmin (http://www.webmin.com) installed on my home server. It has a facility for monitoring pretty much any command that can return a value which can be read. It can also send an email or an SMS message when a monitored item goes up or down. I have monitors configured for several different services which will generate alerts upon system startup, so I always know when the system is booted and when the internet connection is up.

  • Lancelot

    New to this, where does the green tick, and “The Power is On”, come from.

  • http://www.facebook.com/chaimpeck Jeff ‘Chaim’ Peck

    I thought of doing this during the power outage to check if the power was on back on home, but it turns out that I reset the router to factory settings at some point and it lost my dyndns configuration. Still it’s nice that others got to take advantage of this clever dyndns use-case.

  • David DePiano

    Lancelot: The green checkmark is from Mac OS X. “The Power is On” is just text added to the HTML file on my home server. The coding of HTML was outside the scope of this post. Again, the purpose of this is that if your an load a web page on your home server, obviously power is on.

  • NH Jim

    OR you could just call and see if yoru answering machine is working…

    • David DePiano

      That assumes two things. First, you have a landline (which I don’t). Second, it also assumes you use a plugin answering machine and not your ISP or VoIP provider’s online voicemail service (I use Google Voice).

      But still, a good tip.

      • David DePiano

        Apologies for the typo. That should read plugged in…

  • JDoe

    This is way more complicated than it has to be.
    First, if you don’s have static ip get a dyndns account.
    Then enable icmp on your router. Finally download and install a server monitoring tool like “network tools” from the market if you have android.
    When power comes back on your router will respond and the app will let you know. That is of course if you set it up to ping every minute.

  • Michael

    I am at a loss as to why you need a Pro account to accomplish any of this.  All you need do is to attempt to reach your router’s management port at regular intervals, which can be done regardless of whether the DYN account is free or Pro.  If you want to want to automate it, just point “aremysitesup.com” or any of the other monitoring services out there to any web server port anywhere on or behind your router.  You’ll get an email or SMS every time your internet service goes down or comes back up.

    • Max

      I agree, you don’t need a pro account. I think the OP was just trying to push the unthinking end user towards paying for a pro account since he is a Dyn employee. Hey I don’t blame him for trying but don’t mislead the readers, right?

  • Kathie Wiilam

    i have no better idea about server .any one can please inform me about my server , i was bought it from (http://penta.com.au/index.php?main_page=product_info&cPath=479_552&products_id=54414) last week.