> For the complete documentation index, see [llms.txt](https://docs.cloud.olakrutrim.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cloud.olakrutrim.com/basics/core-infrastructure/networking/subnets/cidr-classless-inter-domain-routing.md).

# CIDR (Classless Inter-Domain Routing)

## Understanding CIDR

**CIDR (Classless Inter-Domain Routing)** is a method for allocating IP addresses and routing traffic. Unlike older class-based addressing (Class A, B, C), CIDR enables more flexible and efficient allocation of IP addresses using **prefix notation**, such as:

```
192.168.1.0/24
```

In CIDR, the number following the slash (e.g., `/24`) is the **network prefix**, which determines how many IP addresses are included in the subnet range.

***

### Why is CIDR Important?

When creating a subnet, you must define how many IP addresses should be available for resources within that subnet. CIDR notation gives you precise control over subnet sizing, allowing you to balance between:

* **Small subnets** – e.g., `/30` for limited usage scenarios
* **Large subnets** – e.g., `/16` for high-scale deployments

Choosing the right CIDR size ensures efficient use of IP space while minimizing waste.

***

### CIDR Size Table

| CIDR Notation | Number of IPs | Usable IPs | Subnet Mask     | Example Range                 |
| ------------- | ------------- | ---------- | --------------- | ----------------------------- |
| /32           | 1             | 0          | 255.255.255.255 | 192.168.1.1                   |
| /30           | 4             | 2          | 255.255.255.252 | 192.168.1.0 – 192.168.1.3     |
| /29           | 8             | 6          | 255.255.255.248 | 192.168.1.0 – 192.168.1.7     |
| /28           | 16            | 14         | 255.255.255.240 | 192.168.1.0 – 192.168.1.15    |
| /27           | 32            | 30         | 255.255.255.224 | 192.168.1.0 – 192.168.1.31    |
| /26           | 64            | 62         | 255.255.255.192 | 192.168.1.0 – 192.168.1.63    |
| /24           | 256           | 254        | 255.255.255.0   | 192.168.1.0 – 192.168.1.255   |
| /23           | 512           | 510        | 255.255.254.0   | 192.168.0.0 – 192.168.1.255   |
| /22           | 1,024         | 1,022      | 255.255.252.0   | 192.168.0.0 – 192.168.3.255   |
| /21           | 2,048         | 2,046      | 255.255.248.0   | 192.168.0.0 – 192.168.7.255   |
| /20           | 4,096         | 4,094      | 255.255.240.0   | 192.168.0.0 – 192.168.15.255  |
| /16           | 65,536        | 65,534     | 255.255.0.0     | 192.168.0.0 – 192.168.255.255 |

> **Note**: The number of usable IPs is always 2 less than the total IPs — one is reserved as the network address and the other as the broadcast address.

***

### Choosing the Right CIDR Block

When selecting a CIDR block, use the following general guidance:

* Use `/30` or `/29` for **small setups** (e.g., 1–6 VMs)
* Use `/27` or `/26` for **medium setups** (e.g., 30–60 VMs)
* Use `/24` or `/23` for **large-scale environments**

{% hint style="info" %}
For most users, `/28` or `/27` is a good starting point unless larger address space is explicitly required.
{% endhint %}
