Manually assigning a public IP address to a BareMetal server
There is no DHCP server in the dedicated public subnet of BareMetal servers. Therefore, on the network interface of the server connected to such a subnet, you should manually set a static public IP address from the subnet address range, plus specify the default gateway address and DNS servers.
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.
Note
The steps described in this guide also apply to the ephemeral public subnet if its DHCP server was off when the server was rented. The ephemeral public subnet is always /31 in size and consists of these two addresses: the first one is the default gateway address, and the second one is the server's public IP address. For more information, see DHCP in an ephemeral public subnet.
For Windows servers, you have to manually assign a public IP address in any ephemeral /31 public subnet, even if its DHCP server is on. This is because the Windows DHCP client cannot issue addresses in /31 subnets.
To learn more about networks in Yandex BareMetal, see Network.
In this guide, you will learn how to manually configure a public IP address on the network interface of a BareMetal server connected to a dedicated public subnet. This example uses servers running Ubuntu 24.04 LTS, AlmaLinux 9, and Windows Server 2022. If using another OS, you will follow the same steps, but the way you configure network interfaces may differ. For network interface configuration steps in other operating systems, refer to the relevant OS guides.
To assign a public IP address to a BareMetal server manually:
- Get your cloud ready.
- Order a dedicated public subnet.
- Rent a BareMetal server.
- Obtain the public subnet parameters.
- Connect to the server via the KVM console.
- Identify the public network interface.
- Assign a static public IP address to the network interface.
- Test network connectivity.
See also How to cancel a server rent.
Getting started
Sign up for Yandex Cloud and create a billing account:
- Navigate to the management console
and log in to Yandex Cloud or create a new account. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVEorTRIAL_ACTIVEstatus. If you do not have a billing account, create one and link a cloud to it.
If you have an active billing account, you can create or select a folder for your infrastructure on the cloud page
Learn more about clouds and folders here.
Required paid resources
The cost of the proposed solution includes:
- Fee for renting a BareMetal server.
- Fee for renting a Yandex BareMetal dedicated public subnet.
For more information, see Yandex BareMetal pricing.
Warning
The minimum rent period for a dedicated public subnet is one month from the order date. You cannot delete such a subnet during the first month after ordering it.
Order a dedicated public subnet
Order a dedicated public subnet of size /29 in the ru-central1-m3 server pool:
- In the management console
, select the folder where you are going to create your infrastructure. - Navigate to BareMetal.
- In the left-hand panel, select
Public addresses and subnets. - At the top right, click Order a public subnet.
- In the Availability zone field, select the availability zone where the subnet will be available.
- In the Pool field, select the
ru-central1-m3server pool. - In the subnet size field, select
/29. - In the Name field, enter the subnet name:
my-public-subnet. - Click Order.
For more information on renting a public subnet, see this section.
Rent a BareMetal server
-
In the management console
, select the folder where you are deploying your infrastructure. -
Navigate to BareMetal.
-
Click Lease server and, in the window that opens, select
Stock configurationsand a suitable BareMetal server configuration in theru-central1-m3server pool.Do it by selecting the
ru-central1-m3server pool in the filter on the right side of the window, under Pool.To select the suitable server configuration, click the section with its name in the central part of the screen.
Tip
You can reduce the cost of renting a server in some configurations by ordering server assembly.
To use the discount, hover over Cheaper with assembly
under the configuration at hand and click Go to assembly in the pop-up window.When ordering a server with assembly, follow the steps below to configure the server properties. In this case, the server will not be available immediately, but only after the assembly is completed (within four calendar days), and at a lower price.
-
In the server configuration window that opens:
-
In the Lease duration field, select the lease period:
1 day,1 month,3 months,6 months, or1 year.When this period expires, server lease will automatically be renewed for the same period. You cannot terminate the lease during the specified lease period, but you can refuse to extend the server lease further.
-
Under Image, select the image of the operating system you will be configuring the network interface in (
Ubuntu 24.04,AlmaLinux 9, orWindows Server 2022). -
Optionally, under Disk, configure disk partitioning:
-
Click Configure disk layout.
-
Specify partition settings. To create a new partition, click
Add partition.To configure RAID arrays and disk partitions by yourself, click Remove RAID.
-
Click Save.
-
-
Under Network interfaces:
- In the Public address field, select
From a dedicated subnet. - In the public subnet selection field that appears, specify the previously created
my-public-subnet.
- In the Public address field, select
-
Under Access:
-
In the Password field, select one of the following options to create a root password:
-
To generate a new root password, select
New passwordand click Generate.Warning
This option requires you to maintain password security. Save the password you generated in a secure location. Yandex Cloud does not store it, and you will not be able to retrieve it once the server is deployed.
-
To use the root password saved in a Yandex Lockbox secret, select
Lockbox secret.In the Name, Version, and Key fields, select the secret containing your password, its version, and its key, respectively.
If you do not have a Yandex Lockbox secret, click Create to create it.
Choose the
Customsecret type to specify a custom password orGeneratedto generate password automatically.
-
-
In the Public SSH key field, select the SSH key saved in your organization user profile.
If there are no SSH keys in your profile or you want to add a new key:
-
Click Add key.
-
Enter a name for the SSH key.
-
Select one of the following:
-
Enter manually: Paste the contents of the public SSH key. You need to create an SSH key pair on your own. -
Load from file: Upload the public part of the SSH key. You need to create an SSH key pair on your own. -
Generate key: Automatically create an SSH key pair.When adding a new SSH key, an archive containing the key pair will be created and downloaded. In Linux or macOS-based operating systems, unpack the archive to the
/home/<user_name>/.sshdirectory. In Windows, unpack the archive to theC:\Users\<user_name>/.sshdirectory. You do not need additionally enter the public key in the management console.
-
-
Click Add.
The system will add the SSH key to your organization user profile. If the organization has disabled the ability for users to add SSH keys to their profiles, the added public SSH key will only be saved in the user profile inside the newly created resource.
-
-
-
Under Server information, in the Name field, enter the server name:
my-server. -
Click Lease server.
-
Note
Server setup and OS installation may take up to 45 minutes. The server will have the Provisioning status during this time. After OS installation is complete, the server status will change to Ready.
Obtain the public subnet parameters
Before configuring the network interface, find out the parameters of the dedicated public subnet the server is connected to: CIDR, default gateway address, and range of available public IP addresses.
-
In the management console
, select the folder where you are deploying your infrastructure. -
Navigate to BareMetal.
-
In the left-hand panel, select
Public addresses and subnets and open themy-public-subnetinformation page. -
Write down the CIDR values, default gateway address, and range of available public IP addresses.
For a subnet of size
/29(eight IP addresses in CIDR):- The first IP address in the range is the subnet address.
- The second IP address in the range is the default gateway address.
- From the third to second-last one are addresses available for server network interfaces.
- The last IP address in the range is the broadcast
(broadcast) address.
For example, if the subnet CIDR is
198.51.100.104/29:- Subnet IP address:
198.51.100.104. - Default gateway IP address:
198.51.100.105. - Available addresses: From
198.51.100.106to198.51.100.110. - Broadcast address:
198.51.100.111.
These values will be used in example commands further on in this guide. Replace them with the values you got for your subnet.
Connect to the server via the KVM console
Before you configure a public IP address, the server is not accessible from the Internet, so you will not be able to connect to it via SSH or RDP. To connect to the server, use the KVM console.
-
In the management console
, select the folder where you are deploying your infrastructure. -
Navigate to BareMetal.
-
Next to
my-server, click and select KVM console.A window with a KVM console terminal will open.
If the terminal does not appear, try restarting the server.
-
Authenticate to the server using the administrator password saved when renting the server (
rootfor Linux,Administratorfor Windows).Tip
To paste clipboard text to the KVM console, use the Paste text here field in the upper right corner.
If you did not save the administrator password, you can create a new one as per this guide or reinstall the server OS.
For more on connecting to a server via the KVM console, see this section.
Identify the public network interface
To figure out which of the server's network interfaces is connected to the public network, match the interface name against the MAC address listed in the management console
Write down the MAC address of the public network interface: you will need it for configuration.
In the KVM console terminal, run this command:
ip a
Result:
...
2: etx1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:25:90:c8:03:f8 brd ff:ff:ff:ff:ff:ff
altname enp2s0f0
inet6 fe80::225:90ff:fec8:3f8/64 scope link
valid_lft forever preferred_lft forever
3: etx2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:25:90:c8:03:f9 brd ff:ff:ff:ff:ff:ff
altname enp2s0f1
inet6 fe80::225:90ff:fec8:3f9/64 scope link
valid_lft forever preferred_lft forever
...
In this example, the public MAC address from the management console is 00:25:90:c8:03:f9, so the server's public network interface is eth2.
In PowerShell, run:
Get-NetAdapter | Format-Table Name, InterfaceDescription, MacAddress, Status
Result:
Name InterfaceDescription MacAddress Status
---- -------------------- ---------- ------
Ethernet Mellanox ConnectX-4 Lx Adapter #1 00-25-90-C8-03-F8 Up
Ethernet 2 Mellanox ConnectX-4 Lx Adapter #2 00-25-90-C8-03-F9 Up
In this example, the public MAC address from the management console is 00:25:90:c8:03:f9, so the server's public network interface is Ethernet 2.
Warning
If the rented server supports MC-LAG and is installed from a custom image, the physical network interfaces are not automatically combined into aggregation groups. In which case we recommend to start by configuring an aggregation group for a pair of public interfaces and then assign a static public IP address to the bond interface. In the bond interface settings, you should specify the MAC address of one of the physical interfaces of the aggregation group as the MAC address.
Assign a static public IP address to the network interface
-
In the KVM console terminal, learn the name of the Netplan
configuration file:ls /etc/netplan/Result:
50-cloud-init.yaml -
Open the configuration file:
nano /etc/netplan/50-cloud-init.yaml -
Update the public network interface settings:
network: version: 2 ethernets: ... # This example shows only the public interface configuration. etx2: match: macaddress: "00:25:90:c8:03:f9" dhcp4: false # Disable DHCP on the interface set-name: "etx2" addresses: # Set a static public IP address and subnet mask - 198.51.100.106/29 routes: # Set the default route through the public subnet gateway - to: default via: 198.51.100.105 nameservers: # Set DNS servers addresses: [77.88.8.8, 77.88.8.1]Where:
match.macaddress: MAC address of the public network interface.dhcp4:falsedisables DHCP on the interface.addresses: Public IP address from the range of available subnet addresses, with the subnet mask in CIDR format.routes.to: defaultandvia: Default route through the public subnet gateway address.nameservers.addresses: DNS server addresses.
To save the changes and exit the text editor, press Ctrl + X and confirm saving changes to the
50-cloud-init.yamlfile. -
Make sure the configuration is correct:
netplan tryIf the configuration is free of errors, the utility will temporarily apply it and prompt you to confirm the changes. Confirm the changes by pressing ENTER.
-
Apply the new configuration:
netplan apply
To configure the network interface, use nmcli. You can also use the nmtui graphical utility, which provides an interactive text interface to go with NetworkManager.
-
View the list of network connections in the KVM console terminal:
nmcli connection showResult:
NAME UUID TYPE DEVICE System etx1 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 ethernet etx1 System etx2 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e04 ethernet etx2Find the connection name for the public network interface. In this example,
System etx2. -
Set a static public IP address, default gateway, and DNS servers for the connection:
nmcli connection modify "System etx2" \ ipv4.method manual \ ipv4.addresses 198.51.100.106/29 \ ipv4.gateway 198.51.100.105 \ ipv4.dns "77.88.8.8 77.88.8.1" \ connection.autoconnect yesWhere:
ipv4.method manual: Disables DHCP and switches the connection to static configuration mode.ipv4.addresses: Public IP address from the range of available subnet addresses, with the subnet mask in CIDR format.ipv4.gateway: Public subnet gateway address.ipv4.dns: DNS server addresses separated by spaces.connection.autoconnect yes: Automatically activates the connection on system boot.
-
Activate the connection:
nmcli connection up "System etx2"
-
In the KVM console, go Start → Control Panel → Network and Internet → Network and Sharing Center.
-
In the left-hand panel, select Change adapter settings.
-
In the list that opens, find the network adapter matching the public network interface, e.g.,
Ethernet 2, right-click it and select Properties. -
In the list of connection components, select Internet Protocol Version 4 (TCP/IPv4) and click Properties.
-
Select Use the following IP address and fill out the fields:
- IP address: Public IP address from the range of available subnet addresses, e.g.,
198.51.100.106. - Subnet mask: Subnet mask matching the CIDR notation, e.g.,
/29:255.255.255.248. - Default gateway: Public subnet gateway address, e.g.,
198.51.100.105.
- IP address: Public IP address from the range of available subnet addresses, e.g.,
-
Select Use the following DNS server addresses and fill out the fields:
- Preferred DNS server:
77.88.8.8. - Alternate DNS server:
77.88.8.1.
- Preferred DNS server:
-
Click OK in both windows to save the settings.
In the PowerShell terminal in the KVM console:
-
Remove the existing IPv4 configuration on the public network interface if you got it over DHCP:
Set-NetIPInterface -InterfaceAlias "Ethernet 2" -Dhcp Disabled Remove-NetIPAddress -InterfaceAlias "Ethernet 2" -AddressFamily IPv4 -Confirm:$false Remove-NetRoute -InterfaceAlias "Ethernet 2" -AddressFamily IPv4 -Confirm:$false -
Set a static public IP address and default gateway:
New-NetIPAddress -InterfaceAlias "Ethernet 2" ` -IPAddress 198.51.100.106 ` -PrefixLength 29 ` -DefaultGateway 198.51.100.105Where:
-InterfaceAlias: Name of the public network interface.-IPAddress: Public IP address from the range of available subnet addresses.-PrefixLength: Subnet mask prefix length (for/29:29).-DefaultGateway: Public subnet gateway address.
-
Set DNS servers for the interface:
Set-DnsClientServerAddress -InterfaceAlias "Ethernet 2" ` -ServerAddresses ("77.88.8.8","77.88.8.1")
Test network connectivity
Make sure the network interface got a public IP address and the server has access to the internet.
-
Check that the specified IP address has been assigned to the network interface:
ip a | grep etx2Result:
3: etx2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 inet 198.51.100.106/29 brd 198.51.100.111 scope global etx2 -
Check the route table:
ip rResult:
default via 198.51.100.105 dev etx2 proto static 198.51.100.104/29 dev etx2 proto kernel scope link src 198.51.100.106 -
Check the DNS settings:
resolvectl status -
Check internet connectivity:
ping ya.ru -c 5Result:
PING ya.ru (77.88.55.88) 56(84) bytes of data. 64 bytes from ya.ru (77.88.55.88): icmp_seq=1 ttl=55 time=3.45 ms 64 bytes from ya.ru (77.88.55.88): icmp_seq=2 ttl=55 time=3.22 ms ... --- ya.ru ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4006ms rtt min/avg/max/mdev = 3.215/3.337/3.452/0.085 ms
-
In PowerShell, check that the specified IP address has been assigned to the network interface:
Get-NetIPAddress -InterfaceAlias "Ethernet 2" -AddressFamily IPv4 -
Check the route table:
Get-NetRoute -InterfaceAlias "Ethernet 2" -AddressFamily IPv4 -
Check the DNS settings:
Get-DnsClientServerAddress -InterfaceAlias "Ethernet 2" -
Check internet connectivity:
Test-NetConnection ya.ru -InformationLevel Detailed
Once a public IP address is assigned, you can connect to the server from the internet via that IP address using SSH (for Linux) or RDP (for Windows).
How to cancel a rent
You cannot delete a BareMetal server or a dedicated public subnet. Instead, you can choose not to renew their rent.
To stop paying for the resources you created:
- Cancel rent renewal for the BareMetal server you created earlier.
- After the minimum rent period (one month from the order date) has expired, delete the dedicated public subnet.