Subnet masks are absolutely one of the most confusing things I have ever encountered. It is likely, you have also experienced a considerable amount of confusion as well.
Subnet Mask Explained
So let’s define: What is a subnet mask?
I liked this definition which I will use from wikipedia.org on subnet masks.
A subnetwork, or subnet, is a logically visible subdivision of an IP network.[1] The practice of dividing a network into subnetworks is called subnetting.
It breaks a larger network, into smaller subnets. A logical, visible subdivion….Well let’s see how they work.
Key Concepts
1. In order to understand subnet masks, we have to think Binary (base 2)
and NOT decimal (base 10).
2. IPv4 addresses are given in octets. Meaning that we have one byte or 8 binary digits (bits) to represent a number. Lowest number we can represent in 8 bits is zero (0), highest (HIGH VALUE or ALL BITS ON) is 255 (base 10.) Numbering starts at zero (0) and not one (1). So we have 256 choices!
3. Subnet masks are identified with a / or slash after the IP address:
4. 192.168.0.0/30
30 bits CAN’T change. only gives us 2 bit that can change. So it would allow 4 subnet hosts. Remember the 1 bit (on,) means it can NOT change. A zero bit (off,) means it CAN change. BUT one bit is reserved for broadcast, and one bit for network (we can’t use those so we have to subtract that!)
3 2 2 2 1 1 2 8 4 0 6 2 8 4 1111 1111 1111 1111 1111 1111 1111 1100 (binary)
(32 – 30) = 2 bits allowed to change. (2^2) -2 = 2 choices.
NOTE: ^ means raised to the power of. So 2 raised to the power of 2 (2 squared) = 4.
So a subnet mask of 30 allows us to control two (2) subnet hosts.
5. A subnet mask of 20 i.e.
3 2 2 2 1 1 2 8 4 0 6 2 8 4 1111 1111 1111 1111 1111 0000 0000 0000 (binary)
192.168.0.0/20, means (32-20) = 12 bits allowed to changed. (2^12) -2 = 4094.
Again, 2 raised to the 12th power (2x2x2x2x2x2x2x2x2x2x2x2) = 4096.
6. A /24 sub network 192.168.0.0/24
3 2 2 2 1 1 2 8 4 0 6 2 8 4 1111 1111 1111 1111 1111 1111 0000 0000 (binary)
Means 24 bits CAN’T change. (32 – 24) = 8 (2^8) – 2 = 254.
Allows 254 subnet hosts, since we have masked OFF 24 bits, only 8 can change! (minus one bit for broadcast, one bit for network)
—–
Thanks Loni, for looking over my shoulder.
Remember. Bits, nibbles, and bytes can hurt you! Be careful out there!
Wayno
Related Articles
1 user responded in this post
OHHH! Fixed bad bug causing all references in wikipedia to error out. Sorry about that!
Wayno
06/03/2012