Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm having problems w/ my ISP at my network at work. They keep losing our connectivity and I need to keep an eye on the connectivity.
Can anybody recommend a simple way just make sure I can hit our IP address? Pretty graphs are nice but as long as I know when the network's down and when it's up I'll be fine. Thanks!
Distribution: Fedora/RHEL currently. Red Hat, Slackware, Debian, SuSe and Mandrake at other times
Posts: 104
Rep:
Here's a simple script I use that does something similar. It is meant to run on your machine and tests for connectivity to the outside world (ie is yahoo.com pingable?) and reacts by running a specified command. You could tweak it to run on an external machine, pinging your machine's IP (set the CHECK_ADDR variable) and reacting when the connection is lost.
Code:
#!/bin/sh
### This simple script monitors the state of a network ###
# Configuration variables
CHECK_ADDR="www.yahoo.com"
CHECK_CMD="ping -c1 -w2 $CHECK_ADDR"
OUTAGE_CMD="echo NETWORK OUTAGE DETECTED AT $(date)"
OUTAGE_WAIT=0
RESTORE_CMD="echo NETWORK RESTORE DETECTED AT $(date)"
RESTORE_WAIT=0
# This function does nothing until $CHECK_CMD fails.
# When that happens, $OUTAGE_CMD runs and the function exits
check_for_outage()
{
$CHECK_CMD &> /dev/null
while [ $? -eq 0 ]
do
sleep $OUTAGE_WAIT
$CHECK_CMD &> /dev/null
done
$OUTAGE_CMD
}
# This function is the same as check_for_outage but it waits for $CHECK_CMD to succeed.
# When that happens, $RESTORE_CMD runs and the function exits
check_for_restore()
{
$CHECK_CMD &> /dev/null
while [ $? -ne 0 ]
do
sleep $RESTORE_WAIT
$CHECK_CMD &> /dev/null
done
$RESTORE_CMD
}
# This function loops forever, alternating between checking to see if the net is down
# and checking to see if it's back up again.
while [ 1 -eq 1 ]
do
check_for_outage
check_for_restore
done
If you have access to snmp comunities on the router read only should be enougth then you could monitor the isp router via snmp alerts. Which could easily be setup to send an alert when the connection has dropped.
if that option is not available then you would need some form of backup link such as a server --> modem link that could dial the same or alternative isp and send snmp alerts to you that way.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.