The little secret of the ping command _dos/bat

Source: Internet
Author: User
Tags numeric
Ping command, we are familiar with, it is often used to test the connectivity of the LAN state. "Ping+ip Address" is one of the most commonly used in a command format, but have you noticed the IP address in the ping command? There is a lot of knowledge and exquisite, the following author for you to explain the hidden in the ping command of these secrets.
". 0" can be conditionally omitted
We often use the "ping 127.0.0.1" command to do loop testing on this machine to verify that the TCP/IP protocol cluster is properly installed. But did you find out? Use the "Ping 127.1" command to get the same test results (figure), in fact, "Ping 127.1" and "ping 127.0.0.1" These two commands are the same, are in the loop test.
Why would that be? This is the technique used to use IP addresses in the ping command application. As we all know, the IP address consists of 32-digit binary digits, in order to facilitate the memory of everyone, the conversion of each 8-digit binary number to decimal digits, thus forming an easy to remember by the four part of the decimal digits of the IP address (such as 127.0.0.1). Because the Windows operating system has the ability to automatically populate ". 0", I can Change "127.0.0.1" to "127.1".
However, the omission of this ". 0" is conditional and cannot be omitted arbitrarily. In the application of the ping command, only one or more ". 0" that appears before the last decimal digit of the IP address can be omitted, such as by rewriting the ping 127.0.0.1 command to ping 127.1.
If this one or more ". 0" is not next to the last part of the decimal number, but in other places, then this ". 0" can not be omitted, such as "ping 202.0.96.1" can not be written as "Ping 202.96.1." This is because the result of "ping 202.96.1" is the answer to "202.96.0.1", not the "202.0.96.1" answer message.
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? When you run the ping 3658906394 command, you will see the return information for the IP address "218.22.123.26".
Why would that be? In fact, "3658906394" is another form of representation of the IP address "218.22.123.26". Of course, you can also ping other IP addresses in the same way.
How does a string change? In fact, it is not complicated, with the IP address "218.22.123.26" as an example, the IP address is converted to a numeric string method as follows: First convert "218.22.123.26" to hexadecimal "da.16.7b.1a", then remove the decimal point and change to " Da167b1a ", finally converts this hexadecimal number to decimal" 3658906394 ", then" 218.22.123.26 "becomes" 3658906394 ". The same method is used to convert other IP addresses to numeric strings.
Tip: In some LAN environments, using the "ping+ number string" command may fail, prompting a "Unknown host number string" because the number string is resolved to the host name, not the IP address.
Therefore, the master of the above skills, network management in the test or maintenance, you can skillfully use the "ellipsis" way to reduce the ping command character input, improve work efficiency. At the same time, the use of digital strings to replace the IP address can also confuse the curiosity of ordinary users, lest they randomly set.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.