Tuesday, December 23, 2014

Resolve the hostname in ping command

In Linux, we use the "ping" command to ping the hostname or the IP address directly. But what if you wanted to know the hostname of the system when you ping using the IP address? This would be very useful in resolving the IP to hostname while debugging in a local network.

$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=57 time=40.4 ms
Just use an additional '.' at the end of the IP to resolve it to hostname.

$ ping 8.8.8.8.
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from google-public-dns-a.google.com (8.8.8.8): icmp_seq=1 ttl=57 time=25.0 ms
64 bytes from google-public-dns-a.google.com (8.8.8.8): icmp_seq=2 ttl=57 time=36.9 ms

Thursday, November 20, 2014

URL Magic - Rare IP address notations

URL (Uniform Resource Locator). We might have heard in this WWW era. Forgetting the intricate details of its implementation, an URL simply means a web address. The RFC of the URI can be found here. This post is just about its rare formats. (For details, refer to the section 7.4 in the RFC)

Rare formats
These rare formats are just for fun. This is not widely used because, it's hard for people to remember and you have to decode it everytime. Nevertheless, this is a good way to hide bookmarks or you can use it as prank with your friends.

Hexadecimal and octal notation
Get the IP address of your favorite website by pinging it. Convert each octet into different format. Paste it in the URL area of the browser. It would still work.
For instance, pinging google.com gives this IP 173.194.113.168 for me. This is the cryptic notation of the same IP. This would still work. :-)

http://0xad.0xc2.0161.168

How about this?

http://0XADC271A8
http://2915201448

The above are 32-bit representation of the IP addresses. Every octet is just represented in its hexadecimal form. In the second format the hexadecimal number is converted to an Integer.

Another notation is that the IP address is split into two parts.

http://0xad.0xC271A8

In the above, the first octet is interpreted as it is and the rest are just coalesced into one.

It's really fun to know about this. Start fooling your friends ;-)

Page Counter