Friday, October 24, 2014

Ping

PING (Packet Internet Groper):

Ping is Member of iputils package.

[root@UnixBabuForun ~]# rpm -qf `which ping`
iputils-20071127-16.el6.i686
[root@UnixBabuForun ~]# rpm -ql iputils | grep "ping"

/bin/ping

Ping is having setuid by default and hence each user can be able to execute ping.

[root@UnixBabuForun ~]# ls -l /bin/ping
-rwsr-xr-x. 1 root root 36892 Mar 22  2011 /bin/ping




Send 3 requests to target with ping

[root@UnixBabuForun ~]# ping -c 3 192.168.79.135
PING 192.168.79.135 (192.168.79.135) 56(84) bytes of data.
64 bytes from 192.168.79.135: icmp_seq=1 ttl=64 time=1.30 ms
64 bytes from 192.168.79.135: icmp_seq=2 ttl=64 time=0.505 ms
64 bytes from 192.168.79.135: icmp_seq=3 ttl=64 time=0.441 ms

--- 192.168.79.135 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.441/0.749/1.301/0.391 ms

If the host is running with more then 2 ips, then we can use -I option to pass the ipaddress from which the ping test needs to be done.

[root@UnixBabuForun ~]# ping -I 192.168.79.130  192.168.79.135
PING 192.168.79.135 (192.168.79.135) from 192.168.79.130 : 56(84) bytes of data.
64 bytes from 192.168.79.135: icmp_seq=1 ttl=64 time=0.240 ms
64 bytes from 192.168.79.135: icmp_seq=2 ttl=64 time=0.279 ms
^C
--- 192.168.79.135 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1534ms
rtt min/avg/max/mdev = 0.240/0.259/0.279/0.025 ms

64 bytes is the default packet size, if you want to change the packet size use option s with ping command. here i will use 32 bytes, but it will be overhead  by 8 bytes. so it will be 40 bytes.

[root@UnixBabuForun ~]# ping -s 48 192.168.79.135
PING 192.168.79.135 (192.168.79.135) 48(76) bytes of data.
56 bytes from 192.168.79.135: icmp_seq=1 ttl=64 time=0.218 ms
56 bytes from 192.168.79.135: icmp_seq=2 ttl=64 time=0.438 ms
^C
--- 192.168.79.135 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1393ms
rtt min/avg/max/mdev = 0.218/0.328/0.438/0.110 ms

Ping will send the packets in 1sec intervel by default. we can custamize this intervel by using -i option.

[root@UnixBabuForun ~]#  ping -i 2 192.168.79.135
PING 192.168.79.135 (192.168.79.135) 56(84) bytes of data.
64 bytes from 192.168.79.135: icmp_seq=1 ttl=64 time=0.180 ms
64 bytes from 192.168.79.135: icmp_seq=2 ttl=64 time=0.483 ms
64 bytes from 192.168.79.135: icmp_seq=3 ttl=64 time=1.06 ms
^C
--- 192.168.79.135 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 4104ms
rtt min/avg/max/mdev = 0.180/0.577/1.069/0.369 ms



0 comments:

Post a Comment

 
Design by BABU | Dedicated to grandfather | welcome to BABU-UNIX-FORUM