[Yandex Cloud documentation](../../index.md) > [Yandex BareMetal](../index.md) > [Concepts](index.md) > Network > Public network

# Public network {#public-network}

A _public network_ is an internet-facing network providing physical connectivity for all servers. On [some](network-restrictions.md#blocked-ports) TCP and UDP ports, network traffic between the private network and the internet is limited. Some BareMetal server [configurations](server-configurations.md) support reserving [MC-LAG](mc-lag.md) public network channels.

When working with a public network and internet access, make sure to comply with the [terms of use](https://yandex.com/legal/cloud_termsofuse/en/).

## Ephemeral public subnet {#ephemeral-public-subnet}

An _ephemeral public subnet_ is a public subnet of the `/31` size that is randomly assigned to a BareMetal server from the range of public IPv4 addresses reserved for Yandex BareMetal.

Ephemeral public subnets are assigned to servers with **Public address** set to `From ephemeral subnet` in their network parameters.

When leasing a BareMetal server, you can enable the [DHCP server](dhcp.md#dhcp-ephemeral-public-subnet) in an ephemeral public subnet. To do this, enable **Assign via DHCP**. Otherwise, the DHCP server in this subnet will be disabled. You will not be able to reconfigure the DHCP server in such a subnet later.

If DHCP is disabled in an ephemeral public subnet or on the server's [network interface](servers.md#network-interfaces) connected to such a subnet, and obtaining an address via DHCP is disabled, consider the following when configuring that interface:

* The subnet the server's public IP address is in has a subnet prefix length of `31` bits and consists of these two addresses: the default gateway IP address and the host IP address.
* The gateway IP address is specified under **Default gateway** in the **Network interfaces** section on the server information page.
* The host IP address is greater than the gateway IP address by one.

Here is an example:

* Subnet CIDR: `198.51.100.110/31`.
* Default gateway IP address: `198.51.100.110`.
* Server public IP address: `198.51.100.111`.

You can [convert](../operations/reserve-public-subnet.md#transform-ephemeral-to-dedicated) an ephemeral public subnet to a [dedicated public subnet](#public-subnet) of size `/31`; this dedicated public subnet of size `/31` will be resolving the default gateway's IP address and the server's public address in the same way as the ephemeral subnet.

The lifecycle of an ephemeral public subnet depends on the lifecycle of the server this subnet is assigned to. When a server lease is cancelled, the ephemeral public subnet assigned to it will be automatically deleted and the server’s public IPv4 address will be released back to the BareMetal address pool.

If the ephemeral public subnet has not been assigned to any server within one month of its creation, such a subnet will also be automatically deleted and its public IPv4 address will return to BareMetal's address pool.

## Dedicated public subnet {#public-subnet}

A _dedicated public subnet_ is a public subnet made up of an IP address range that will be available to your servers in the selected [pools](servers.md#server-pools). The IP address range is assigned to the dedicated public subnet automatically.

A dedicated public subnet may contain servers located in different server pools at the same time. Moreover, case such servers retain [OSI](https://en.wikipedia.org/wiki/OSI_model) L2 network connectivity between them in the public subnet.

You can [order](../operations/reserve-public-subnet.md) a dedicated public subnet in the following sizes:

| Subnet size | Total number of IP addresses | Available IP addresses |
| --- | --- | --- |
| `/31`^1^ | 2 | 1 |
| `/29` | 8 | 5 |
| `/28` | 16 | 13 |
| `/27`^2^ | 32 | 29 |
| `/26`^2^ | 64 | 61 |
| `/25`^2^ | 128 | 125 |
| `/24`^2^ | 256 | 253 |

^1^ You can order a public subnet of size `/31` only by [converting](../operations/reserve-public-subnet.md#transform-ephemeral-to-dedicated) an [ephemeral public subnet](#ephemeral-public-subnet).
^2^ To order public subnets with sizes `/27`, `/26`, `/25`, and `/24`, [contact](https://center.yandex.cloud/support/tickets/create) support.

When you cancel the rent of a server which has a dedicated public subnet assigned to it, its public IPv4 address is released back to the dedicated public subnet’s address pool so you can later use it for another server.

In Yandex BareMetal, dedicated public subnets are [billable](../pricing.md). The minimum rent period for a dedicated public subnet is one month, so you cannot delete such a subnet during the first month after the order date.

{% note info %}

The default gateway in a dedicated public subnet remains inactive (does not respond to `ping` requests) until at least one server is connected to that public subnet.

{% endnote %}

## IP address distribution in public subnets {#address-distribution}

The dedicated public subnet [does not have](dhcp.md#dhcp-public-subnet) a DHCP server; therefore, on the network interface of the server connected to such subnet, you should manually configure a static IP address from the subnet’s range of available public IP addresses and specify the default gateway address.

The information about the range of IP addresses available in a public subnet and default gateway is provided in the **Network interfaces** section on the server information page and on the public subnet information page.

Within a dedicated public subnet range, IP addresses are distributed as follows:

{% list tabs %}

- Subnets of size `/31`

  * First IP address in the range is the default gateway address.
  * Second IP address in the range is the address available for assignment to the network interface.

  Here is an example:
  
  * Subnet CIDR: `198.51.100.110/31`.
  * Default gateway IP address: `198.51.100.110`.
  * Server public IP address: `198.51.100.111`.

- Subnets of size `/29` or more

  * First IP address in the range is the subnet address.
  * Second IP address in the range is the default gateway address.
  * Third to second-last addresses in the range are addresses available for assignment to network interfaces.
  * Last IP address in the range is the [broadcast](https://en.wikipedia.org/wiki/Broadcast_address) (`broadcast`) address.

  For example:

  * Subnet CIDR: `198.51.100.104/29`.
  * Network IP address: `198.51.100.104`.
  * Default gateway IP address: `198.51.100.105`.
  * Available addresses: From `198.51.100.106` to `198.51.100.110`.
  * Broadcast address: `198.51.100.111`.

{% endlist %}

#### See also {#see-also}

* [Network](network.md)
* [Private network](private-network.md)
* [DHCP in a Yandex BareMetal network](dhcp.md)
* [Reserving a BareMetal network connection using MC-LAG](mc-lag.md)
* [Ordering a dedicated public subnet](../operations/reserve-public-subnet.md)
* [Setting up a secondary private subnet with a tagged VLAN on a server](../operations/servers/set-up-tagged-vlan.md)
* [Switching the type of a network connected to a network interface](../operations/servers/switch-network-type.md)