First thing you might wonder with the title of this article, is why the heck would you write leading 0’s in IP addresses? Well, fair enough. But read on about this little story of mine.
We have Excel sheets here listing all fixed IP addresses from our networks, to know which servers have them, and for which reason.
For a reason unbeknownst to me, we have put leading 0‘s in the addresses in those sheets. Well, thinking of it, maybe it was for cosmetic reasons or easier column sorting, but in that type of document we could have simply typed the IPs from a VLAN in a certain sequence once and for all.
Anyway, so we have this Excel file with these addresses, and server names/comments I don’t copy here:
A good-willing Operator had to configure a new server, so he went to the Excel file, chose a free address in the list, which was
, and copy-pasted it to the deploy wizard.
Some time later (when the server was actually brought online), we got a reported IP conflict on the network, and nobody understood why.
So check this out, let’s ping the address of the new server:
Yeah well, the .21 address was indeed already used. It turns out that using one leading zero in front of any IP chunk, will convert this chunk in octal (base-8). So the address 192.168.147.001 is read correctly in decimal, but .025 means 25 in octal, thus 2×8^1+5×8^0 i.e. 21 in decimal.
So even if in some software the correction might be done, never ever write your IP addresses with leading zero’s.
Now let’s have some fun. You probably now that “0x” is the prefix for the hexadecimal notation right?
Now WHY on earth you can do that, remains a mystery to me.