# Subnetting (Part 1)

### Subnetting

The IANA (Internet Assigned Numbers Authority) assigns IPv4 addresses/networks to companies based on their size. For example, large companies may receive a Class A or Class B network, while a small company might receive a Class C network. But it led to many wasted IP addresses. E.g. when using a point-to-point network - a network connecting only two points ( two offices, branches, cities, etc), only 2 addresses are assigned to these two points, one for the network, and one for the broadcast; even if we use Class C network we waste 252 addresses.&#x20;

The IETF (Internet Engineering Task Force) introduced **CIDR** (Classless Inter-Domain Routing) in 1993 to replace the classful addressing system. With CIDR, larger networks were allowed to be split into smaller networks, allowing greater efficiency. These smaller networks are called **subnetworks** or **subnets**.&#x20;

### Class C subnetting

#### /25

<figure><img src="https://3642595937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKsHxwINrQaKCeVpC90i9%2Fuploads%2FS6pEfO0Pv83T3Gzfaqhv%2Fimage.png?alt=media&#x26;token=1c5f5a6a-c8b6-46e5-b35c-cacad42e2e4f" alt="/25" width="563"><figcaption></figcaption></figure>

The network portion of the address is extended into the first bit of the last octet. And the mask in dotted decimal is now `255.255.255.128`. There are now 7 bits in the host portion of the address, so the number of usable addresses is `2^7-2=126`.

#### /26

<figure><img src="https://3642595937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKsHxwINrQaKCeVpC90i9%2Fuploads%2FoJLeyzHqfj2z2IuugHUV%2Fimage.png?alt=media&#x26;token=2c703a7e-a2ef-47e2-8276-bc0d92b37b94" alt="/26" width="563"><figcaption></figcaption></figure>

The mask in dotted decimal is written as `255.255.255.192`. The number of usable addresses is 62.

#### /27

<figure><img src="https://3642595937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKsHxwINrQaKCeVpC90i9%2Fuploads%2F1n9tg4R4RY0lgExJhLNI%2Fimage.png?alt=media&#x26;token=691b80a8-ea25-4f34-b12d-3cbfb56b8716" alt="/27" width="563"><figcaption></figcaption></figure>

The mask is `255.255.255.224`. The number of usable addresses is 30.

#### /28

<figure><img src="https://3642595937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKsHxwINrQaKCeVpC90i9%2Fuploads%2F9HD8teBnzWMBGqC9DgGM%2Fimage.png?alt=media&#x26;token=67ec2831-1e79-4b50-b889-edc9f8885556" alt="/28" width="563"><figcaption></figcaption></figure>

The mask is `255.255.255.240`. The number of usable addresses is 14.

#### /29

<figure><img src="https://3642595937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKsHxwINrQaKCeVpC90i9%2Fuploads%2FY1EgMlaqwyJEsxkJ9yrU%2Fimage.png?alt=media&#x26;token=f5cdce55-5ff1-421b-85a0-36380813506f" alt="/29" width="563"><figcaption></figcaption></figure>

The mask is `255.255.255.248`. The number of usable addresses is 6.

#### /30

<figure><img src="https://3642595937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKsHxwINrQaKCeVpC90i9%2Fuploads%2F2fY7LVKmKw3zd17cbXZy%2Fimage.png?alt=media&#x26;token=04c45906-726a-47f8-aad9-83885db73e4c" alt="/30" width="563"><figcaption></figcaption></figure>

The mask is `255.255.255.252`. The number of usable addresses is 2 - perfect for point-to-point networks. `203.0.113.0/30` includes the address range of `203.0.113.0` - `203.0.113.3` first address being the network address, the next two are usable addresses, and the last one is a broadcast address. The remaining addresses in the `203.0.113.0/24` address block are available to be used in other subnets.

#### /31

<figure><img src="https://3642595937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKsHxwINrQaKCeVpC90i9%2Fuploads%2FbZ85DstB21nJUIh1l7HL%2Fimage.png?alt=media&#x26;token=4e9e5ad2-fdc9-4e2d-9bf0-7b6f778f25f8" alt="/31" width="563"><figcaption></figcaption></figure>

The mask is `255.255.255.254`. The number of usable addresses is 0. However, this subnet mask can be used for point-to-point networks because it consists of only 2 addresses and there is no need for the network and broadcast addresses. For any other cases, this would be a problem since it leaves no usable addresses after subtracting the network and broadcast addresses.&#x20;

#### /32

<figure><img src="https://3642595937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKsHxwINrQaKCeVpC90i9%2Fuploads%2FQOmspNldxV4cYj3OCHWy%2Fimage.png?alt=media&#x26;token=645a3997-1420-4138-8777-4d1c68355be6" alt="/32" width="563"><figcaption></figcaption></figure>

The mask is `255.255.255.255`. This mask cannot be used here and usually is not used at all for configuration. However, there are some use cases, e.g. when creating a static route to one specific host.

Here is a chart summarizing dotted decimal subnet masks and their equivalent in CIDR notation.

<figure><img src="https://3642595937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKsHxwINrQaKCeVpC90i9%2Fuploads%2FGckhqV7jf5V7iBaab7JW%2Fimage.png?alt=media&#x26;token=be342816-b82d-46b4-8f34-7afbae9dfe2a" alt="dotted decimal to cidr notation" width="375"><figcaption></figcaption></figure>

{% file src="<https://3642595937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKsHxwINrQaKCeVpC90i9%2Fuploads%2FO2ejnyLeXJ4Lt2eAsi6e%2FDay%2013%20Flashcards%20-%20Subnetting.apkg?alt=media&token=4081f463-7ed8-4180-8fdf-70903653ca1f>" %}
