# Subnets

A **Subnet** is a range of IP addresses within a VPC that groups resources. In the same analogy for VPC being the neighbourhood you have created for all your resources, isolated from other neighborhoods, Subnet here represents the particular segment/line/area inside your neighbourhood. You can determine if this area wants to be accessed by anyone publicly (Public subnet) or if it’s completely restricted to the people inside the area only (Private subnet)

* Can be **Public** (internet-facing) or **Private** (internal-only)
* One subnet can host multiple VMs

***

#### Creating a Subnet <a href="#creating-a-subnet" id="creating-a-subnet"></a>

1. Navigate to **Networking > Subnets**
2. Click **"Create Subnet"**
3. Fill in:
   * VPC (required)
   * Subnet Name (required)
   * Description
   * Access Type: Public / Private (required)
     * Public - Public subnets can be accessed through the internet. Public IP addresses that you want to assign to your publicly accessible VMs can only be assigned to this type of subnet
     * Private - Private subnets cannot be accessed through the internet. Only private IP addresses will be created inside this subnet, and you can only add privately accessible VMs inside this subnet
   * CIDR (required)
     * CIDR means Classless Inter-Domain Routing. It’s notation to define the range of IP addresses for your subnet. It also defines how big your subnet is. For more details, check the section below
   * Gateway IP (required)
     * It's the IP address used by instances in the subnet to send traffic outside the subnet (like to the internet or other subnets). It’s mainly used for:
       * Routing internal traffic or
       * Connecting to the internet via an internet or NAT gateway, or
       * Being the default route in the route table for resources in the subnet
4. If no VPC exists, → option to create one in the pop-up
5. Click **"Create Subnet"**
6. Subnet appears in the list with its properties

***

#### Deleting a Subnet <a href="#deleting-a-subnet" id="deleting-a-subnet"></a>

You can only delete a subnet **if it is not attached to any VM**. Here's how the process works:

**Pre-check**

* If the subnet **is currently attached to any VM**, the UI will:
  * **Block deletion**
  * Show a warning:

    ❌ "Subnet is in use by one or more Virtual Machines. Please detach all VMs before deleting the subnet."

***

**If Subnet is NOT attached:**

1. Navigate to **Networking > Subnets**
2. Click on the **three-dot menu** next to the subnet you want to delete
3. Select **"Delete Subnet"**
4. A confirmation dialog appears with a caution:

   ⚠️ "Deleting this subnet is irreversible and will remove the subnet and all its route table associations."
5. To confirm, you must **type the subnet name manually** (copy-paste disabled)
6. If the entered name matches:
   * Subnet is deleted successfully
   * Toast: “Subnet deleted successfully”
7. If mismatch:
   * Toast: “Entered name does not match. Deletion cancelled”

#### Billing and Pricing <a href="#billing-and-pricing" id="billing-and-pricing"></a>

Subnets are completely free, and you won’t be charged for any subnets


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cloud.olakrutrim.com/basics/core-infrastructure/networking/subnets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
