[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Checking if the network is up



On Fri, 10 May 1996, Rob Leslie wrote:

> Try using `fping' on your network gateway host. e.g.:
> 
>   if fping -q $GWHOST
>   then
>     popclient ...
>   fi
> 
> Or, if you prefer compactness (also good for crontabs):
> 
>   fping -q $GWHOST && popclient ...
> 
> Substituting $GWHOST with the name/address of your gateway, of course. Better
> yet, substitute the name of your POP server.

I use a variant of this, run out of cron every few minutes to keep my
PPP connection up.


REMOTE_IP=x.x.x.x   # IP Address of remote gateway machine.

    fping -q $REMOTE_IP && exit 0
    .
    . remainder of script here
    .


or (on machines which don't have fping...e.g. slackware):

    ifconfig | grep $REMOTE_IP >/dev/null 2>&1 && exit 0
    .
    . remainder of script.
    .


if the exit code of either test is true, then the script exits
immediately. otherwise the link must be dead, so it runs the remainder
of the commands which bring the link back up again.

The fping version could use either an IP address or a domain name.  The
ifconfig version must use an IP address.

Craig


Reply to: