Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Virtual Private Cloud
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Cloud network
      • Creating a cloud network
      • Deleting a cloud network
      • Updating a cloud network
    • Subnet
      • Creating a subnet
      • Deleting a subnet
      • Updating a subnet
    • IP address
      • Reserving a static public IP address
      • Making a dynamic public IP address static
      • Making a static public IP address dynamic
      • Deleting a static public IP address
    • Static routes
      • Creating a static route
      • Enabling NAT to the internet
    • Security groups
      • Create a security group
      • Update a security group and rules
      • Delete a security group
    • DDoS Protection
      • Enable protection from DDoS attacks
  • Use cases
    • Architecture and protection of a basic internet service
  • Concepts
    • Relationship between service resources
    • Cloud networks and subnets
    • Cloud resource addresses
    • Static routes
    • Security groups
    • MTU and MSS
    • DHCP settings
    • Quotas and limits
  • DDoS Protection
  • Cloud Interconnect
  • Access management
  • Pricing policy
    • Current policy
    • Archive
      • Policy before January 1, 2019
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • AddressService
      • NetworkService
      • RouteTableService
      • SecurityGroupService
      • SubnetService
      • OperationService
    • REST
      • Overview
      • Address
        • Overview
        • create
        • delete
        • get
        • getByValue
        • list
        • listOperations
        • update
      • Network
        • Overview
        • create
        • delete
        • get
        • list
        • listOperations
        • listSubnets
        • move
        • update
      • RouteTable
        • Overview
        • create
        • delete
        • get
        • list
        • listOperations
        • move
        • update
      • SecurityGroup
        • Overview
      • Subnet
        • Overview
        • create
        • delete
        • get
        • list
        • listOperations
        • move
        • update
      • Operation
        • Overview
        • get
  • Questions and answers
  1. Step-by-step instructions
  2. Subnet
  3. Creating a subnet

Creating a subnet

  • Examples

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

Management console
CLI

To create a subnet:

  1. Open the Virtual Private Cloud section in the folder where you want to create the subnet.

  2. Click on the name of the cloud network.

  3. Click Add subnet.

  4. Fill in the form: enter the subnet name and select the availability zone from the drop-down list.

    • The name must be unique within the folder.
    • The name may contain lowercase Latin letters, numbers, and hyphens.
    • The first character must be a letter. The last character can't be a hyphen.
    • The maximum length of the name is 63 characters.
  5. Enter the subnet CIDR: the IP address and mask. For more information about subnet IP address ranges, see the section Cloud networks and subnets.

  6. (optional) Specify DHCP settings. To do this:

    1. Set the Domain name to be added to the names of the VMs connected to the subnet.

    2. In the DNS servers field, click Add DNS server and enter the address of your DNS server. You can specify multiple DNS servers.

    3. In the NTP servers field, click Add NTP server and specify the address of your NTP server. You can specify multiple NTP servers.

      Note

      NTP settings do not apply to Windows VMs. For more information, see NTP settings in Windows.

  7. Click Create subnet.

If you don't have the Yandex.Cloud command line interface yet, install and initialize it.

The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name or --folder-id parameter.

To create a subnet:

  1. See 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 b1g6ci08ma55klukmdjs
    +----------------------+----------------+
    |          ID          |      NAME      |
    +----------------------+----------------+
    | enpavfmgapumnl7cqin8 | test-network-1 |
    | enplom7a98s1t0lhass8 | default        |
    +----------------------+----------------+
    
  3. Select the NAME or ID of the cloud network you need. Create a subnet in the default folder by specifying the cloud network ID via the --network-id flag:

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

    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. The --zone flag indicates the availability zone where the subnet will be created. If this flag is omitted, the subnet is created in the default availability zone.

    • The name must be unique within the folder.
    • The name may contain lowercase Latin letters, numbers, and hyphens.
    • The first character must be a letter. The last character can't be a hyphen.
    • The maximum length of the name is 63 characters.
    yc vpc subnet create --name test-subnet-1 \
    --description "My test subnet" \
    --network-name test-network-1 \
    --zone ru-central1-b \
    --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
    +----------------------+-----------------------+------------------------+
    |          ID          |         NAME          | ... |       RANGE      |
    +----------------------+-----------------------+------------------------+
    ...
    | e2l0psbfoloefpjb1rau | test-subnet-1         | ... | [192.168.0.0/24] |
    ...
    +----------------------+-----------------------+-----+------------------+
    

    Get the same list with more details in YAML format:

    yc vpc subnet list --format yaml
     
    ...
     
    - id: e2l0psbfoloefpjb1rau
      folder_id: b1g6ci08ma55klukmdjs
      created_at: "2018-10-24T12:25:58Z"
      name: test-subnet-1
      description: My test subnet
      network_id: enplom7a98s1t0lhass8
      zone_id: ru-central1-b
      v4_cidr_blocks:
      - 192.168.0.0/24
     
    ...
    

Examples

CLI

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 b1g6ci08ma55klukmdjs \
--network-id enplom7a98s1t0lhass8 \
--zone ru-central1-b \
--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 b1g6ci08ma55klukmdjs \
--network-id enplom7a98s1t0lhass8 \
--zone ru-central1-b \
--range 192.168.0.0/24 \
--domain-name test.domain \
--domain-name-server 192.168.0.100 \
--ntp-server 192.168.0.101
Language
Careers
Privacy policy
Terms of use
© 2021 Yandex.Cloud LLC