Ping's IP Address Completion Feature
A meme came across my feed today that demonstrated a "pro tip" in which to ping your loopback address 127.0.0.1 you would have to only issue the command as shown below.
$ ping 127.1
I thought this was odd and happened to be on my computer at the time, so I opened up a command prompt and gave it a try and sure enough it worked!
>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
Ping statistics for 127.0.0.1:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
Control-C
^C
Trying it on a Linux machine works too!
$ ping 127.1
PING 127.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.028 ms
^C
--- 127.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.028/0.028/0.028/0.000 ms
$
I started playing around a bit and realized that it also works for other IP addresses, and the behavior appears to be that if you are missing all 4 octets, it will take the last octet you have specified, treat that as the fourth octet, and fill in zeros in the middle. Below are some examples.
$ ping 10.1
PING 10.1 (10.0.0.1) 56(84) bytes of data.
You can see it filled in 2 octets of zeros in this instance
$ ping 10.1.1
PING 10.1.1 (10.1.0.1) 56(84) bytes of data.
You can see it treated the last .1 as the 4th octet and filled in a 0 in the missing 3'rd place
$ ping 192.168.1
PING 192.168.1 (192.168.0.1) 56(84) bytes of data.
You can see here it treated the last .1 as the 4th octet and filled in a 0 in the missing 3'rd place also
While this is a cool trick, I don't foresee myself using it often as I feel when pinging things in an ipv4 address, it's not that hard to specify all of the digits and for the sake of the conciseness I think it best to just type out the whole address. But for the loopback I can see myself picking this habit up!
None the less, it is a cool party trick, if there ever was a party that this would be an acceptable trick!