Labels

Arduino (1) Brainf**k (1) Bugs (3) C (1) HTML (1) Install (3) Linux (27) Maths (1) Python (12) Raspberry Pi (4)

Monday, 13 July 2015

How to use the ping command

Ping is a program that is used to test the reachability of a host. It also measures the time it takes to send the packet and receive one.

It does this by sending a ICMP echo request packet and waiting for a reply. Pretty much all Linux flavours will come with Ping pre-installed.


How to ping using a specific interface
ping -I wlan0 google.com
This will ping google using the wlan0 interface

How to send a certain amount of ping requests
ping -c 4 google.com
This will send 4 ICMP echo requests to google

How to change the timeout of a ping
ping -w 5 google.com
This changes the timeout of the ICMP request to 5 seconds

How to ping yourself to check your interface is working
ping 0
or
ping 127.0.0.1
or
ping localhost
They all essentially do the same thing which is ping yourself.

Most ping output should look something like this:

matty@matty-ThinkPad-T420 ~ $ ping google.com
PING google.com (216.58.210.14) 56(84) bytes of data.
64 bytes from lhr08s06-in-f14.1e100.net (216.58.210.14): icmp_req=1 ttl=55
64 bytes from lhr08s06-in-f14.1e100.net (216.58.210.14): icmp_req=2 ttl=55
64 bytes from lhr08s06-in-f14.1e100.net (216.58.210.14): icmp_req=3 ttl=55
64 bytes from lhr08s06-in-f14.1e100.net (216.58.210.14): icmp_req=4 ttl=55
^C
--- google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 26.039/32.973/37.669/4.941 ms