Using ping to Test Network Connectivity





Using ping to Test Network Connectivity

Whether or not your troublesome server is connected to your local network, it is always a good practice to force a response from it.

One of the most common methods used to test connectivity across multiple networks is the ping command. ping sends ICMP echo packets that request a corresponding ICMP echo-reply response from the device at the target address. Because most servers will respond to a ping query, it becomes a very handy tool. A lack of response could be due to:

  • A server with that IP address doesn't exist.

  • The server has been configured not to respond to pings.

  • A firewall or router along the network path is blocking ICMP traffic.

  • You have incorrect routing. Check the routes and subnet masks on both the local and remote servers and all routers in between. A classic symptom of bad routes on a server is the ability to ping servers only on your local network and nowhere else. Use TRaceroute to ensure you're taking the correct path.

  • Either the source or destination device has an incorrect IP address or subnet mask.

  • You may have lost connectivity to the gateway router on the network. If you can't get to the first network hop, your traffic won't be able to leave the LAN. Try pinging the gateways to make sure they are responsive.

There are a variety of ICMP response codes that can help in further troubleshooting. See the appendix for a full listing of them.

The Linux ping command sends continuous pings, once a second, until stopped with a Ctrl-C. Here is an example of a successful ping to the server bigboy at 192.168.1.100:

     [[email protected] tmp]# ping 192.168.1.101
     PING 192.168.1.101 (192.168.1.101) from 192.168.1.100 : 56(84) bytes
     of data.
     64 bytes from 192.168.1.101: icmp_seq=1 ttl=128 time=3.95 ms
     64 bytes from 192.168.1.101: icmp_seq=2 ttl=128 time=7.07 ms
     64 bytes from 192.168.1.101: icmp_seq=3 ttl=128 time=4.46 ms
     64 bytes from 192.168.1.101: icmp_seq=4 ttl=128 time=4.31 ms

     --- 192.168.1.101 ping statistics ---
     4 packets transmitted, 4 received, 0% loss, time 3026ms
     rtt min/avg/max/mdev = 3.950/4.948/7.072/1.242 ms
     [[email protected] tmp]#

You may get a Destination Host Unreachable message. This message is caused by your router or server knowing that the target IP address is part of a valid network, but is getting no response from the target server. There are a number of reasons for this.

If you are trying to ping a host on a directly connected network:

  • The server might be down or disconnected for the network.

  • Your NIC might not have the correct duplex settings; you may verify this with the mii-tool command.

  • You might have the incorrect type of cable connecting your Linux box to the network. There are two basic types: straight through and crossover.

  • In the case of a wireless network, your SSID or encryption keys might be incorrect

If you are trying to ping a host on a remote network:

  • The network device doesn't have a route in its routing table to the destination network and sends an ICMP reply type 3, which triggers the message. The resulting message may be Destination Host Unreachable or Destination Network Unreachable:

    [[email protected] tmp]# ping 192.168.1.105
    PING 192.168.1.105 (192.168.1.105) from 192.168.1.100 : 56(84) bytes
    of data.
    From 192.168.1.100 icmp_seq=1 Destination Host Unreachable
    From 192.168.1.100 icmp_seq=2 Destination Host Unreachable
    From 192.168.1.100 icmp_seq=3 Destination Host Unreachable
    From 192.168.1.100 icmp_seq=4 Destination Host Unreachable
    From 192.168.1.100 icmp_seq=5 Destination Host Unreachable
    From 192.168.1.100 icmp_seq=6 Destination Host Unreachable
    --- 192.168.1.105 ping statistics ---
    8 packets transmitted, 0 received, +6 errors, 100% loss, time 7021ms,
    pipe 3
    [[email protected] tmp]#
    


     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows