> ## Documentation Index
> Fetch the complete documentation index at: https://gcore-doc-1256a.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create and manage a subnetwork

export const MethodSection = ({children}) => children ?? null;

export const MethodSwitch = ({children}) => {
  const tabs = React.Children.toArray(children).filter(c => c && c.props && c.props.id);
  const firstId = tabs.length > 0 ? tabs[0].props.id : "";
  const [active, setActive] = React.useState(firstId);
  React.useEffect(() => {
    try {
      const saved = localStorage.getItem("gcore_docs_method");
      if (saved && tabs.find(t => t.props.id === saved)) {
        setActive(saved);
      }
    } catch (_) {}
  }, []);
  React.useEffect(() => {
    try {
      document.querySelectorAll("h2[id], h3[id]").forEach(heading => {
        const visible = heading.offsetParent !== null;
        document.querySelectorAll(`a[href="#${heading.id}"]`).forEach(link => {
          if (link.closest("h1,h2,h3,h4,h5,h6")) return;
          const li = link.closest("li");
          if (li) li.style.display = visible ? "" : "none";
        });
      });
    } catch (_) {}
  }, [active]);
  const handleClick = id => {
    setActive(id);
    try {
      localStorage.setItem("gcore_docs_method", id);
    } catch (_) {}
  };
  return <div>
      <div className="not-prose flex gap-0 border-b border-zinc-200 dark:border-zinc-800 mb-8 mt-2" role="tablist">
        {tabs.map(tab => {
    const isActive = active === tab.props.id;
    return <button key={tab.props.id} role="tab" aria-selected={isActive} onClick={() => handleClick(tab.props.id)} className={["px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors cursor-pointer", isActive ? "border-primary text-primary" : "border-transparent text-zinc-500 hover:text-zinc-800 dark:hover:text-zinc-200"].join(" ")}>
              {tab.props.label}
            </button>;
  })}
      </div>

      {tabs.map(tab => <div key={tab.props.id} style={{
    display: active === tab.props.id ? "" : "none"
  }}>
          {tab.props.children}
        </div>)}
    </div>;
};

<MethodSwitch>
  <MethodSection id="portal" label="Customer Portal">
    A subnetwork is a range of IP addresses in a cloud network. Addresses from this range will be assigned to Virtual Machines (VMs) in the cloud.

    ## Create a subnetwork

    You can create a subnetwork in two ways: [during the creation of a Gcore Virtual Machine](/cloud/virtual-instances/create-an-instance) or from the **Networks** page, which is described in the following section.

    ### Create a subnetwork from the networks page

    1. In the Gcore Customer Portal, navigate to **Cloud** > **Networking**.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/O2fvsv9KLjD8CjMq/images/docs/cloud/networking/create-and-manage-a-subnetwork/networks-page.png?fit=max&auto=format&n=O2fvsv9KLjD8CjMq&q=85&s=446faf0f27f7526b8443efa37f0a9daf" alt="Networks page open in the Customer Portal" width="5388" height="1988" data-path="images/docs/cloud/networking/create-and-manage-a-subnetwork/networks-page.png" />
    </Frame>

    2. Find the network where you want to create a subnetwork and click its name to open it.
    3. Click **Create subnetwork**.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/O2fvsv9KLjD8CjMq/images/docs/cloud/networking/create-and-manage-a-subnetwork/network-settings-create-subnet.png?fit=max&auto=format&n=O2fvsv9KLjD8CjMq&q=85&s=fd7783d015eb71f08857090369af63b3" alt="Network settings section with the highlighted Create a subnetwork button" width="3580" height="1152" data-path="images/docs/cloud/networking/create-and-manage-a-subnetwork/network-settings-create-subnet.png" />
    </Frame>

    4. A new **Create subnetwork** page will open. Here, you can customize subnetwork settings.
    5. Enter the subnetwork name.
    6. Set a CIDR within the specified range:

    * 10.0.0.0/8
    * 172.16.0.0/12
    * 192.168.0.0/16
    * fc00::/7

    Set the mask between 16 and 24. You can find more information in the [Set the IP range](/cloud/networking/create-and-manage-a-subnetwork#set-the-ip-range) section.

    7. (optional) Turn on the **Enable DHCP** toggle to assign IP addresses to machines in the subnet automatically.

    <Warning>
      **Warning**

      For IPv6 networks, you can only enable or disable DHCP when creating a subnetwork. Changing this setting later is only possible via recreating the IPv6 subnetwork.
    </Warning>

    8. (optional) Turn on the **Non-routable subnetwork** toggle to block access to the subnet from external networks and other subnets. If you keep the network routable, you can specify the **Gateway IP** address. Otherwise, a random IP address will be assigned.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/O2fvsv9KLjD8CjMq/images/docs/cloud/networking/create-and-manage-a-subnetwork/create-subnetwork-name-cidr-dhcp.png?fit=max&auto=format&n=O2fvsv9KLjD8CjMq&q=85&s=802a0689939dfda18980361e1b82684a" alt="Network configuration example" width="1728" height="1408" data-path="images/docs/cloud/networking/create-and-manage-a-subnetwork/create-subnetwork-name-cidr-dhcp.png" />
    </Frame>

    9. (optional) Specify custom DNS servers for the subnetwork. If you don't need custom DNS settings, leave the field blank.
    10. Define how traffic is distributed within the network. Each subnetwork supports up to 20 host routes.

    * **Destination:** Specify the network or host where the traffic is intended to go.
    * **Next hop:** Choose the intermediate device (e.g., a router or gateway) through which traffic must pass to reach the destination.

    11. (optional) Turn on **Add tags** to add metadata to the subnetwork.
    12. Click **Create subnetwork**.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/O2fvsv9KLjD8CjMq/images/docs/cloud/networking/create-and-manage-a-subnetwork/create-subnetwork-dns-config.png?fit=max&auto=format&n=O2fvsv9KLjD8CjMq&q=85&s=06baa395f311654683a04c998093032b" alt="Network configuration example" width="1820" height="1192" data-path="images/docs/cloud/networking/create-and-manage-a-subnetwork/create-subnetwork-dns-config.png" />
    </Frame>

    ## Set the IP range

    While creating a subnetwork, specify the address range in the CIDR format.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/O2fvsv9KLjD8CjMq/images/docs/cloud/networking/create-and-manage-a-subnetwork/create-subnetwork.png?fit=max&auto=format&n=O2fvsv9KLjD8CjMq&q=85&s=88be58fff43b6531b4be5e9a1846a23f" alt="Create a subnetwork dialog" width="2136" height="864" data-path="images/docs/cloud/networking/create-and-manage-a-subnetwork/create-subnetwork.png" />
    </Frame>

    Your subnetwork's IP range must not overlap with others in the same network. Overlapping subnets cause network conflicts and break connectivity. Virtual machines in the same network communicate using private IP addresses, but subnetworks in different networks cannot communicate unless you configure routing.

    The subnetwork size is set using the classless addressing (CIDR) method. You can use both private IPv6 and IPv4 addresses in subnetworks.

    Acceptable CIDR ranges for IPv4 addresses are as follows:

    * 10.0.0.0 - 10.255.255.255
    * 172.16.0.0 - 172.31.255.255
    * 192.168.0.0 - 192.168.255.255

    The valid subnet mask range is 16-29.

    ### Comparison of IPv4 and IPv6 subnets

    The table below outlines key networking features for IPv4 and IPv6, including supported CIDR ranges, subnet mask configurations, and connectivity options.

    | **Feature**                 | **IPv4**                                                                                   | **IPv6**                                                                   |
    | --------------------------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
    | **CIDR ranges**             | 10.0.0.0/8<br />172.16.0.0/12<br />192.168.0.0/16                                          | fc00::/7                                                                   |
    | **Subnet mask range**       | /8 - /29 for 10.0.0.0/8<br />/12 - /29 for 172.16.0.0/12<br />/16 - /29 for 192.168.0.0/16 | /7 - /126                                                                  |
    | **Floating IP support**     | Yes                                                                                        | No                                                                         |
    | **Internet access**         | Yes                                                                                        | No – private IPv6 subnets are not publicly routable<br />Yes – public IPv6 |
    | **DHCP configuration**      | Can be enabled or disabled                                                                 | Cannot be changed after creation                                           |
    | **Routing between subnets** | Allowed within the same network                                                            | Allowed within the same network                                            |
    | **UI availability**         | Available to all users                                                                     | Available to all users                                                     |

    ## Configure network routing

    A routed network is a private network that's already connected to a router with a public interface. All Virtual Machines in such networks can access the internet through the router and accept incoming connections.

    By default, a subnetwork in the cloud is created with internet access, which means that it's routable. If you need to restrict machines from external connections, you need to enable the **Non-routable subnetwork** option while creating a subnetwork.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/O2fvsv9KLjD8CjMq/images/docs/cloud/networking/create-and-manage-a-subnetwork/enable-non-routable-subnetwork.png?fit=max&auto=format&n=O2fvsv9KLjD8CjMq&q=85&s=e6d53de8127e51eb46304b1d13f4b724" alt="Create subnetwork dialog" width="2136" height="1296" data-path="images/docs/cloud/networking/create-and-manage-a-subnetwork/enable-non-routable-subnetwork.png" />
    </Frame>

    ### Set up the default gateway

    <Warning>
      **Warning**

      Changing the subnet gateway or disabling it may cause loss of connectivity between the private IP and the Floating IP (if they exist). 
    </Warning>

    If your Gcore Virtual Machine or Gcore Bare Metal server has both public and private interfaces, disable the default gateway for all private subnetworks. Otherwise, there will be a conflict with the default gateway on the server, and you won't be able to connect to the server.

    If you need to configure a gateway in a private subnetwork, ensure that only one of your subnetworks is routable. To do this, check the subnetwork settings and verify that only one subnetwork has the **Enable router gateway** toggle active.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/O2fvsv9KLjD8CjMq/images/docs/cloud/networking/create-and-manage-a-subnetwork/disable-router-gateway.png?fit=max&auto=format&n=O2fvsv9KLjD8CjMq&q=85&s=0d75008fcfd3584a5fea5aa8d61fe922" alt="Edit subnetwork dialog" width="2124" height="1316" data-path="images/docs/cloud/networking/create-and-manage-a-subnetwork/disable-router-gateway.png" />
    </Frame>

    If you add a private interface (with or without a floating IP) after creating a server, some operating systems may not activate it automatically. This is especially common for Bare Metal servers. In such cases, configure the interface manually.

    **Gateway IP validation**

    Validation ensures proper configuration and prevents errors during creation or updates. The gateway IP address must belong to the defined CIDR range of the subnetwork. For example, if the CIDR is 192.168.0.0/24, the gateway IP must be within the 192.168.0.0 - 192.168.0.255 range.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/O2fvsv9KLjD8CjMq/images/docs/cloud/networking/create-and-manage-a-subnetwork/gateway_ip_validation_error.png?fit=max&auto=format&n=O2fvsv9KLjD8CjMq&q=85&s=a99c86a931fcc9d876906a519a3d881b" alt="Gateway ip validation error" width="672" height="735" data-path="images/docs/cloud/networking/create-and-manage-a-subnetwork/gateway_ip_validation_error.png" />
    </Frame>

    ## Manage subnetworks

    You can view and manage subnetworks on the **Networking** page of the Gcore Customer Portal.

    ### Rename a subnetwork

    1. In the Gcore Customer Portal, navigate to **Cloud** > **Networking**.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/O2fvsv9KLjD8CjMq/images/docs/cloud/networking/create-and-manage-a-subnetwork/networks-page.png?fit=max&auto=format&n=O2fvsv9KLjD8CjMq&q=85&s=446faf0f27f7526b8443efa37f0a9daf" alt="Networks page open in the Customer Portal" width="5388" height="1988" data-path="images/docs/cloud/networking/create-and-manage-a-subnetwork/networks-page.png" />
    </Frame>

    2. Find the network where you want to rename a subnetwork. Click the network's name to open it.
    3. Click the three-dot icon next to the subnetwork you want to rename, then click **Edit**.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/O2fvsv9KLjD8CjMq/images/docs/cloud/networking/create-and-manage-a-subnetwork/rename-subnetwork.png?fit=max&auto=format&n=O2fvsv9KLjD8CjMq&q=85&s=bfc7ed7ed510eba4db95b77ac2e48c60" alt="Network settings with the highlighted edit button" width="4184" height="1448" data-path="images/docs/cloud/networking/create-and-manage-a-subnetwork/rename-subnetwork.png" />
    </Frame>

    4. Update the subnetwork's name.
    5. Click **Edit subnetwork** to save the changes.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/O2fvsv9KLjD8CjMq/images/docs/cloud/networking/create-and-manage-a-subnetwork/edit-subnetwork-menu.png?fit=max&auto=format&n=O2fvsv9KLjD8CjMq&q=85&s=73baf98f7fc96a94d24a819a6cb2e322" alt="Subnetwork settings" width="2164" height="2404" data-path="images/docs/cloud/networking/create-and-manage-a-subnetwork/edit-subnetwork-menu.png" />
    </Frame>

    The subnetwork has been renamed.

    ### Delete a subnetwork

    You can delete a subnetwork that's not attached to a VM.

    To delete a subnetwork:

    1. In the Gcore Customer Portal, navigate to **Cloud** > **Networking**.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/O2fvsv9KLjD8CjMq/images/docs/cloud/networking/create-and-manage-a-subnetwork/networks-page.png?fit=max&auto=format&n=O2fvsv9KLjD8CjMq&q=85&s=446faf0f27f7526b8443efa37f0a9daf" alt="Networks page open in the Customer Portal" width="5388" height="1988" data-path="images/docs/cloud/networking/create-and-manage-a-subnetwork/networks-page.png" />
    </Frame>

    2. Find the network where you want to delete a subnetwork. Click the network's name to open it.
    3. Click the three-dot icon next to the subnetwork you want to remove, then click **Delete**.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/O2fvsv9KLjD8CjMq/images/docs/cloud/networking/create-and-manage-a-subnetwork/delete-subnetwork.png?fit=max&auto=format&n=O2fvsv9KLjD8CjMq&q=85&s=4baea82bbf56234298712d87117e0152" alt="Network settings with the highlighted delete button" width="4184" height="1448" data-path="images/docs/cloud/networking/create-and-manage-a-subnetwork/delete-subnetwork.png" />
    </Frame>

    4. Confirm your action by clicking **Delete** again.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/O2fvsv9KLjD8CjMq/images/docs/cloud/networking/create-and-manage-a-subnetwork/confirm-subnetwork-deletion.png?fit=max&auto=format&n=O2fvsv9KLjD8CjMq&q=85&s=db7243c9089866fca65e8744dec347b9" alt="Delete subnetwork confirmation dialog" width="2152" height="724" data-path="images/docs/cloud/networking/create-and-manage-a-subnetwork/confirm-subnetwork-deletion.png" />
    </Frame>

    The subnetwork has been successfully removed.
  </MethodSection>

  <MethodSection id="api" label="REST API">
    Create a subnet inside an existing network and customize its DHCP and DNS settings to match your connectivity requirements.

    <Info>
      A permanent [API token](/account-settings/api-tokens) is required, along with a [project ID](https://api.gcore.com/docs/cloud#tag/Projects/operation/ProjectsListV1.get) and [region ID](https://api.gcore.com/docs/cloud#tag/Regions/operation/RegionListV1.get).
    </Info>

    Set these variables before running the examples:

    ```bash theme={null}
    export GCORE_API_KEY="{YOUR_API_KEY}"
    export GCORE_CLOUD_PROJECT_ID="{YOUR_PROJECT_ID}"
    export GCORE_CLOUD_REGION_ID="{YOUR_REGION_ID}"
    export NETWORK_ID="{YOUR_NETWORK_ID}"
    ```

    <Info>
      **NETWORK\_ID** is the UUID of the network in which to create the subnetwork. To create a network or find its ID, see [Create and manage a network](/cloud/networking/create-and-manage-a-network).
    </Info>

    ## Quickstart

    The scripts below create a subnet in an existing network, rename it with a custom DNS server, then delete it.

    <Tabs>
      <Tab title="Python SDK">
        ```python theme={null}
        import os
        from gcore import Gcore

        client = Gcore()

        # Step 1. Create a subnet.
        task = client.cloud.networks.subnets.create(
            cidr="192.168.10.0/24",
            name="my-subnet",
            network_id=os.environ["NETWORK_ID"],
            enable_dhcp=True,
        )
        subnet_id = client.cloud.tasks.poll(task.tasks[0]).created_resources.subnets[0]
        print(f"Subnet ID: {subnet_id}")

        # Step 2. Get the subnet.
        subnet = client.cloud.networks.subnets.get(subnet_id)
        print(f"CIDR: {subnet.cidr}  gateway: {subnet.gateway_ip}")

        # Step 3. Update the subnet.
        subnet = client.cloud.networks.subnets.update(
            subnet_id,
            name="my-subnet-updated",
            dns_nameservers=["8.8.8.8", "1.1.1.1"],
        )
        print(f"Updated name: {subnet.name}")

        # Step 4. Delete the subnet.
        task = client.cloud.networks.subnets.delete(subnet_id)
        client.cloud.tasks.poll(task.tasks[0])
        print(f"Deleted subnet {subnet_id}")
        ```
      </Tab>

      <Tab title="Go SDK">
        ```go theme={null}
        package main

        import (
            "context"
            "fmt"
            "log"
            "os"

            gcore "github.com/G-Core/gcore-go"
            "github.com/G-Core/gcore-go/cloud"
        )

        func main() {
            client := gcore.NewClient()
            ctx := context.Background()

            // Step 1. Create a subnet.
            subnet, err := client.Cloud.NetworkSubnets.NewAndPoll(ctx, cloud.NetworkSubnetNewParams{
                Cidr:       "192.168.10.0/24",
                Name:       "my-subnet",
                NetworkID:  os.Getenv("NETWORK_ID"),
                EnableDhcp: gcore.Bool(true),
            })
            if err != nil {
                log.Fatalf("create subnet: %v", err)
            }
            fmt.Printf("Subnet ID: %s  CIDR: %s\n", subnet.ID, subnet.Cidr)

            // Step 2. Get the subnet.
            subnet, err = client.Cloud.NetworkSubnets.Get(ctx, subnet.ID, cloud.NetworkSubnetGetParams{})
            if err != nil {
                log.Fatalf("get subnet: %v", err)
            }
            fmt.Printf("CIDR: %s  gateway: %s\n", subnet.Cidr, subnet.GatewayIP)

            // Step 3. Update the subnet.
            subnet, err = client.Cloud.NetworkSubnets.Update(ctx, subnet.ID, cloud.NetworkSubnetUpdateParams{
                Name:           gcore.String("my-subnet-updated"),
                DNSNameservers: []string{"8.8.8.8", "1.1.1.1"},
            })
            if err != nil {
                log.Fatalf("update subnet: %v", err)
            }
            fmt.Printf("Updated name: %s\n", subnet.Name)

            // Step 4. Delete the subnet.
            if err = client.Cloud.NetworkSubnets.DeleteAndPoll(ctx, subnet.ID, cloud.NetworkSubnetDeleteParams{}); err != nil {
                log.Fatalf("delete subnet: %v", err)
            }
            fmt.Println("Subnet deleted.")
        }
        ```
      </Tab>
    </Tabs>

    ## Step-by-step

    <p>Each step below explains what the call does, which parameters matter, and what the response looks like. Use this section to understand the flow or to debug a specific step.</p>

    <Accordion title="Show all steps">
      ### Step 1. Create a subnet

      Provisions a new subnet inside an existing network; the backend assigns a gateway IP automatically unless one is specified.

      | Parameter                   | Required | Description                                                                                                                                                                                                       |
      | --------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
      | `cidr`                      | Yes      | IP range in CIDR notation, e.g. `192.168.10.0/24`. Must fall within `10.0.0.0/8`, `172.16.0.0/12`, or `192.168.0.0/16` for IPv4, or `fc00::/7` for IPv6. Must not overlap with other subnets in the same network. |
      | `name`                      | Yes      | Name for the subnet.                                                                                                                                                                                              |
      | `network_id`                | Yes      | ID of the network to attach this subnet to.                                                                                                                                                                       |
      | `enable_dhcp`               | No       | Set to `true` to have DHCP assign IP addresses to VMs automatically. For IPv6 subnets this cannot be changed after creation.                                                                                      |
      | `connect_to_network_router` | No       | Set to `false` to make the subnet non-routable (no internet access). Omit to use the network's default routing.                                                                                                   |
      | `dns_nameservers`           | No       | List of DNS server IPs to advertise via DHCP.                                                                                                                                                                     |

      <Tabs>
        <Tab title="Python SDK">
          ```python theme={null}
          task = client.cloud.networks.subnets.create(
              cidr="192.168.10.0/24",
              name="my-subnet",
              network_id=os.environ["NETWORK_ID"],
              enable_dhcp=True,
          )
          subnet_id = client.cloud.tasks.poll(task.tasks[0]).created_resources.subnets[0]
          print(f"Subnet ID: {subnet_id}")
          ```
        </Tab>

        <Tab title="Go SDK">
          ```go theme={null}
          subnet, err := client.Cloud.NetworkSubnets.NewAndPoll(ctx, cloud.NetworkSubnetNewParams{
              Cidr:       "192.168.10.0/24",
              Name:       "my-subnet",
              NetworkID:  os.Getenv("NETWORK_ID"),
              EnableDhcp: gcore.Bool(true),
          })
          if err != nil {
              log.Fatalf("create subnet: %v", err)
          }
          fmt.Printf("Subnet ID: %s\n", subnet.ID)
          ```
        </Tab>

        <Tab title="curl">
          ```bash theme={null}
          curl -X POST "https://api.gcore.com/cloud/v1/subnets/${GCORE_CLOUD_PROJECT_ID}/${GCORE_CLOUD_REGION_ID}" \
            -H "Authorization: APIKey ${GCORE_API_KEY}" \
            -H "Content-Type: application/json" \
            -d '{
              "cidr": "192.168.10.0/24",
              "name": "my-subnet",
              "network_id": "'${NETWORK_ID}'",
              "enable_dhcp": true
            }'
          ```

          Response:

          ```json theme={null}
          {
            "tasks": ["0e7e5e2c-a2b5-4a20-a118-face59aa1e27"]
          }
          ```

          Poll `GET /cloud/v1/tasks/{task_id}` every 5 seconds until `state` is `FINISHED`. The subnet ID is in `created_resources.subnets[0]`.

          ```json theme={null}
          {
            "state": "FINISHED",
            "created_resources": {
              "subnets": ["3f80fb47-4cda-43bd-95f9-18b316f7546e"]
            }
          }
          ```
        </Tab>
      </Tabs>

      ### Step 2. Get subnet details

      Retrieves the current configuration of the subnet; useful to confirm the assigned gateway IP and DHCP settings after creation.

      <Tabs>
        <Tab title="Python SDK">
          ```python theme={null}
          subnet = client.cloud.networks.subnets.get(subnet_id)
          print(f"CIDR: {subnet.cidr}  gateway: {subnet.gateway_ip}")
          ```
        </Tab>

        <Tab title="Go SDK">
          ```go theme={null}
          subnet, err = client.Cloud.NetworkSubnets.Get(ctx, subnet.ID, cloud.NetworkSubnetGetParams{})
          if err != nil {
              log.Fatalf("get subnet: %v", err)
          }
          fmt.Printf("CIDR: %s  gateway: %s\n", subnet.Cidr, subnet.GatewayIP)
          ```
        </Tab>

        <Tab title="curl">
          ```bash theme={null}
          curl -X GET "https://api.gcore.com/cloud/v1/subnets/${GCORE_CLOUD_PROJECT_ID}/${GCORE_CLOUD_REGION_ID}/${SUBNET_ID}" \
            -H "Authorization: APIKey ${GCORE_API_KEY}"
          ```

          Response:

          ```json theme={null}
          {
            "id": "3f80fb47-4cda-43bd-95f9-18b316f7546e",
            "name": "my-subnet",
            "cidr": "192.168.10.0/24",
            "network_id": "6880a081-5f09-4437-9942-3eabee038666",
            "enable_dhcp": true,
            "ip_version": 4,
            "gateway_ip": "192.168.10.1",
            "dns_nameservers": ["8.8.8.8"],
            "host_routes": []
          }
          ```
        </Tab>
      </Tabs>

      ### Step 3. Update a subnet

      Updates subnet settings in place; the response returns the full updated subnet object. Only fields included in the request body are changed.

      | Parameter         | Description                                                                           |
      | ----------------- | ------------------------------------------------------------------------------------- |
      | `name`            | New name for the subnet.                                                              |
      | `enable_dhcp`     | Enable or disable DHCP. For IPv6 subnets this field is read-only after creation.      |
      | `dns_nameservers` | Replace the list of DNS server IPs. Pass an empty array to clear.                     |
      | `gateway_ip`      | Override the gateway IP. Set to `null` to remove the gateway advertisement from DHCP. |

      <Tabs>
        <Tab title="Python SDK">
          ```python theme={null}
          subnet = client.cloud.networks.subnets.update(
              subnet_id,
              name="my-subnet-updated",
              dns_nameservers=["8.8.8.8", "1.1.1.1"],
          )
          print(f"Updated name: {subnet.name}")
          ```
        </Tab>

        <Tab title="Go SDK">
          ```go theme={null}
          subnet, err = client.Cloud.NetworkSubnets.Update(ctx, subnet.ID, cloud.NetworkSubnetUpdateParams{
              Name:           gcore.String("my-subnet-updated"),
              DNSNameservers: []string{"8.8.8.8", "1.1.1.1"},
          })
          if err != nil {
              log.Fatalf("update subnet: %v", err)
          }
          fmt.Printf("Updated name: %s\n", subnet.Name)
          ```
        </Tab>

        <Tab title="curl">
          ```bash theme={null}
          curl -X PATCH "https://api.gcore.com/cloud/v1/subnets/${GCORE_CLOUD_PROJECT_ID}/${GCORE_CLOUD_REGION_ID}/${SUBNET_ID}" \
            -H "Authorization: APIKey ${GCORE_API_KEY}" \
            -H "Content-Type: application/json" \
            -d '{
              "name": "my-subnet-updated",
              "dns_nameservers": ["8.8.8.8", "1.1.1.1"]
            }'
          ```

          Response:

          ```json theme={null}
          {
            "id": "3f80fb47-4cda-43bd-95f9-18b316f7546e",
            "name": "my-subnet-updated",
            "cidr": "192.168.10.0/24",
            "enable_dhcp": true,
            "dns_nameservers": ["8.8.8.8", "1.1.1.1"]
          }
          ```
        </Tab>
      </Tabs>
    </Accordion>

    ## Clean up

    Delete a subnet that is not attached to any Virtual Machine. The delete operation is asynchronous — poll the task until it reaches `FINISHED`.

    <Tabs>
      <Tab title="Python SDK">
        ```python theme={null}
        task = client.cloud.networks.subnets.delete(subnet_id)
        client.cloud.tasks.poll(task.tasks[0])
        print(f"Deleted subnet {subnet_id}")
        ```
      </Tab>

      <Tab title="Go SDK">
        ```go theme={null}
        if err = client.Cloud.NetworkSubnets.DeleteAndPoll(ctx, subnet.ID, cloud.NetworkSubnetDeleteParams{}); err != nil {
            log.Fatalf("delete subnet: %v", err)
        }
        fmt.Println("Subnet deleted.")
        ```
      </Tab>

      <Tab title="curl">
        ```bash theme={null}
        curl -X DELETE "https://api.gcore.com/cloud/v1/subnets/${GCORE_CLOUD_PROJECT_ID}/${GCORE_CLOUD_REGION_ID}/${SUBNET_ID}" \
          -H "Authorization: APIKey ${GCORE_API_KEY}"
        ```

        Response:

        ```json theme={null}
        {
          "tasks": ["23096938-53a5-4d06-8f44-bcf7741e2414"]
        }
        ```
      </Tab>
    </Tabs>
  </MethodSection>
</MethodSwitch>
