In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the usage of ping and arping commands in Linux system". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the usage of ping and arping commands in Linux system".
Ping
The ping program uses the forced echo request Datagram of the ICMP protocol to cause the host or gateway to send an echo reply of ICMP. The echo request Datagram ("pings") contains a header of IP and ICMP, followed by a ``time value keyword followed by an arbitrary length of padded byte to keep the packet length to an integer multiple of 16. Here are the options for the program:
Ping [- LRUbdfnqrvR] [- c count] [- I wait] [- l preload] [- p pattern] [- s packetsize]
Parameters.
-c
Count stops operation after sending (and receiving) exactly the number of echo reply packets of count. The special case where no packets are received after sending count packets is that the transmission results in termination (the selection host or gateway is unreachable).
-d
Use the SO_DEBUG option on the socket you are using.
-f
Do ping in a high-speed way. Output other packets or a hundred times per second at the speed at which the packets are returned. When each echo reply is received and a backspace is printed, a period ``is printed for each echo request. This quickly shows how many packets have been discarded, and only superusers can use this option. This is very demanding on the network and should be used with caution.
-I
The number of seconds wait waits for wait when sending each packet. The default value is to wait one second for each packet. This option cannot be used at the same time as the-f option.
-l
Preload if preload is specified, the ping program sends packets as soon as possible before starting normal operation mode. Again, only superusers can use this option.
-n
Output information in digital form only. So you don't try to find the hostname.
-p
Pattern can specify up to 16 padding bytes to keep the packet length to an integer multiple of 16. This option is useful when diagnosing data-related problems on the network. For example, ``- p ff will cause all packets sent out to populate the data area with all 1s.
-Q
Static output. Only summary lines are displayed when the program starts and ends.
-R
Record the route. The record routing option is included in the echo request packet and the routing buffer is displayed when the corresponding packet is returned. Note that the capacity of the IP header can only hold 9 such routes. Many hosts ignore or disable this option.
-r
Bypass the normal routing table on the connected network and send packets directly to the host. If the host is not on a directly connected network, an error is returned. This option can be used to detect a host through an unrouted interface (for example, when the interface has been discarded by the routed program).
S
Packetsize specifies the amount of bytes to send data. The default value is 56, which assembles a 64-byte ICMP Datagram after adding an 8-byte ICMP header.
-v
Verbose mode output. Print ICMP packets other than the received echo reply.
-w
Waitsecs stops the execution of the ping program after waitsecs seconds. This option is useful when trying to detect unreachable hosts.
When using ping to isolate faults, you should first run on the local host to check that the local network interface is running effectively. The hosts and gateways should then be further checked. The round trip time and packet loss rate are calculated. If duplicate packets are received, although the round-trip time of these packets is used to calculate the minimum / average / maximum round-trip time, they should not be counted in the missing packets just calculated. A short summary is displayed when a specified number of packets have been sent (and received) or if the program is terminated by a SIGINT signal.
If the ping program does not receive any return packets at all, it will exit with the return code 1. Return 2 if there is an error. Otherwise, 0 is returned. These values may be used to see if the host exists.
This program is designed for network testing, measurement and management. Because it uses network traffic, it is unwise to use it in normal operation or in automated scripts.
Example 1
For example, a ping baidu.
The code is as follows:
[root@localhost ~] # ping baidu.com
PING baidu.com (123.125.114.144) 56 (84) bytes of data.
64 bytes from 123.125.114.144: icmp_seq=1 ttl=54 time=3.51 ms
64 bytes from 123.125.114.144: icmp_seq=2 ttl=54 time=6.03 ms
-baidu.com ping statistics
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
Rtt min/avg/max/mdev = 3.515 ms 4.775 ms 6.036 Universe 1.262
Example b, specified times and time, interval ping baidu
The code is as follows:
[root@localhost] # ping-c 5-I 0.5 baidu.com
PING baidu.com (123.125.114.144) 56 (84) bytes of data.
64 bytes from 123.125.114.144: icmp_seq=1 ttl=54 time=2.92 ms
64 bytes from 123.125.114.144: icmp_seq=2 ttl=54 time=2.97 ms
64 bytes from 123.125.114.144: icmp_seq=3 ttl=54 time=2.99 ms
64 bytes from 123.125.114.144: icmp_seq=4 ttl=54 time=6.98 ms
64 bytes from 123.125.114.144: icmp_seq=5 ttl=54 time=3.14 ms
-baidu.com ping statistics
5 packets transmitted, 5 received, 0 packet loss, time 2011ms
Rtt min/avg/max/mdev = 2.925 ms 3.806 ms 6.985 ms
Example 2
For example:-I specifies the time interval for sending packets,-c specifies how many packets are sent,-I specifies the source address, and-Q specifies to directly display the startup and final result of the program.
The code is as follows:
# ping-I 0.2-c 30-I 192.168.10.208 180.149.132.47-Q
PING 180.149.132.47 (180.149.132.47) from 192.168.10.208: 56 (84) bytes of data.
-180.149.132.47 ping statistics-
30 packets transmitted, 30 received, 0 packet loss, time 5858ms
Rtt min/avg/max/mdev = 29.525 ms 29.857 Universe 33.755 ms
Arping
Arping command: send an ARP request on the specified network card to specify the address, and the "- s" parameter specifies the source address, which can be used to directly ping MAC the address and find out which computers are using those ip addresses.
-An ARP reply mode to update neighbors
-b keep broadcasting
-D copy address detection mode
-f quit when you get the first reply
-Q does not display warning message
-U active ARP mode to update neighbors
-number of packets sent by c
-w set the timeout
-I uses the specified Ethernet device and uses eth0 by default
-s specifies the source IP address
-h displays help information
-V displays version information
Example:
For example a, specify IP to send ARP request
The code is as follows:
[root@Blackghost ~] arping 192.168.1.11
ARPING 192.168.1.11 from 192.168.1.6 eth0
Unicast reply from 192.168.1.11 [08:00:27:7e:b8:08] 2.780ms
Unicast reply from 192.168.1.11 [08:00:27:7e:b8:08] 2.187m
Example b, sends an ARP request to the specified host and automatically exits when the first packet is received
The code is as follows:
[root@Blackghost] arping-f 192.168.1.11
Unicast reply from 192.168.1.11 [08:00:27:7e:b8:08] 3.080ms
Sent 1 probes (1 broadcast (s))
Received 1 response (s)
Example c, specify the number of times to send
The code is as follows:
[root@Blackghost] arping-c 4 192.168.1.11
Unicast reply from 192.168.1.11 [08:00:27:7e:b8:08] 3.080ms
Unicast reply from 192.168.1.11 [08:00:27:7e:b8:08] 2.670ms
Unicast reply from 192.168.1.11 [08:00:27:7e:b8:08] 1.850ms
Unicast reply from 192.168.1.11 [08:00:27:7e:b8:08] 4.120ms
Sent 4 probes (4 broadcast (s))
Received 4 response (s)
Thank you for your reading. the above is the content of "the usage of ping and arping commands in Linux system". After the study of this article, I believe you have a deeper understanding of the usage of ping and arping commands in Linux system, and the specific usage needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.