09.12.2012 Views

Understanding the network.pdf - Back to Home

Understanding the network.pdf - Back to Home

Understanding the network.pdf - Back to Home

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

# If any of <strong>the</strong> hosts fail <strong>to</strong> respond <strong>the</strong> script will mail<br />

# a notification message <strong>to</strong> you.<br />

for i in $hosts;<br />

do<br />

$ping -c 3 $i >/dev/null 2>&1<br />

if [ $? != 0 ]; <strong>the</strong>n<br />

echo $i is down|$mail your@mailaddress-here<br />

fi<br />

done<br />

Although ping is not a glamorous <strong>to</strong>ol in comparison <strong>to</strong> o<strong>the</strong>r <strong>network</strong> <strong>to</strong>ols, it is<br />

flexible (as you can see from <strong>the</strong> previous examples). When using ping as a<br />

standalone <strong>to</strong>ol or in a script, keep in mind that a reachability failure or loss of<br />

packets does not au<strong>to</strong>matically indicate that <strong>the</strong> host is down or <strong>the</strong>re are physical<br />

layer problems with one of your gateways or transport links. A failed ping attempt or<br />

one with a high level of dropped packets can also indicate a routing problem or an<br />

excessive level of <strong>network</strong> traffic.<br />

Traceroute<br />

To check <strong>the</strong> route <strong>to</strong> <strong>the</strong> destination host or <strong>to</strong> verify that all of <strong>the</strong> gateways in <strong>the</strong><br />

transit path are up, an additional application, commonly called traceroute, is used.<br />

Traceroute, like ping, uses ICMP echo-request messages <strong>to</strong> trace <strong>the</strong> gateway path<br />

one hop at a time. It accomplishes this by sending three ICMP messages with<br />

variable TTL counters. The first ICMP message, which is sent <strong>to</strong> <strong>the</strong> host's default<br />

gateway, has a TTL of 1. The message is received by <strong>the</strong> gateway, and it decreases<br />

<strong>the</strong> TTL counter <strong>to</strong> zero and returns an ICMP host unreachable notification message.<br />

Then traceroute sends an ICMP message with a TTL of 2, <strong>to</strong> reach <strong>the</strong> next gateway.<br />

This process continues, incrementing <strong>the</strong> TTL by one, each time a successful ICMP<br />

host unreachable message is received. This continues until <strong>the</strong> final destination host<br />

is reached. This occurs when <strong>the</strong> traceroute program receives an ICMP<br />

echo_response from <strong>the</strong> destination host.<br />

As traceroute maps <strong>the</strong> transit path, it displays <strong>the</strong> gateway (hostname or address)<br />

and <strong>the</strong> round-trip delivery time averages for <strong>the</strong> ICMP messages sent <strong>to</strong> each<br />

gateway. The output from a UNIX-based traceroute implementation follows:<br />

%traceroute www.yahoo.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!