0

So, I discovered a strange quirk of the Windows 10 ping utility. If you ping a whole number instead of an IP address, it will "convert" that number to an IPv4 address. The conversion is such that the first octet is your 256^3 spot, second octet is 256^2, third is 256^1, and the last octet being the "ones" place or 256^0.

For example "ping 200" will ping 0.0.0.200, but "ping 400" will ping 0.0.1.144, where the "1" in the third octet represents 256 (256 + 144 = 400).

A quick Google search (although I couldn't think of a great search term) didn't bring anything.

My only two theories are this:

  1. It may be the case that in an earlier iteration of the IP schema (i.e. the unused v1, v2, or v3), the plan was to just use single whole numbers. Microsoft, in its' obsession with backwards compatibility wrote a translation algorithm into the ping utility to handle this way way back when ping was first coded.
  2. It may be the case that due to the way the ping utility is coded, it normally takes a valid IPv4 address and translates it to a single whole number before doing something with that data. Thus, as a check in the code, if it sees that the user entered a single whole number, it just skips that initial translation step.

Any ideas? It definitely intrigued my co-workers, but they were just as clueless as I am.

EDIT: Just tested it on my Arch Linux machine, and I can confirm that the behavior exists there as well, so that likely discredits my first theory.

2

4 Answers 4

3

The answer is documented in Wikipedia:

Other address representations were in common use when classful networking was practiced. For example, the loopback address 127.0.0.1 is commonly written as 127.1, given that it belongs to a class-A network with eight bits for the network mask and 24 bits for the host number. When fewer than four numbers are specified in the address in dotted notation, the last value is treated as an integer of as many bytes as are required to fill out the address to four octets. Thus, the address 127.65530 is equivalent to 127.0.255.250.

1
  • Huh, surprised that never got covered in my college networking classes lol. Also, -1, really? I asked our Sr. engineer at work who has nearly 15 years IT experience and he had no idea. It's not like it's a well-known fact that you can ping numbers like that. Dec 4, 2020 at 1:00
1

It's not a quirk. It's a feature.

Remember that the dot notation of an IPv4 address is merely a way to represent the four-byte (i.e 32 bit) integer that is an IPv4 address (and that goes in the 32-bit destination field in an IP packet). Different utilities will accept different formats for this integer.

I know that in the past some browsers accepted decimal integers like this as an address in the address bar. (I was surprised that my two current browsers, Firefox and Chrome, no longer do this.)

0

".0" can be omitted conditionally

You often use the "ping 127.0.0.1" command to do a loop test on the machine to verify whether the TCP/IP protocol suite of the machine is correctly installed. But did you find it? The same test result can be obtained by using the command "ping 127.1". In fact, the two commands "ping 127.1" and "ping 127.0.0.1" are the same, both of which are performing loop tests.

Why is this so? This is the skill of using IP address in Ping command application. Everyone knows that the IP address is composed of 32 binary digits. In order to make it easier for everyone to remember, every 8 binary digits are converted into decimal digits. Therefore, an easy-to-remember IP address consisting of four-part decimal digits (such as 127.0.0.1 ). Since the Windows operating system has the function of automatically filling ".0", I can change "127.0.0.1" to "127.1".

However, the omission of this ".0" is conditionally restricted and cannot be omitted arbitrarily. In the application of the Ping command, you can only omit one or more ".0"s that appear before the last decimal number of the IP address, such as rewriting the "ping 127.0.0.1" command to "ping 127.1".

If the one or more ".0" is not next to the last part of the decimal number, but 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 the result returned by "ping 202.96.1" is the response message of "202.96.0.1" instead of the response message of "202.0.96.1".

Number string instead of IP address

In the Ping command, you can also use a numeric string instead of an IP address. Run the "ping 3658906394" command, and you will see the return information of the IP address "218.22.123.26".

Why is this so? In fact, "3658906394" is another representation of the IP address "218.22.123.26". Of course, you can also ping other IP addresses in the same way.

How is the string converted? In fact, it is not complicated. Taking the IP address "218.22.123.26" as an example, the method of converting the IP address into a numeric string is as follows: first convert "218.22.123.26" to hexadecimal "DA.16.7B.1A", and then remove it. After the decimal point, it becomes "DA167B1A", and finally the hexadecimal number is converted to decimal "3658906394", then "218.22.123.26" becomes "3658906394". The same method is used to convert other IP addresses into numeric strings.

Tip: In some LAN environments, using the "Ping+number string" command may fail, and the prompt message "Unknown host number string" appears. This is because the number string is resolved into a host name instead of an IP address.

-1

IPv4 addresses are unsigned 32-bit integers. In a misguided attempt to make them more human-readable, they are traditionally displayed in the UI in "dotted decimal" notation, where each octet (8-bit byte), starting with the most significant, is represented as a decimal number, separated from the next octet by a dot.

It's not terribly surprising that some UIs might allow you to input anything they can interpret as a UInt32 and use the resulting UInt32 as the IPv4 address you intended.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .