Can anyone please explain why CMD pings a different IP address than the one I am searching for?
-
This is a duplicate, I just can't remember where– Canadian LukeCommented Mar 26, 2015 at 16:09
-
@DavidPostill, It's not a duplicate, because in the question you linked to, the system was treating numbers with and without leading zeroes as decimal, but in this question, it's pretty clear the system is interpreting leading zeroes as octal numbers.– Sam SkuceCommented Mar 27, 2015 at 14:06
-
3@SamSkuce Did you read the highest voted answer? "For example, if you use a 3-digit number starting with a zero (or a two-digit one starting with zero, ... ), then ping will assume the numbers are octal."– DavidPostill ♦Commented Mar 27, 2015 at 14:12
-
1As well, when we suggest a duplicate post, the OP is asked to look at the question and answers to see if it's the same– Canadian LukeCommented Mar 27, 2015 at 16:22
Add a comment
|
1 Answer
On Windows CMD if you put leading zeros on the IP address means octal.
It is interpreting 016
as 16 octal
and converts it to 14 decimal
.
You can use octal, decimal or hexadecimal notation as in the following example:
22.101.31.153 (decimal)
026.0145.037.0231 (octal)
0x16.0x65.0xF1.0x99 (hexadecimal)
-
3Wow. That is a terrible undocumented "feature". Turns out Chrome does it also (
4.4.4.8
and4.4.4.010
are equivalent) Commented Mar 26, 2015 at 17:58 -
3Well BEEP, it works with hex too! That makes the old
ping 10.1000001
look almost sane...ping 10.0xDEAD
... !!! Commented Mar 26, 2015 at 19:17 -
38It's neither terrible, nor undocumented; this is the regular notation for IPv4 addresses– sleblancCommented Mar 26, 2015 at 20:06
-
5@LukeMcGregor No. I think the standard itself is bad. I think leading 0 octal notation is bad. And while I'm glad Microsoft followed the standard, I'd prefer it be buried behind a switch for usability purposes, or at least some information being given to say that a specific number is being read as octal, and you should leave out the 0 if you don't want that.– trlklyCommented Mar 27, 2015 at 4:01
-
4The people handling IP addresses should understand what they are before using them. Leading zero octal notation is common enough that it is a mistake you will only do once. End users typically are not expected to handle IP addresses, or at least, they should not alter the representation. If the manual for your router says "connect to 172.16.0.1", you should not type in "172.016.000.001".– sleblancCommented Mar 27, 2015 at 22:15