Are IP addresses with and without leading zeroes the same?

It depends on the tool.

For most purposes the two will be the same, but not always.

For example, if you use a 3-digit number starting with a zero (or a two-digit one starting with zero, thanks @Dietrich-Epp), then ping will assume the numbers are octal.

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users>ping 011.012.013.014

Pinging 9.10.11.12 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 9.10.11.12:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

Assuming all software you are using is using dot-decimal and subnetting correctly, yes they are the same.

192.168.0.1 for example is only the friendly dot-decimal notation of the dot-binary value 11000000.10101000.00000000.00000001.

Whether you type it as 192.168.0.1 or 192.168.000.001 they are both equal to 11000000.10101000.00000000.00000001


It depends on the tools or functions any given program uses to parse the address given. Both Microsoft and Linux as well as other OSes use a POSIX compatible inet_addr() routine for parsing addresses.

Many TCP/IP programs such as Ping and FTP use the inet_addr() sockets function to translate IP address strings into 4-byte addresses. This function accepts an IP address in standard decimal, octal, and hexadecimal notation.
Microsoft KB115388 Ping and FTP Resolve IP Address with Leading Zero as Octal

 

The inet_addr() function converts the Internet host address cp from IPv4 numbers-and-dots notation into binary data in network byte order.

In all of the above forms, components of the dotted address can be specified in decimal, octal (with a leading 0), or hexadecimal, with a leading 0X). Addresses in any of these forms are collectively termed IPv4 numbers-and-dots notation. The form that uses exactly four decimal numbers is referred to as IPv4 dotted-decimal notation (or sometimes: IPv4 dotted-quad notation).
inet_addr(3): Internet address change routines - Linux man page

As such, your specific system might require three-digit decimal notation for each octet, but this is not universal, and care should be taken to ensure the proper IP address is entered.

Of course, only valid numbers for each type will work. Out of range Octal, Hex or Decimal numbers will also fail or cause issues. Octal 088, Hex 0xGG, or Decimal 280 are all invalid examples.

Tags:

Ip

Networking