Checking Network Connectivity
Using ping
A good way to check for network connectivity is by using the ping command. The basic syntax of the command expects a host to be specified.
root@hostname:directory# ping 192.168.1.144
This command sends data in the form of packets and listens for returned packets. By checking the number and percentage of packets returned, you can gauge the quality and response of the network connection. Note that you need to interrupt the output of ping using <Ctrl>+C so that the prompt returns.
If you have a LAN, you may want to first check whether you are connected to your local gateway. As an example, check the following output:
root@hostname:directory# ping 192.168.1.5 PING 192.168.1.5 (192.168.1.5) 56(84) bytes of data. 64 bytes from 192.168.1.5: icmp_seq=1 ttl=64 time=3.02 ms 64 bytes from 192.168.1.5: icmp_seq=2 ttl=64 time=0.244 ms 64 bytes from 192.168.1.5: icmp_seq=3 ttl=64 time=0.232 ms <Ctrl>+C --- 192.168.1.5 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2002ms rtt min/avg/max/mdev = 0.232/1.167/3.026/1.314 ms demo:/var/easypush/etc#
As we see above, a number of lines are printed on the screen. Each line represents a packet sent to the host and returned back. The time taken for the round trip is shown, along with some summary statistics. If there is no network connection, an output similar to the following appears:
root@hostname:directory# ping 192.168.1.5 PING 192.168.1.5 (192.168.1.5) 56(84) bytes of data. --- 192.168.1.5 ping statistics --- 3 packets transmitted, 0 received, 100% packet loss, time 2008ms demo:/var/easypush/etc#
The message "0 received, 100% packet loss" indicates that the network link to the given host could possibly be broken.
Using ethtool
deepOfix provides ethtool, a command with a simple syntax and high utility. It checks the ethernet interface as argument which you specify as argument.
root@hostname:directory# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pg
Wake-on: d
Current message level: 0x000000c5 (197)
Link detected: yes
root@hostname:directory#
In above output, "Link detected: yes" indicates that the network interface eth0 is up.
Using traceroute
The traceroute command traces the path of a packet sent to a particular host. It lists sequentially, each gateway involved in transferring a packet to the host specified as argument. This is useful to check your connection to systems outside a LAN. You can use it to check connectivity to the Internet.
root@hostname:directory# traceroute www.iisc.ernet.in traceroute to www.iisc.ernet.in (220.227.207.41), 30 hops max, 40 byte packets 1 192.168.1.5 (192.168.1.5) 0.192 ms 0.135 ms 0.109 ms 2 * * dsl-KK-static-001.192.95.61.airtelbroadband.in (61.95.192.1) 35.138 ms 3 dsl-KK-static-234.63.101.203.airtelbroadband.in (203.101.63.234) 41.928 ms 50.485 ms 39.671 ms 4 59.145.6.85 (59.145.6.85) 41.348 ms 40.454 ms 47.524 ms 5 125.17.12.69 (125.17.12.69) 41.382 ms 51.414 ms 45.801 ms 6 59.145.7.21 (59.145.7.21) 50.166 ms 53.345 ms 54.707 ms 7 61.95.180.17 (61.95.180.17) 46.609 ms 47.190 ms 49.362 ms 8 59.145.7.57 (59.145.7.57) 230.985 ms 235.826 ms 204.620 ms 9 61.95.151.170 (61.95.151.170) 75.458 ms 72.554 ms 72.951 ms 10 198.32.202.65 (198.32.202.65) 69.662 ms 78.223 ms 70.749 ms 11 198.32.202.113 (198.32.202.113) 71.362 ms 75.862 ms 269.194 ms <Ctrl>+C root@hostname:directory#
Since we are looking to check Internet connection, we can break by pressing <Ctrl>+C once we find external IP addresses appearing in the output listing. If the connection is slow, ping can be used too.
