Linux (28) Python (13) Raspberry Pi (5) Bugs (3) Install (3) C (2) Brainf**k (1) HTML (1) Maths (1) Sorts (1)

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
This will ping google using the wlan0 interface

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

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

How to ping yourself to check your interface is working
ping 0
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
PING ( 56(84) bytes of data.
64 bytes from ( icmp_req=1 ttl=55
64 bytes from ( icmp_req=2 ttl=55
64 bytes from ( icmp_req=3 ttl=55
64 bytes from ( icmp_req=4 ttl=55
--- 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

No comments:

Post a comment