Sometimes, a strange phenomenon occurs when you use the Ping command. Ping is a command line program running in Windows. It is the main command used to detect network connectivity, accessibility, and name resolution problems in TCP/IP environments. The main use of Ping is to check whether the target host can be connected. The essence of Ping is to send an ICMP echo request packet to the target host and wait for the echo ICMP response, then print the echo message. This article does not need to discuss the Ping command application in detail. It points out a detail that is not worth attention and reminds everyone to pay special attention to it.
Enter ping 127.0.0.1 at the Windows2000/XP command prompt and press Enter. The echo message is displayed, indicating that ping is successful. Interestingly, if you enter ping 127. 0 .. 1 and press enter, note that it is not 127.0.0.1, and enter a value of 0 in the middle), you can also Ping it! Windows will automatically fill in the IP address with a "0" to form 127.0.0.1, figure 1 ).
The same result is returned when you run this command in Windows 98/Me! In another way, enter the command in the command line: ping 127... 0.1. You can also Ping the command. The system will automatically add the last "0" to the complete form. This is because when you Ping an IP address by using the Ping command, you can omit the null value of the IP address, that is, the value of "0", and use ".. "This format can automatically add null values in it, so we can omit" 0.
If we enter Ping 202.108.36.172 as the Netease IP address under the command line respectively) and Ping 202.108.036.172, will the echo result be the same? At first, I thought it was the same, but the result after command execution was far from my expectation-it was totally different from what I imagined. After you enter Ping 202.108.36.172 and press enter, all the displayed results are normal, exactly the same as we expected. When Ping 202.108.036.172, the Command Prompt window shows another IP Address: 202.108.30.172. Figure 2 )!
More interestingly, if you enter Ping 202.108.044.172 and press enter, the Command Prompt window displays the Ping address 202.108.36.172 (Figure 3 )!
Is this unexpected? In addition to Windows systems, the test results on FreeBSD are the same.
Why? This is because the system regards "036" in the above IP address as an octal number instead of a decimal number, the octal value "036" is converted to decimal, Which is exactly "30". You can use the calculator that comes with Windows to check it). Therefore, the system will think that we want to Ping 202.108.30.172. Adding 0 before the decimal number of the IP Address indicates that this is the octal number. Adding 0x indicates that this is a hexadecimal value. Run Ping 0x7f. 0.0.1 at the command prompt. After you press enter, you will find that the Ping is 127.0.0.1. Because 0x7f is the hexadecimal representation of the decimal value 127. Try again and enter Ping 0x7f. 0 .. 1 to guess what will happen? That's right. In this case, enter the IP address 127.0.0.1 for Ping.
Note: When you Ping an IP address by using the Ping command, only one part of the four parts of the IP address can be entered in octal or hexadecimal format, and the rest must be in decimal format, otherwise, an error occurs. For example, if you convert the IP address 202.108.36.172 to octal 0312.0154.044.0254, And Then Ping the IP address, the system reports the error Figure 4). Similarly, if you convert all parts of the IP address in dotted-decimal format to hexadecimal format, an error is reported when you Ping the system. Therefore, it is better to use a decimal IP address for Ping.
In the future, when using the Ping command, we should pay special attention to the fact that one more "0" and one less "0" are sometimes different.
Related Articles]
- Tips for using Ping commands
- The Ping Command vulnerability cannot be ignored.
- Do not underestimate the ping command