For their entire working careers, the vast majority of IT people have glanced at their subnet when they run ifconfig and noticed that 99% of the time it says 255.255.255.0 and thought no more about that. If someone were to think about this further they might wonder what’s the point in having this number if it always appears to be the same.
That’s a good question. Here we explain what the subnet really means and how it relates to IP addresses.
Basically a subnet is used to tell a router to which network an IP address belongs. There is supposed to be only one subnet per network, but something called VLANS (virtual LANS) have let network engineers ignore that requirement and reuse them all they want. That might be why we see 255.255.255.0 all the time. That would be especially true in the cloud where each customer would want to have no restrictions on what number they use for the subnet and would want to be able to set up networking in the way they already understand and are comfortable with.
But not all networks are virtual networks. For example, the one in your house is what is called a flat network. Let’s look at that.
The majority of home computers on home networks have IP addresses like 192.268.1.xxx. That is just a convention that has become common.
The Linksys router that you plugin to your cellular modem is given an IP address, of say, 192.168.1.1, by Linksys when they manufacture it. You type http://192.168.1.1 when you want to log into that. Then each device in your house is given an IP address in the 192.168.1.xxx range, like 192.168.1.2.
(Your router has a public internet address too, like 18.104.22.168. That’s what gets recorded in web server logs when you go visit web sites. What that means is all of the people visiting websites in your house all have the same IP address. That is called NAT. So if your kid is downloading movies from Pirate Bay tell them to stop that as you could get blamed.)
An IP address is broken into four decimal numbers ranging from 0 to 255 and arranged into groups like this nnn.nnn.nnn.nnn. Let’s call each group an octet as it is 8 bits.
The reason that the highest octet value is 255 is that IP addresses are given in bits, which are the power of 2.
The maximum number you can write with bit notation is with 8 1’s or 11111111=255.
This notation 11111111 is powers of 2, since each bit can be a 0 or a 1. So it is this:
Now, the subnet, also called the subnet mask, means what network an IP address is on. Having a subnet tied
to an IP address is supposed to speed up a router by having it check fewer possibilities.
Obviously you can easily see that if the devices in your home network all look like 192.168.1.x then the network portion of that address is 192.168.1. The last octet, .2 in this case, denotes the host.
IP addresses are of either class A, B, C, D, or E. This classification means how many of the 1st four bits of the first octet in the IP address are 1.
We can illustrate this in the table below. For example, for an IP address in a type C network, like 192.168.1, the first octet is 110xxxxx. That is because 192 is written as 11000000. The lowest 8-bit number you can make with 110 in the first 3 positions is 11000000 (192) and the highest is 11011111 (233). So that is the range of class C IP addresses.
|A||0xxxxxxx||00000000 (0) to 01111111 (127)||0.0.0.0
22.214.171.124 (Google DNS server)
|B||10xxxxxx||10000000 (128) to 10111111 (191)|
|C||110xxxxxx||11000000 (192) = to 110111111 (223) .
|D||1110xxxxx||11100000 (224) to 11101111 (239)|
|E||1111xxxx||11110000 (240) to 11111111 (255)|
A subnet mask shows what portion of the IP address is used to denote the network, like 192.168.0, and what portion is used to denote the host, like .1.
The subnet mask is each bit in the IP address that the router should look at when determining the network part of the address and the host part. For the IP address 192.168.1.0 you have to look all the way down to the third octet in 192.168.1. Since the definition of the subnet is to set all those 24 bits (3 octets) to 1 and write out this number:
We have the netmask:
The .0 ending means that it’s not part of the network address. Those 8 bits are used for host IP
Why do you see this number so often on other networks?
Consider a server with this IP address 126.96.36.199 and this subnet mask: 255.255.255.0. That means all the devices on that network (subnet) have the IP address 215.54.150.n. So it requires all of the first 3 tuples to find the host by first finding the network and then search from there.
If I want more or less IP addresses on a network I change the subnet mask to grow or shrink the network and host portion of the IP address.
You can see that 255 IP addresses are not many, certainly not enough for a medium sized office. If you want to have more IP addresses then you take away bits from the network portion of the address and assign them to hosts. If you want to fewer IP addresses, such as you want to divide your network into segments like “accounting” and “sales” you would use more.
In other words you might want to use 1 more bit to divide your network right down the middle and have this 25-
bit subnet mask:
So that would give IP addresses on the first portion would be in the range 192.168.1.(1-127) and the second
Or you might want many twice as many IP addresses and use this 23-bit subnet:
Since bits are powers of 2 that would give you twice as many possible IP addresses or 2*255=510. And since we are using the last bit of the 3rd octet for IP addresses that means that we can have both 192.168.0.(1-255) and 192.168.1.(1-255) possible IP addresses since that bit can be a 1 or a 0.
Finally, CIDR notation is a way to write an IP address such that you can infer the subnet mask from the IP
address. It introduces a slash (/). So in the example above we would write 192.168.1.1/24 which means it takes 24 bits to determine the network address, thus having the netmask 255.255.255.0. And in the example below that where we used 1 more bit that notation is 192.168.1.1/23 with a subnet mask of 255.255.254.0.
Everything you need to know about outsourcing technology development
Access a special Introduction Package with everything you want to know about outsourcing your technology development. How should you evaluate a partner? What components of your solution that are suitable to be handed off to a partner? These answers and more below.