### Subnet Masks

Computers or devices need to know where you drew that line. That’s where subnet masks come in. These masks are a series of ones and zeros that tell the device which part is the network, and which is the host. In the example below, the subnet mask is show in the red box, first in binary, then in decimal.

One thing to note, subnet masks weren’t necessary when we had IP address classes. You could determine the subnet without a mask. But when subnets came into play, we needed masks to specify where the line was drawn. If you stuck to classful boundaries, it became a default subnet mask.

### CIDR Notation

CIDR was introduced much later than RFC 950 but will introduce it in this module to start becoming familiar with it. CIDR (Classless Inter-Domain Routing) notation, which simplifies subnetting. Instead of writing out subnet masks, you just count the number of ones in the mask. For example, a subnet mask of 255.240.0.0 is written as “/12” because it has 12 ones. It would look like this:

**10.0.0.0/12**

### Default Subnet Masks

Defualt Subnet Masks just represent the classful subnet mask, aligning with the boundaries of the original IP address classes. For instance, if we spot a Class A address with a 10 in the first octet, it means the first octet represents the network bits, and the rest are for hosts. So, we set all network bits to one and all host bits to zero, resulting in a default subnet mask of 255.0.0.0 (shown in red box below).

This is what it would look like in CIDR Notation

10.0.0.0/8

### Custom Subnet Masks

Custom subnet masks are subnet masks that fall outside the classful defined ranges. For instance, if we decide to borrow 4 bits, those bits become the network bits. The rest become host bits. In this example, the red box highlights the network portion and the yellow highlights the host portion.

Custom subnet masks can seem a bit odd, increasing in the following sequence: 0, 128, 192, 224, 240, 248, 252, 254, 255. This is because we are barrowing bits starting from the left most binary number available to the right.

If we borrow one bit, we activate the 128 switch, giving us a decimal value of 128. Borrowing two bits activates both the 128 and 64 switches, summing up to 192. Adding one more bit flips the 32 switch, resulting in 224. And so on, until we reach 255, which is when all switches are turned on. This process occurs per octet.