The little secret of ping command

Time:2021-11-25

Ping command is familiar to everyone. It is often used to test the connectivity of LAN. “Ping + IP address” is the most commonly used command format, but have you noticed the IP address in the ping command? There is a lot of knowledge and attention here. The following author will introduce these secrets hidden in the ping command.
“. 0” can be conditionally omitted
We often use “Ping”   127.0.0.1 “command performs loop test on the local machine to verify whether the local TCP / IP protocol cluster is installed correctly. But did you find out? Using “Ping”   The command “127.1” can also get the same test result (as shown in the figure). In fact, “Ping”   127.1 “and” Ping ”   127.0.0.1 “these two commands are the same. They are both performing loop test.
Why? This is the skill of using IP address in ping command application. As we all know, the IP address is composed of 32-bit binary digits. In order to facilitate your memory, every 8-bit binary digit is converted into decimal digits. Therefore, an easy to remember IP address composed of four decimal digits (such as 127.0.0.1) is formed. Due to, the windows operating system has automatic population   The function of “. 0”, so I can change “127.0.0.1” to “127.1”.
However, the omission of “. 0” is conditional and cannot be omitted arbitrarily. In the application of ping command, only one or more “. 0” appearing before the last decimal number of IP address can be omitted, such as “Ping”   The “127.0.0.1” command is changed to “Ping”   127.1”。
If this one or more   “. 0” has no decimal number next to the last part, but is in other positions, then this “. 0” cannot be omitted, such as “Ping”   202.0.96.1 “cannot be written as” Ping ”   202.96.1”。 This is because “Ping”   The result returned by “202.96.1” is the response information of “202.96.0.1”, not the response information of “202.0.96.1”.
Digital string instead of IP address
In the ping command, you can also use a numeric string instead of an IP address. Do you believe it? Run “Ping”   3658906394 “command, you will see the return information of the IP address” 218.22.123.26 “.
Why? In fact, “3658906394” is another representation of the IP address “218.22.123.26”. Of course, you can ping other IP addresses in the same way.
How are strings converted? In fact, it is not complicated. Take the IP address “218.22.123.26” as an example. The method to convert the IP address into a digital string is as follows: first   “218.22.123.26” is converted to hexadecimal “Da. 16.7b. 1A”, and then after removing the decimal point, it becomes “da167b1a”. Finally, this hexadecimal number is converted to decimal “3658906394”, then “218.22.123.26” becomes “3658906394”. The same method is used to convert other IP addresses to digital strings.
Tip: in some LAN environments, using the “Ping + digital string” command may fail, and the prompt message “unknown” appears   Host “because the string is resolved to a host name instead of an IP address.
Therefore, after mastering the above skills, the network management can skillfully use the “ellipsis” method in network testing or maintenance, reduce the character input of ping command and improve work efficiency. At the same time, using digital string instead of IP address can also confuse ordinary users with strong curiosity to avoid their random setting.