Interesting ping trick, it ignores leading zeros in an IP address.

Posted: September 25, 2017. At: 2:21 PM. This was 3 months ago. Post ID: 11400
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

The IP address you supply the ping command with can have a leading zero or multiple leading zeros and they will be ignored by the ping command.

This is an example.

[email protected]:~$ ping 192.168.00001.00002
PING 192.168.00001.00002 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=0.012 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=0.018 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=0.019 ms
64 bytes from 192.168.1.2: icmp_seq=4 ttl=64 time=0.018 ms
64 bytes from 192.168.1.2: icmp_seq=5 ttl=64 time=0.018 ms
64 bytes from 192.168.1.2: icmp_seq=6 ttl=64 time=0.017 ms
64 bytes from 192.168.1.2: icmp_seq=7 ttl=64 time=0.018 ms

This is a very cool but pointless ping trick.

Even this does not affect it at all.

[email protected]:~$ ping 192.168.000000001.000000002
PING 192.168.000000001.000000002 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=0.013 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=0.024 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=0.021 ms
^C
--- 192.168.000000001.000000002 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2054ms
rtt min/avg/max/mdev = 0.013/0.019/0.024/0.005 ms

This trick also works on Windows with CMD.

C:\Users\jason>ping 192.168.00001.00002
 
Pinging 192.168.1.2 with 32 bytes of data:
Reply from 192.168.1.2: bytes=32 time<1ms TTL=128
Reply from 192.168.1.2: bytes=32 time<1ms TTL=128
Reply from 192.168.1.2: bytes=32 time<1ms TTL=128
Reply from 192.168.1.2: bytes=32 time<1ms TTL=128
 
Ping statistics for 192.168.1.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

This is interesting, but a useless trick. Creating an IP address with zeros in the wrong places could be interpreted as the wrong number when you try and ping it. A good explanation here: https://superuser.com/questions/857603/are-ip-addresses-with-and-without-leading-zeroes-the-same.

This is an example in Windows 8.1 of the ping command interpreting 192.168.1.010 as 192.168.1.8.

C:\Users\jason>ping 192.168.1.010
 
Pinging 192.168.1.8 with 32 bytes of data:
Reply from 192.168.1.2: Destination host unreachable.
 
Ping statistics for 192.168.1.8:
    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Control-C
^C

This is further proof that having a leading zero in an IP address is a very bad idea.

Yet another example.

C:\Users\jason>ping 192.168.1.020
 
Pinging 192.168.1.16 with 32 bytes of data:
Reply from 192.168.1.2: Destination host unreachable.
Reply from 192.168.1.2: Destination host unreachable.
Reply from 192.168.1.2: Destination host unreachable.
Reply from 192.168.1.2: Destination host unreachable.
 
Ping statistics for 192.168.1.16:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
2 responses to “Interesting ping trick, it ignores leading zeros in an IP address.

C:\Users\alex>ping 127.1

Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time=1ms TTL=128
Reply from 127.0.0.1: bytes=32 time=1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms

😉

[email protected]:~$ ping 127.0000.0000.00001
PING 127.0000.0000.00001 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.014 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.018 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.018 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.017 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.019 ms
64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.018 ms
64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.016 ms
^C
--- 127.0000.0000.00001 ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6128ms
rtt min/avg/max/mdev = 0.014/0.017/0.019/0.002 ms

Leave a Reply