[CentOS] Back-up connection

Fri Aug 16 12:50:39 UTC 2013
Mihai T. Lazarescu <mtlagm at gmail.com>

On Fri, Aug 16, 2013 at 01:33:01PM +0200, Timothy Murphy wrote:

> Some weeks ago, I asked if anyone had set up a backup scheme for a remote 
> server.
> By backup here, I mean an alternative arrangement that can be called upon
> if eg the DSL connection to the remote machine fails.
> 
> I received one interesting reply:
> ======================
> At home, besides my fixed lines,
> I have two gsm-modems, one low-speed (that came free of charge with one of 
> my fixed lines),
> the other is high speed, but pre-paid, normally off)
> ======================
> I meant to respond at the time, asking for further details,
> but forgot, and now I have lost the original message.

I think that the original thread was on users at lists.fedoraproject.org:

    http://www.spinics.net/linux/fedora/fedora-users/msg435811.html

In case the web/CLI interface of DSL modem/router is still
responsive, you can script a reboot from the server on the
LAN when fails the ping to a set of well-know always-up hosts.

I resuscitate this way a D-Link DSL-320B with (snippet):

    # Set both international and national hosts.
    hosts="www.google.com www.yahoo.com www.libero.it www.telecom.it"

    for h in $hosts; do
        ping -c 2 "$h" > /dev/null 2>&1 && {    # Success
            retval=0
            break
        }

        echo "Ping failed for ${h}."
        retval=1                                # Failure
    done

    test "$retval" -ne 0 && {
        echo -e "\nResetting the ADSL modem."
        phantomjs adsl-reboot.js
    }

adsl-reboot.js is a Javascript script that logins onto the
modem and "clicks" the reset button.

You can also play with the -w option if your ping supports it.
The default timeout is 10 seconds or so.

Mihai