Welcome to WebProNews Breaking eBusiness and Search News
Advertise | Newsletter | Sitemap | News Feeds News Feed 
 WebProNews Search Part of the iEntry network iEntry inc. 

Testing For Network Connectivity In A Script

A.P. Lawrence
Expert Author
Published: 2004-12-27

WebProNews RSS Feed


Sometimes a script needs to know if it has network or internet connectivity before it continues, or perhaps its whole purpose is the report a loss of connectivity or inability to reach specific services.

A typical response to such a problem is to use "ping" to determine if some other host is "up". That's pretty simplistic, though, and really doesn't tell the whole story.

If you really want to test connectivity, and want the script to be able to tell you where the problems are when it is lacking, you need a more procedural approach. First, ping something on your local network, using a "-c5" or even a larger count (don't use the "-w" flag here). The reason for a larger count rather than the commonly advised "-c1" is that very temporary and unimportant problems can cause single packet loss. This *shouldn't* be on your local network, but asking for more packets gives you more information about the situation if you do have this problem. Similarly, the reason not to use -w1 or -w anything (which times out after that many seconds) is because temporarily slow does not mean not connected.

Use a numeric ip address for this first test so that you aren't triggering dns name resolution. Test more than one address in case one host is down. If none of these work, you know you have serious local problems: either your nic isn't working or connected, or the rest of your network is down.

Next try the router on your lan segment, again using numeric ip addresses. If that doesn't respond, you won't be going off-network, so you can stop now.

If these tests succeed, you still don't really know that you have connectivity, so I'd next try the closest thing I know - like my isp's dns or mail server. Depending on how seriously you define "connectivity", I'd then move on to checking things farther away or the things I already know I need to talk to.

If you have had any indications of failure, increase -c to get an idea of how bad the loss actually is. Somewhere in here I'd check with a hostname or two, to see that DNS is working.

Consider that ping doesn't absolutely say you have any high level connectivity, so if you REALLY need to know, then you need to do more, like a lynx dump for a web page, a test ftp connection, or whatever tells you that by gum you really do have full connectivity. If your purpose is to specific hosts, that's all you need to know, but if your concern is general connectivity, then you need to test a range of hosts.

Your script may also want to check "ifconfig" and "netstat -i" if it is logging problems. Changes of netstat -i stats in the error columns over a short period of time probably indicates serious problems.

*Originally published at APLawrence.com

Receive Our Daily Email of Breaking eBusiness News


About the Author:
A.P. Lawrence provides SCO Unix and Linux consulting services http://www.pcunix.com

WebProNews RSS Feed

More Articles

Contact WebProNews
Advertisement





TOP NEWS

Targeted Information for Business
WebProNews is part of the iEntry network

Internet Business: Marketing: Small Business:
WebProNews MarketingNewz SmallBusinessNewz
WebProWorld AdvertisingDay PromoteNews
EcommNewz SalesNewz EntrepreneurNewz

Software: Search Engines: Web Design:
WebMasterFree Jayde B2B DesignNewz
NetworkingFiles SearchZA FlashNewz
SecurityConfig SearchNewz WebSiteNotes

Developer: IT Management: Security:
DevWebPro ITManagement SecurityProNews
DevNewz SysAdminNews SecurityConfig
TheDevWeb NetworkingFiles NetworkNewz

The iEntry Network consists of over 100 web publications reaching millions of Internet Professionals. Contact us to advertise.
eBUSINESS RESOURCES






 Advertise | Contact Us | Corporate | Newsletter | Sitemap | Submit an Article | News Feeds
 WebProNews is an iEntry, Inc. ® publication - $line) { echo $line ; } ?> All Rights Reserved
About WebProNews
WebProNews is the number one source for eBusiness News. Over 5 million eBusiness professionals read WebProNews and other iEntry business and tech publications.

WebProNews provides real-time coverage of internet business.

Free Email Newsletters:
WebProNews SearchNewz
WebProWorld DevWebPro
Marketing SecurityNews
Plus over 100 other newsletters!

Send me relevant info on products and services.


WebProWorld
Ten most recent posts.

NetworkingFiles
Featured Software

WebProNews in the News
View all recent mentions of WebProNews from around the world!

Recent Articles On ...
Google eBusiness
Yahoo Ask Jeeves
MSN Blogs
Search Engines Blogging
Affiliate Programs Marketing
eCommerce Advertising
eBay Sun Microsystems
AOL Adsense
Microsoft Adwords
Oracle IBM
Amazon Apple
SEM Mac
SEO iPod
Adsense XBox
PR Adobe



iEntry.com WebProWorld RSS Feed WebProWorld Contact WebProNews Print Version Email a friend Bookmark us