Thursday, May 21, 2009

How Are IP Addresses and Subnet Masks Related?

One of the topics that I (along with many others) had trouble understanding was how to differentiate the network side of an IP address with the host side of an IP address. For example, our computer has an IP address 192.168.1.1 with a subnet mask of 255.255.255.0. The subnet mask is key in determining the difference between your network address and host address.

Now let’s break down our computer’s IP. Every IP consists of four, 8-bit octets that range in decimal value from 0 to 255. For instance, 192 (our IP’s 1st octet) in decimal translates to 11000000 in binary (for more information on binary to decimal translation, see this article: http://www.wikihow.com/Convert-from-Binary-to-Decimal). This next step is key. ANY BINARY ‘1’ IN OUR SUBNET DEFINES THE NETWORK, and ANY ‘0’ IN OUR SUBNET DEFINES OUR HOST. Because our subnet mask’s 1ST, 2nd, and 3rd octets are 255 (or 11111111 in binary), this means that our network address that our IP exists in is 192.168.1.0. The 4th octet, thus, defines the host number in this network. So in this one particular network, 192.168.1.0, we can have up to 254 host computers. You may wonder why not 255?? This is because the host address 255 (192.168.1.255) is reserved for the network’s broadcast address. Therefore, we can only host 254 addresses on our network (1-254).

Let’s try a little harder example this time. Say we go to the command line on our computer and do an “ipconfig” command to display our IP and subnet mask. The output displays our IP address being 192.168.1.193 with a subnet mask of 255.255.255.192. The first thing to do is break the IP address into each octet. Luckily for us, the 1st three octets are all our network address as defined by the subnet being all 1’s (255 = 11111111 in binary). Now all we need to worry about is our last octet! The 192 in our subnet mask translates to 11000000 in binary (All ‘0s’ being possible host IP addresses). Because our network is defined by 1’s in the subnet, the first 2 bits of the last octet of our IP are still part of the network address. So, if we translate 193 to binary, we get 11000001. 193 ends up being the first host in the network 192.168.1.192! So in this case, our network address is 192.168.1.192 in which hosts in this network will range from 192.168.1.193 – 192.168.1.254!

Fortunately for us, IPv6 has been created which voids the need for differentiating the network address from the host address using a subnet mask. I will post this topic in a later article, but for now, IPv4 takes practice, practice, and even more practice to understand the concept of the relationship between your IP address and subnet mask. Try it yourself on your computer at home and let me know how things go!

No comments:

Post a Comment