In my previous article on the subject, which you can read here, I went over the very bare bones basics about IP addresses; that is, how they're divided into classes, what the classes mean, and an example of how some IP addresses are special.
In this article, we will be going over how to convert IP addresses to various formats (binary, octal, hexadecimal, DWORD, and DNS), as well as subnet addressing and how it works, netmasks, and subnet masks.
Let's get started.
Converting DNS addresses to normal IP addresses
Most people don't consider a DNS to be an IP address, but it is. All a DNS does is point you to an IP address; it just puts a fancy name on it and makes it easier on people to visit. Let's use http://www.yahoo.com as an example. Do you think Yahoo would be so popular if people had to type 18.104.22.168 into their browser every time they wanted to visit it? Me either.
Getting the normal IP of a DNS is really quite simple, and there are various ways to do it. I'll go over the ping way.
For Windows users, open up the Command Prompt (Start-->Run-->cmd.exe) and ping yahoo.com. Simple. The output should look something like this:
Pinging yahoo.com [22.214.171.124] with 32 bytes of data:
Reply from 126.96.36.199: bytes=32 time=130ms TTL=55
Reply from 188.8.131.52: bytes=32 time=129ms TTL=55
Reply from 184.108.40.206: bytes=32 time=127ms TTL=55
Reply from 220.127.116.11: bytes=32 time=130ms TTL=56
Ping statistics for 18.104.22.168:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 127ms, Maximum = 130ms, Average = 129ms
So you see, simply pinging it gives you the IP address. Easy enough. Other methods include looking up ARIN whois data, tracert, etc.
Converting normal IP addresses to hexadecimal and DWORD
Let's think of an IP address as four different parts, separated by decimal places (which you should know by now is precisely what an IP address is). Our example, Yahoo, breaks down into 66, 94, 234, and 13. Take these numbers and do the following:
- Convert them to their hexadecimal equivalents
- Convert those numbers to their decimal equivalents
It's that simple. So let's get down to work. 66=42, 94=5E, 234=EA, and 13=0D. Well, that was easy. (Note: there are various ways to convert decimal to hexadecimal...either Google it or just open Calculator for Chrissakes).
Now it says we have to convert 425EEA0D to decimal. Hmm, seems pretty easy. Just have to find a hexadecimal to decimal converter and we're all set. Using Windows' included Calculator program, I find that 425EEA0D=1113516557, and 1113516557 is the DWORD equivalent of http://www.yahoo.com or 22.214.171.124.
Converting IP addresses to binary
Convert the IP address to its hexadecimal equivalent using the process described above and then convert that to binary. Easy enough. 425EEA0D=1000010010111101110101000001101. Note that typing "1000010010111101110101000001101" into most browsers won't do a damn thing.
Converting IP addresses to octal
Break the IP address into four parts as you did to convert it to hexadecimal, then convert those numbers straight to octal instead of hex. You can find plenty of converters and conversion tables online.
There is one difference when converting IP addresses to octal...each "section" of the address must be preceded with a zero. For example, the octal value of http://www.yahoo.com, broken down, is: 102, 136, 352, and 15. If you were to put 102.136.352.15 into your address bar, it wouldn't know what to do, as that isn't a valid IP address. So what you do is precede each value with 0: http://0102.0136.0352.015. Simple as that.
Converting IP addresses to hexadecimal
This was described above, except instead of keeping all of the values merged together, you do them separately; 42.5E.EA.0D would be our IP in hex.
By now you should know that IP addresses are separated into two parts. If not, they are: the network ID (or net ID for short) and the host ID. To summarize my previous article on the subject, the number of octets (or bits, whichever you prefer) in an IP address that the net ID and host ID both contain are dependent on the class or range of the IP address. For example, if an IP address belongs to class C, then the first 8 bits (the first octet) are allocated to the net ID and the remaining 24 bits (3 octets) are allocated to the host ID part.
This is not all there is to IP addresses, however. To make things more complicated, we're going to divide IP addresses into three parts: the net ID, the host ID, and the subnet ID. Subnets are used for a few things like hiding the structure of an internal network and preventing the waste of IP addresses. For example, let's take a typical class B IP address, which is divided as so: the first 16 bits are the net ID and the second 16 bits are the host ID. A division like this requires 2^16-2 hosts to be attached to that particular network--more than you'll find on any network on the 'net, meaning if IPs were divided simply by net ID and host ID, we'd have many, many wasted IP addresses.
Note: You may be wondering why you subtract 2 from 2^16 to determine how many IPs would need to be allocated to that network...the reason for this is simple: 0 and 255 are usually reserved for special IPs.
This is where subnetting comes in. A class B after subnetting should look something like this: first 16 bits are net ID, next 8 bits are subnet ID, and last 8 bits are host ID. This lets there be a possible 254 hosts per subnet of the 254 subnets possible. I know that's a lot to take it at once. Just think about it 'til you understand it, 'cause I've sat here for ten minutes trying to think of a way to better explain it and I can't :)
A netmask is a 32-bit value containing one bits (255s) for the network ID and zero bits (0s) for the host ID> By studying the netmask value of an IP address, you can determine the class to which an IP belongs. Neat, huh?
So what does a netmask look like, huh? Open a command prompt again and type "route PRINT". Take a look at the values under "Netmask." Like I said, they're made up of one bits (255s) and zero bits (0s), so they shouldn't be hard to spot. A typical netmask is 255.0.0.0, which you should see is connected to your box from and to the loopback interface address as discussed in my previous article.
Let's look at that netmask. 255.0.0.0. What does that mean? Well, it means that the first octet (first 8 bits) is reserved for the network ID (you know this because it contains only one bits) and the last 3 octets (last 24 bits) are reserved for the host ID (you know this because it contains only zero bits). This means that the IP address 127.0.0.1 is a class C IP address (127 being the network ID and 0.0.1 being the host ID).
Yeah, that's right; there are netmasks, ergo there are subnet masks. It means pretty much the same thing--a 32 bit value made up of one bits (255s (net ID)) and zero bits (0s (host ID)). Along with netmasks, subnet masks can be used to find out exactly how many bits are allocated for the net ID, the host ID, and the subnet ID. Well how in the hell do I do that, you ask? Let's show you with an example. I'll use the made up IP address 126.96.36.199, which has a netmask of 255.255.0.0, and a subnet mask of 255.255.255.0. Now, looking at the netmask, you see that the first 16 bits are the net ID and the second 16 bits are the host ID. So you know that the net ID=205.66 and the host ID=48.92. However, let's think about the subnet mask. It says that the first 3 octets (24 bits) should be the net ID...and the last octet (8 bits) should be the host ID...
Okay...so..hmm. The net ID and subnet ID put together=205.66.48 and the host ID=92. Using this, we can determine the following: net ID=205.66, subnet ID=48, and the host ID=92. So you see, the netmask gives you the boundary between the host ID and the network ID, whereas the subnet mask gives you the boundary between the network ID and the subnet ID.
If you wanna find all this out about yourself, simply Start-->Run-->ipconfig. It lists your IP, class, net ID, subnet ID, and host ID for you.
That's pretty much all there is to IP addresses.
Cast your vote on this article 10 - Highest, 1 - Lowest
Comments: Published: 13 comments.
HackThisSite is is the collective work of the HackThisSite staff, licensed under a CC BY-NC license.
We ask that you inform us upon sharing or distributing.