preface
In fact, we have mentioned some of the use of the ping command before, but we have not explained too much about the ping command. Generally, we use the basic functions of the ping command. Today, we will look at the detailed use of the ping command.
A, ping basic use details
Ping is a very powerful TCP/IP tool in the network. Its main functions are as follows:
1. Used to detect the connectivity of the network and analyze the network speed
2. Obtain the server IP address based on the domain name
3. Determine the operating system used by the peer and the number of packets that pass through routers based on the TTL value returned by the ping.
We usually use it to ping IP addresses directly to test network connectivity.
For example, if you ping an IP address or gateway, the following information is displayed: bytes=32; Time < 1 ms; TTL=128 what does this mean?
Bytes value
: Packet size, that is, bytes.The time value
: Response time. The smaller the response time, the faster you can connect to this address.TTL value
: Time To Live: indicates the Time that the DNS records on the DNS server. It is a value of the IP protocol packet that tells the router when the packet needs To be discarded. You can roughly determine whether the target system type is Windows or UNIX/Linux based on the TTL value returned by Ping.
By default, the TTL is 64 or 255 for Linux, 128 for WindowsNT/2000/XP, 32 for Windows98, and 255 for UNIX hosts.
Therefore, the general TTL value is:
- Between 100 and 130ms, Windows system;
- 240 to 255ms on UNIX/Linux.
Of course, these are not the main things we learned today, but other references to Ping.
The ping command has other uses besides directly ping the IP address of the network to verify network connectivity and speed.
Ping -t
Ping the specified computer continuously until the administrator interrupts.
This shows that the computer is connected to the router, the network effect is very good. Now press Ctrl+ C on the keyboard to stop it and continue ping, it will stop, it will sum up how many packets are sent, how many are on and off.
3. Use ping -a
Ping -a Resolves the computer name and NetBios name. The host name can be resolved by ping its IP address.
Ping -n
By default, only four packets are sent. Using this command, you can define the number of packets to be sent, which is helpful to measure the network speed. For example, if I want to test the average return time, the fastest time, and the slowest time of 10 packets, I can obtain the following information:
From the above, I can know that in the process of sending 10 packets to 47.93.187.142, 10 packets were returned without loss. Among these 10 packets, the return speed is the fastest 32ms, the slowest 55ms, and the average speed is 37ms. I have a good network.
If for some bad network, such as the monitoring system is very slow, so the test, the return result may show that part of the loss, if the loss is more, then it shows that the network is not good, you can intuitively judge the network situation.
Ping -l size
-l size: sends packets of specified size to the destination host.
By default, Windows ping sends 32byt packets and a maximum of 65500byt packets. If the number of packets sent at a time is greater than or equal to 65500BYT, the computer of the receiver may break down. So Microsoft capped the number; This parameter can do a lot of damage when combined with other parameters, such as the -t parameter. (So it is dangerous, do not easily use other people’s computers).
For example, ping -l 65500 -t 211.84.7.46
Ping the IP address continuously until the user interrupts by pressing Ctrl+C.
It keeps sending 65,500byt packets to 211.84.7.46 computers. If you have only one computer, it may not work, but if you have many computers, it can completely disable the other computer and cause network congestion, which is a big deal.
Ping -r count
In the Record Route field, record the routes of the outgoing and returned packets
Number of routes, but a maximum of nine routes can be traced.
Ping -n 1 -r 9 202.102.224.25 (Send a packet, record a maximum of nine routes)
All nine routes are displayed, as shown in the figure above.
The ping command is mostly used in these 6 categories, you may use in the project.
Ping network segments in batches
For a network segment with many IP addresses, if a single detection is really troublesome, then we can directly batch ping network segment detection, which IP address is wrong, at a glance.
First look at the code, directly from the command line window type:
For /L %D in (1,1,255) do ping 10.168.1.%D
Change the IP address segment to the IP address segment you want to check.
When a batch command is entered, it automatically pings all IP addresses in the network segment until they are finished.
For /L %D in(1,1,255) do ping 10.168.1.%D
The (1,1,255) in the code is the start and end of the network segment, which is to detect all IP addresses between 192.168.1.1 and 192.168.1.255, increment by 1 each time, until the 255 IP addresses from 1 to 255 are detected.
end… From: www.toutiao.com/a6783191796…
This article is shared from the wechat public account – IT dys_family. If there is infringement, please contact [email protected] to delete. This article participates in “OSC source innovation Program”, welcome you to join us and share with us.