---
title: "Public subnets"
sidebar_label: "Public subnets"
sidebar_position: 10
description: "How to create a public subnet, configure access to a public subnet in different projects, change DNS servers in a subnet, and other instructions"
---

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import {TabItemLabel} from '@selectel/docux/components'
import MoreVerticalIcon from '@selectel/docux/icons/more-vertical'
import EditIcon from '@selectel/docux/icons/edit'
import CheckIcon from '@selectel/docux/icons/check'
import CopyIcon from '@selectel/docux/icons/copy'
import TrashIcon from '@selectel/docux/icons/trash'
import CreatePublicSubnet from '@site/i18n/en/docusaurus-plugin-content-docs/current/_partials/cloud-servers/cloud-networks/create-public-subnet.mdx'
import Formbricks from '@theme/MDXComponents/Formbricks'

# Public subnets

A public subnet is a range of public static IP addresses limited by a prefix (mask) size. All devices in a public subnet have a public IP address and access to and from the Internet. You can configure access through a public subnet for a cloud server, cloud load balancer, and Managed Database cluster — more information is available in the instruction [Configuring access to and from the Internet](/cloud-servers/cloud-networks/configure-access-to-internet.mdx).

IP addresses from a public subnet are not processed by the [cloud router](/cloud-servers/cloud-networks/cloud-routers.mdx) via 1:1 NAT, but are connected directly to the devices: cloud server, cloud load balancer, or cloud database cluster. Because there is no NAT, this type of internet connection for devices is more fault-tolerant and faster, but less secure than [connecting via a public floating IP address](/cloud-servers/cloud-networks/configure-access-to-internet.mdx#internet-access-via-floating-ip).

Devices in a public subnet communicate with each other through public interfaces.

A public subnet can only be used within a single [project](/access-control/projects/about-projects.mdx) and a single [pool](/infrastructure/locations.mdx#pool).

There are traffic volume limitations within public subnets — throughput. You can view these in the [Throughput](/cloud-servers/cloud-networks/about-networks.mdx#bandwidth) table.

You can work with public subnets in the [control panel](https://my.selectel.ru/vpc/default/networks/) or via [Terraform](/terraform/providers/).

## Public subnet sizes \{#public-subnet-size}

Public subnets are available in sizes from `/29` (five free IPv4 addresses) to `/24` (253 free IPv4 addresses). Each public subnet reserves three service IP addresses:

* first IP address — network address;
* second IP address — gateway address;
* last IP address — broadcast address.

The remaining IP addresses can be assigned to devices.

Example for subnet `192.0.2.0/29` — five addresses are available:

* 192.0.2.0 — network address;
* 192.0.2.1 — gateway address;
* 192.0.2.2 — available for use;
* 192.0.2.3 — available for use;
* 192.0.2.4 — available for use;
* 192.0.2.5 — available for use;
* 192.0.2.6 — available for use;
* 192.0.2.7 — broadcast address.

If a public subnet has run out of free IP addresses, you can [create a new public subnet](#create-public-subnet).

## Automatic public subnet settings \{#default-settings}

Default settings are specified for public subnets: default gateway and DNS servers. The settings are applied to devices in the subnet automatically.

### Default gateway \{#default-gateway}

When creating a public subnet, the second IP address is reserved for the default gateway. The default gateway in a public subnet cannot be changed.

### DNS servers \{#dns-servers}

When a public subnet is created, Selectel DNS servers are automatically assigned to the devices in the subnet. You can change the DNS servers when [creating a subnet](#create-public-subnet) or [change them after creation](#change-dns-servers-on-public-subnet).

### Static routes

By default, no static routes are specified for subnets. For public subnets, you can [configure static routes](/cloud-servers/cloud-networks/static-routes.mdx#configure-static-routing-on-subnet).

## Create a public subnet \{#create-public-subnet}

<CreatePublicSubnet />

## Configure access to a public subnet in different projects \{#configure-access-to-public-subnet}

By default, a public subnet can only be used within one [project](/access-control/projects/about-projects.mdx) and one [pool](/infrastructure/locations.mdx#pool). You can configure shared access to a public subnet across different projects within the same account. The subnet will still only be available within one pool.

The public subnet will have a **Cross-project** tag. You will only be able to manage the subnet in the project where it is located.

<Tabs queryString="configure-access-to-public-subnet">
  <TabItem value="panel" default>
    <TabItemLabel>
      Control panel
    </TabItemLabel>

    1. In the [Control panel](https://my.selectel.ru/vpc/default/networks/), on the top menu, click **Products** and select **Cloud Servers**.
    2. Go to the **Network** section → **Public networks** tab.
    3. Copy the ID of the recipient project with which you want to share the subnet. Open the project menu (name of the current project) and click in the row of the required project.<CopyIcon />
    4. Make sure you are in the project where the subnet is located.
    5. Open the network card → **Projects** tab.
    6. Click **Add project**.
    7. Paste the ID of the destination project that you copied in step 3.
    8. Click .<CheckIcon />
  </TabItem>
</Tabs>

## Change DNS servers in a public subnet \{#change-dns-servers-on-public-subnet}

When creating a public subnet, [Selectel recursive DNS servers](/infrastructure/dns/dns-recursive-servers-list.mdx) are automatically assigned to the devices in the subnet. You can change the DNS servers when [creating a public subnet](#create-public-subnet) or for an existing public subnet.

<Tabs queryString="change-dns-servers-on-public-subnet">
  <TabItem value="panel" default>
    <TabItemLabel>
      Control panel
    </TabItemLabel>

    1. In the [control panel](https://my.selectel.ru/vpc/default/networks/), on the top menu, click **Products** and select **Cloud Servers**.
    2. Go to the **Network** section → **Public networks** tab.
    3. Open the public subnet card → **Subnets** tab.
    4. In the subnet row, in the **DNS servers** column, click .<EditIcon />
    5. Enter from one to three values.
    6. Click .<CheckIcon />
  </TabItem>

  <TabItem value="openstack">
    <TabItemLabel>
      OpenStack CLI
    </TabItemLabel>

    1. [Open OpenStack CLI](/cloud-servers/tools/openstack-cli/).

    2. If you need to completely replace the list of DNS servers, delete the IP addresses of the specified DNS servers and add new ones:

       ```bash
       openstack subnet set \
         --no-dns-nameservers \
         --dns-nameserver <dns_server> \
         <subnet>
       ```

       Specify:

       * `<dns_server>` — IP address of the DNS server. You can add multiple DNS servers — each is added using the `--dns-nameserver <dns_server>` option;;
       * `<subnet>` — ID or name of the public subnet; you can view it using the `openstack subnet list` command.

       Example of changing default DNS servers to `192.0.2.3` and `192.0.2.4`:

       ```bash
       openstack subnet set \
         --no-dns-nameservers \
         --dns-nameserver 192.0.2.3 \
         --dns-nameserver 192.0.2.4 \
         <subnet>
       ```

    3. If you need to add to the list of DNS servers, add the IP addresses of the new DNS servers:

       ```bash
       openstack subnet set \
         --dns-nameserver <dns_server> \
         <subnet>
       ```

       Specify:

       * `<dns_server>` — IP address of the DNS server. You can add multiple DNS servers — each is added using the `--dns-nameserver <dns_server>` option;;
       * `<subnet>` — ID or name of the public subnet; you can view it using the `openstack subnet list` command.
  </TabItem>
</Tabs>

## Delete a public subnet \{#delete-public-subnet}

<Tabs queryString="delete-public-subnet">
  <TabItem value="panel" default>
    <TabItemLabel>
      Control panel
    </TabItemLabel>

    1. In the [control panel](https://my.selectel.ru/vpc/default/networks/), on the top menu, click **Products** and select **Cloud Servers**.

    2. Go to the **Network** section → **Public networks** tab.

    3. Open the subnet card → **Ports** tab.

    4. If there are ports with an inactive  button, prepare them for deletion:<TrashIcon />

       4.1. In the **Connected to** column, see which device the port is connected to.

       4.2. Prepare the port for deletion depending on the device:

       * cloud server — set the server to [status](/cloud-servers/manage/server-statuses.mdx) `ACTIVE`, `PAUSED` or `STOPPED`;
       * any other device — delete the device, and the port will be automatically deleted along with the device.

       4.3. If there are still ports with an inactive  button in the subnet, repeat steps 4.1–4.2 for each of them.<TrashIcon />

    5. Go to the **Network** section → **Public networks** tab.

    6. In the  public subnet menu, select **Delete subnet**.<MoreVerticalIcon />

    7. Enter the subnet address to confirm the deletion.

    8. Click **Delete**.
  </TabItem>
</Tabs>

<Formbricks />
