Ping Command on CISCO Router/Switch

Command

Ping

Use

Allows you to verify reachbility of a remote device. This is one of the most useful of the diagnogstic commands.

Syntax

Router#ping <ip address or DNS name>

OR

Router#ping

Optional Switches

data

df-bit
repeat
size
source

timeout
validate

Example

In this example a user pings from R1 to R2. The ‘.‘ represents a failure and the ‘!‘ represents a success. If you ever see a single failure at the being of a ping that usually means the router hasn’t finished its ARP process for the destination.

R1(config-if)#do ping 10.1.1.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 4/27/72 ms
R1(config-if)

You can use the repeat option with the ping command to specify how many times the router will ping the remote host.

R1#ping 10.1.1.2 repeat 100

Type escape sequence to abort.
Sending 100, 100-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Success rate is 100 percent (100/100), round-trip min/avg/max = 64/108/180 ms
R1#

You can also use the size option to set the size of the ping packet. This is useful for a variety of reasons, but at the CCNA level, the best use is making sure the downstream routers can support abnormal MTUs (Maximum Transmission Unit). The MTU is the maximum size that a router will allow a packet to be for it to transmit..

Additionally you can use the df-bit with your testing to prevent the routers from fragmenting the packet.

R1#ping 10.1.1.2 size 2000

Type escape sequence to abort.
Sending 5, 2000-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 68/156/276 ms
R1#ping 10.1.1.2 size 2000 df-bit

Type escape sequence to abort.
Sending 5, 2000-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:
Packet sent with the DF bit set
…..
Success rate is 0 percent (0/5)
R1#

R1#ping 10.1.1.2 size 1500 df-bit

Type escape sequence to abort.
Sending 5, 1500-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:
Packet sent with the DF bit set
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 68/97/144 ms
R1#

One of the more useful options is source. Source allows you to send a ping from any interface you want on the router.

By default ping will source its ping from the closest match in the routing table. You may want to change the source-interface to verify proper routing.

In the below example R1 tries to ping R2 via it’s Loopback 0 interface. Looking at the debug ip packet output on R2, we can see that packets to 1.1.1.1 are unroutable. This means the route 1.1.1.1 is not in R2’s routing table.

R1#ping 10.1.1.2 source loopback 0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
…..
Success rate is 0 percent (0/5)

R2#debug ip packet
IP packet debugging is on
R2#
*Mar 1 00:23:23.619: IP: tableid=0, s=1.1.1.1 (FastEthernet0/0), d=10.1.1.2 (FastEthernet0/0), routed via RIB
*Mar 1 00:23:23.619: IP: s=1.1.1.1 (FastEthernet0/0), d=10.1.1.2 (FastEthernet0/0), len 100, rcvd 3
*Mar 1 00:23:23.619: IP: s=10.1.1.2 (local), d=1.1.1.1, len 100, unroutable
R2#
*Mar 1 00:23:25.575: IP: tableid=0, s=1.1.1.1 (FastEthernet0/0), d=10.1.1.2 (FastEthernet0/0), routed via RIB
*Mar 1 00:23:25.575: IP: s=1.1.1.1 (FastEthernet0/0), d=10.1.1.2 (FastEthernet0/0), len 100, rcvd 3
*Mar 1 00:23:25.575: IP: s=10.1.1.2 (local), d=1.1.1.1, len 100, unroutable
R2#
*Mar 1 00:23:27.551: IP: tableid=0, s=1.1.1.1 (FastEthernet0/0), d=10.1.1.2 (FastEthernet0/0), routed via RIB
*Mar 1 00:23:27.551: IP: s=1.1.1.1 (FastEthernet0/0), d=10.1.1.2 (FastEthernet0/0), len 100, rcvd 3
*Mar 1 00:23:27.555: IP: s=10.1.1.2 (local), d=1.1.1.1, len 100, unroutable
R2#
*Mar 1 00:23:29.587: IP: tableid=0, s=1.1.1.1 (FastEthernet0/0), d=10.1.1.2 (FastEthernet0/0), routed via RIB
*Mar 1 00:23:29.587: IP: s=1.1.1.1 (FastEthernet0/0), d=10.1.1.2 (FastEthernet0/0), len 100, rcvd 3
*Mar 1 00:23:29.587: IP: s=10.1.1.2 (local), d=1.1.1.1, len 100, unroutable
R2#
*Mar 1 00:23:31.567: IP: tableid=0, s=1.1.1.1 (FastEthernet0/0), d=10.1.1.2 (FastEthernet0/0), routed via RIB
*Mar 1 00:23:31.567: IP: s=1.1.1.1 (FastEthernet0/0), d=10.1.1.2 (FastEthernet0/0), len 100, rcvd 3
*Mar 1 00:23:31.571: IP: s=10.1.1.2 (local), d=1.1.1.1, len 100, unroutable

Checking the routing table on R2 confirms that there is no route for 1.1.1.1

R2#show ip route
Codes: C – connected, S – static, R – RIP, M – mobile, B – BGP
D – EIGRP, EX – EIGRP external, O – OSPF, IA – OSPF inter area
N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2
E1 – OSPF external type 1, E2 – OSPF external type 2
i – IS-IS, su – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2
ia – IS-IS inter area, * – candidate default, U – per-user static route
o – ODR, P – periodic downloaded static route

Gateway of last resort is not set

2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 2 subnets
C 10.2.2.0 is directly connected, FastEthernet1/0
C 10.1.1.0 is directly connected, FastEthernet0/0
R2#

Lets quickly add a static route to fix this problem

R2(config)#ip route 1.1.1.1 255.255.255.255 10.1.1.1

And now we can ping.

R1#ping 10.1.1.2 source loopback 0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/42/84 ms
R1#

Finally, you can a lot more options using extended ping. This is done by simply typing the ping command.
Many of the options of this command have been discussed already or are out of the CCNA scope. If your IOS doesn’t support using the ping options, then you can do the same thing with the extended ping.

R1#ping
Protocol [ip]:
Target IP address: 10.1.1.2
Repeat count [5]: 5
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: yes
Source address or interface: loopback0
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/29/44 ms
R1#

Related Articles

guest
0 Comments
Inline Feedbacks
View all comments