ping Command in Linux

Back

The ping command allows you to test connectivity. It can be locally, within a network, and across networks on the internet. For the purpose of this section, assume your IP address is 192.168.122.50, and the gate way address on the local network is 192.168.122.1

If you are having a problems connecting to a network, try the following ping commands in order. 
The first step is to test the integrity on your computer

# ping 127.0.0.1
    loop-back address

Normally, ping works continuously on Linux ,you'll need to press CTRL+C to stop this command. If you need to verify the proper connection to a LAN, ping the IP address of the local network card.

# ping 192.168.122.50

If that works, ping address of another compter on your network. Then start tracing the route to the internet. ping the address for the network gateway, in this case, 192.168.122.1. 

If possible, ping the address for the network's connection to the Internet, which would be on the other side of the gateway. It may be public IP address of the LAN on the internet. Add finally, ping the address of a computer that you know is active on the internet.

You can substitute host-names such as www.google.com for a IP address. If the host-name does not work, there is likely a problem with the database of host-names and IP address ,more commonly known as ( DNS )  Domain Name Server , Berkeley Internet Name Domain ( BIND ), or nameserver .

It could also indicate the problem with the /etc/hosts configuration file.