# The Subnet Mask and Slash Notation

The following image shows four IP subnets having six host addresses.

In binary, an IP address is 32 bits long. It divides these bits into four sections. In each, it keeps 8 bits or 1 byte (8 bits = 1 byte). It uses dots to separate them.

We use IP addresses in decimal. From 8 binary bits, the maximum number we can make in decimal is 256. IP addresses start from 0. Hence, the maximum number in decimal will be 255 (256 -1).

We use the subnet mask to separate network and host bits in an IP address. For 32 IP bits, we use 32 subnet mask bits. Subnet mask bits and IP address bits have one-to-one relations. The first subnet mask bit relates with the first IP bit, the second subnet mask bit with the second IP bit, and so on til the last bit.

A subnet mask bit shows the type of the related IP bit. If its value is 1, the IP bit will be a network bit. If its value is 0, the IP bit will be a host bit.

There are five IP classes . These are A, B, C, D, and E. Only classes A, B, and C are available for network addressing. We cannot use classes D and E for network addressing. Network services use class D for multicast addressing. Class E is reserved for research.

 Class First address (binary notation) Last address (binary notation) First address (decimal notation) Last address (decimal notation) A 00000000 01111111 0 127 B 10000000 10111111 128 191 C 11000000 11011111 192 223 D 11100000 11101111 224 239 E 11110000 11111111 240 255

IP addresses in classes D and E have all network bits. They do not have host bits. Since they do not have host bits and a subnet mask is used to differentiate host bits from network bits, they do not need a subnet mask.

Only IP addresses in classes A, B, and C have host bits and need a subnet mask. These classes have a default subnet mask.

The following table lists default subnet masks.

 Class Default subnet mask A 255.0.0.0 B 255.255.0.0 C 255.255.255.0 D Not applicable E Not applicable

Because of the default subnet masks, the first 8, 16, and 24 bits in classes A, B, and C are always network bits.

### Slash notation

Slash notation is a shorter way to write subnet masks. In this notation, instead of writing the full subnet mask, we use only the number of bits having the value 1 after the slash with the IP address.

For example, the default subnet mask of class A is 255.0.0.0. In binary, it is 11111111.00000000.00000000.00000000. It has 8 network bits having the value of 1. In slash notation, we will write this subnet mask as /8.

The default subnet mask of class B has 16 network bits. In slash notation, it will be /16. The default subnet mask of class C has 24 network bits. In slash notation, we will write it as /24.

 Class Default subnet mask Slash notation A 255.0.0.0 /8 B 255.255.0.0 /16 C 255.255.255.0 /24

The following table lists some examples of IP addresses and their subnet mask in all three notations.

 In Slash notation In binary notation In decimal notation 10.10.10.10/8 00001010.00001010.00001010.00001010 11111111.00000000.00000000.00000000 10.10.10.10 255.0.0.0 172.168.1.1/16 10101100.10101000.00000001.00000001 11111111.11111111.00000000.00000000 172.168.1.1 255.255.0. 192.168.1.1/24 11000000.10101000.00000001.0000000111111111.11111111.11111111.00000000 192.168.1.1 255.255.255.0 192.168.1.1/28 11000000.10101000.00000001.00000001 11111111.11111111.11111111.11110000 192.168.1.1 255.255.255.240

### Bits in the subnet mask

Bits in the subnet mask always follow a pattern. They are written from left to right. Network bits are always written before the host bits. We cannot write a host bit between network bits.

### Subnetting

Subnetting is a process of breaking an IP subnet into many small subnets. To break an IP subnet, we convert the host bits into network bits. We start the conversion process from the leftmost host bit.

When converting bits, we cannot skip any host bit. For example, if we want to break a subnet into two subnets, we will convert the leftmost host bit into a network bit. If we want to break it into four subnets, we will convert the two leftmost host bits into network bits.

This tutorial is the third chapter of the tutorial series. Other chapters of this series are the following.