Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Virtual Private Cloud
  • Getting started
    • All guides
      • Creating a subnet
      • Deleting a subnet
      • Updating a subnet
      • Getting information about a subnet
      • Moving a subnet between folders
      • Moving a subnet to a different availability zone
      • Viewing a list of used addresses
    • Enabling a software-accelerated network
    • Chart of network connections
    • Viewing operations with resources
  • DDoS Protection
  • Access management
  • Terraform reference
  • Audit Trails events
  • Release notes
  • FAQ
  1. Step-by-step guides
  2. Subnet
  3. Creating a subnet

Creating a subnet

Written by
Yandex Cloud
Improved by
Danila N.
Updated at May 13, 2025

Subnets are created in cloud networks. A new subnet is located in one of the availability zones. You can connect resources to a subnet if they reside in the same availability zone as the subnet itself.

Management console
CLI
Terraform
API
  1. In the management console, go to the folder where you need to create a subnet.

  2. In the list of services, select Virtual Private Cloud.

  3. In the left-hand panel, select Subnets.

  4. At the top right, click Create.

  5. In the Name field, specify the subnet name. The naming requirements are as follows:

    • It must be from 2 to 63 characters long.
    • It may contain lowercase Latin letters, numbers, and hyphens.
    • It must start with a letter and cannot end with a hyphen.
  6. (Optional) In the Description field, add a description.

  7. In the Zone field, select an availability zone from the drop-down list.

  8. In the Network field, specify a cloud network. Make sure to create it in advance.

  9. In the CIDR field, enter the subnet IP address and mask.
    For more information about subnet IP address ranges, see Cloud networks and subnets.
    If you need to enter more CIDRs, click Add.

  10. (Optional) Set DHCP settings. For this, follow these steps:

    1. In the Domain name field, specify a DNS domain to search for unqualified names.
    2. In the Domain name servers field, click Add and enter the address of your DNS server. You can specify multiple DNS servers.
    3. In the NTP servers field, click Add and enter the address of your NTP server. You can specify multiple NTP servers.
  11. Click Create subnet.

If you do not have the Yandex Cloud (CLI) command line interface yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To create a subnet:

  1. View the description of the CLI command for creating a subnet:

    yc vpc subnet create --help
    
  2. Get a list of cloud networks in the required folder:

    yc vpc network list --folder-id b1g6ci08ma55********
    

    Result:

    +----------------------+----------------+
    |          ID          |      NAME      |
    +----------------------+----------------+
    | enpavfmgapum******** | test-network-1 |
    | enplom7a98s1******** | default        |
    +----------------------+----------------+
    
  3. Select NAME or ID of the cloud network you need. Create a subnet in the default folder:

    yc vpc subnet create \
      --name test-subnet-1 \
      --description "My test subnet" \
      --network-id enplom7a98s1******** \
      --zone ru-central1-a \
      --range 192.168.0.0/24
    

    Where:

    • --network-id: Cloud network ID. You can also select a cloud network by specifying its name via the --network-name flag. Specify the name of the cloud network to create the subnet in and the CIDR.
    • --zone: Availability zone to create the subnet in. If this flag is not set, the subnet is created in the default availability zone.
    • --range: List of internal IPv4 addresses specified for this subnet, such as 10.0.0.0/22 or 192.168.0.0/16. Make sure the addresses are unique within the network. The minimum subnet size is /28, and the maximum subnet size is /16. Only IPv4 is supported.

    The subnet naming requirements are as follows:

    • It must be from 2 to 63 characters long.
    • It may contain lowercase Latin letters, numbers, and hyphens.
    • It must start with a letter and cannot end with a hyphen.
    yc vpc subnet create \
      --name test-subnet-1 \
      --description "My test subnet" \
      --network-name test-network-1 \
      --zone ru-central1-a \
      --range 192.168.0.0/24
    

    The --name and --description flags are optional: you can create a subnet without any name or description and access it by ID.

  4. Get a list of all subnets in the default folder:

    yc vpc subnet list
    

    Result:

    +----------------------+-----------------------+------------------------+
    |          ID          |         NAME          | ... |       RANGE      |
    +----------------------+-----------------------+------------------------+
    ...
    | e2l0psbfoloe******** | test-subnet-1         | ... | [192.168.0.0/24] |
    ...
    +----------------------+-----------------------+-----+------------------+
    

    Get the same list with more details in YAML format:

    yc vpc subnet list --format yaml
    

    Result:

    ...
    
    - id: e2l0psbfoloe********
      folder_id: b1g6ci08ma55********
      created_at: "2018-10-24T12:25:58Z"
      name: test-subnet-1
      description: My test subnet
      network_id: enplom7a98s1********
      zone_id: ru-central1-a
      v4_cidr_blocks:
      - 192.168.0.0/24
    
    ...
    

With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.

Terraform is distributed under the Business Source License. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the documentation on the Terraform website or mirror website.

If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

  1. In the configuration file, describe the subnet parameters:

    • name: Subnet name. The naming requirements are as follows:

      • It must be from 2 to 63 characters long.
      • It may contain lowercase Latin letters, numbers, and hyphens.
      • It must start with a letter and cannot end with a hyphen.
    • description: Subnet description.

    • v4_cidr_blocks: List of IPv4 addresses the traffic will come to or from, such as 10.0.0.0/22 or 192.168.0.0/16. Make sure the addresses are unique within the network. The minimum subnet size is /28, and the maximum subnet size is /16. Only IPv4 is supported.

    • zone: Availability zone.

    • network_id: ID of the network you are creating the subnet in.

    Here is an example of the configuration file structure:

    resource "yandex_vpc_subnet" "lab-subnet-a" {
      name           = "<subnet_name>"
      description    = "<subnet_description>"
      v4_cidr_blocks = ["<IPv4_address>"]
      zone           = "<availability_zone>"
      network_id     = "<network_ID>"
    }
    

    To add, update, or delete a subnet, use the yandex_vpc_subnet resource indicating the network in the network_id field (see this example).

    For more information about the yandex_vpc_subnet resource parameters in Terraform, see the relevant provider documentation.

  2. Make sure the configuration files are correct.

    1. In the command line, go to the directory where you created the configuration file.

    2. Run a check using this command:

      terraform plan
      

    If the configuration description is correct, the terminal will display a list of the resources being created and their parameters. If the configuration contains any errors, Terraform will point them out.

  3. Deploy the cloud resources.

    1. If the configuration does not contain any errors, run this command:

      terraform apply
      
    2. Confirm creating the resources: type yes in the terminal and press Enter.

      This will create all the resources you need in the specified folder. You can check the new resources and their settings using the management console or these CLI commands:

      yc vpc subnet list
      

To create a subnet, use the create REST API method for the Subnet resource or the SubnetService/Create gRPC API call, and provide the following in the request:

  • ID of the folder the subnet will reside in, in the folderId parameter.
  • ID of the network the subnet will be placed in, in the networkId parameter.
  • ID of the availability zone the subnet will be placed in, in the zoneId parameter.
  • List of internal IPv4 addresses specified for this subnet, in the v4CidrBlocks[] array, such as 10.0.0.0/22 or 192.168.0.0/16. Make sure the addresses are unique within the network. The minimum subnet size is /28, and the maximum subnet size is /16. Only IPv4 is supported.

To get the subnet ID, use the list REST API method for the Subnet resource or the SubnetService/List gRPC API call and provide the folder ID in the folderId request parameter.

To learn how to find out the folder ID, see Getting the folder ID.

ExamplesExamples

CLI
Terraform

Create a subnet with a name and description in the selected folder:

yc vpc subnet create \
  --name test-subnet-1 \
  --description "My test subnet" \
  --folder-id b1g6ci08ma55******** \
  --network-id enplom7a98s1******** \
  --zone ru-central1-a \
  --range 192.168.0.0/24

Create a subnet with DHCP settings:

yc vpc subnet create \
  --name test-subnet-1 \
  --description "My test subnet" \
  --folder-id b1g6ci08ma55******** \
  --network-id enplom7a98s1******** \
  --zone ru-central1-a \
  --range 192.168.0.0/24 \
  --domain-name test.domain \
  --domain-name-server 192.168.0.100 \
  --ntp-server 192.168.0.101
  1. Describe the parameters of the yandex_vpc_subnet resource in the configuration file:

    resource "yandex_vpc_network" "lab-net" {
      name        = "network-1"
      description = "My first network"
    }
    
    resource "yandex_vpc_subnet" "lab-subnet-a" {
      name           = "subnet-1"
      description    = "My first subnet"
      v4_cidr_blocks = ["10.2.0.0/16"]
      zone           = "ru-central1-a"
      network_id     = "${yandex_vpc_network.lab-net.id}"
    }
    

    For more information about resource parameters in Terraform, see the relevant provider documentation.

  2. Make sure the configuration files are correct.

    1. In the command line, go to the directory where you created the configuration file.

    2. Run a check using this command:

      terraform plan
      

    If the configuration description is correct, the terminal will display a list of the resources being created and their parameters. If the configuration contains any errors, Terraform will point them out.

  3. Deploy the cloud resources.

    1. If the configuration does not contain any errors, run this command:

      terraform apply
      
    2. Confirm creating the resources: type yes in the terminal and press Enter.

      This will create all the resources you need in the specified folder. You can check the new resources and their settings using the management console or these CLI commands:

      yc vpc subnet list
      

Was the article helpful?

Previous
Moving a cloud network between folders
Next
Deleting a subnet
© 2025 Direct Cursus Technology L.L.C.