FAQ about Compute Cloud
General questions
What is cloud computing used for?
Yandex Cloud provides scalable computing capacity: you can quickly create and start virtual machines on demand and stop them when the load decreases. The usage of cloud resources reduces your IT infrastructure costs because you pay only for the resources you use.
It is easier to manage a cloud infrastructure so you can focus on your business challenges instead of server maintenance.
What can I do with a Yandex Cloud VM?
- Use only the computing capacity you really need. You do not have to buy expensive powerful equipment whenever there is a task that requires it. Instead, you can create a Yandex Cloud VM and use it if and when required.
- Quickly scale the computing power up or down as needed. You can start additional VMs during peak periods and stop them when the load drops.
- Use VMs to deploy applications that must always be available. You do not need to worry about guaranteeing server uptime: Yandex Cloud will keep it running smoothly. Focus on creating applications that work.
- Configure backups to make it easier to restore your data in the event of loss.
- Create and distribute VM disk images. You can use images to quickly deploy your software on other VMs.
- Automate VM management using the API and scripts in the command line interface.
For more information about Yandex Cloud VMs, see VMs in Compute Cloud.
How do Yandex Cloud VMs differ from regular hosting?
Traditional hosting offers you resources on lease with pre-agreed performance for a fixed time. Yandex Cloud VMs allow you to use cloud resources as your personal data center. At the same time, you get all the advantages of the fault tolerant infrastructure Yandex Cloud data centers provide.
You can scale your cloud infrastructure as your performance requirements change. This way you can control how many resources you are using at any given time and how much you pay for them.
You will also have complete control over the VM status. You can start and stop VMs when you need to. You can set up your VM software configuration and change it as required. Disk images and snapshots allow you to easily transfer data between your VMs.
How do I get started with a Yandex Cloud VM?
You can create your first VM by following one of the scenarios described in Getting started with Compute Cloud.
How do I get access to a VM?
You can connect to a VM from another VM on the same cloud network. Use the VM's internal IP address or FQDN to do this.
If you assigned a VM a public IP during creation, you can use that IP to connect to the VM from the internet.
You can get the IP addresses, FQDNs, and other information in the management console in to the Network section on the VM's page.
For more information, see VM network interfaces.
Use SSH to connect to Linux VMs. Use RDP to connect to Windows VMs.
How quickly can I change the performance of my information systems?
You can change the performance of your information system in one of the following ways:
- Create VMs in advance with the appropriate configuration and pre-installed software. During peak times, all you have to do is start these VMs to increase the performance of the information system. When the load decreases, you can stop some of the VMs to avoid paying for extra resources.
- If you frequently need new VMs with the same configuration, you can create a boot disk image and use it when creating VMs.
Why is my VM slow?
Just like for any other servers, including physical ones, VM performance depends on the performance of:
- CPU
- RAM
- Disks
- Network
Please note: The physical core thread allocated to your VM handles, in addition to the vCPU itself, the qemu virtualization process and I/O operations (network and disk ones).
General recommendations for improving VM performance:
-
For product solutions, use a vCPU with a guaranteed performance of at least 100%. If you use a vCPU with performance below 100%, the vCPU performance may drop to the guaranteed level when "neighbors" appear on the physical core. For example, for a share of 5%, this is only about 100 MHz of clock frequency, which is most likely insufficient for a product server.
If the graphs show that the load on the vCPU is close to 100% for a long time or at the time the issue occurs, we recommend increasing the number of cores.
-
Never use the swap file. It causes a significant drop in performance. The best solution is to expand the vRAM if there is not enough memory. With Linux, you can also use the
zram-config
utility. -
Use large network SSDs. The weak point of the system may be network drives. They are subject to the limits of IOPS and bandwidth, which depend on the disk type and size. For more information, see the Disk and file storage limits documentation section.
Keep in mind that disk performance also depends on the read and write request size. See Read and write operations.
You should read and write data in several threads.
-
Note that network computing depends on the vCPU performance. Run synthetic tests that do not affect disk usage to diagnose network problems. If it does have to do with a slow network, we recommend adding a vCPU and retesting it.
Which operating systems are supported by Yandex Cloud VMs?
Such VMs support Linux and Windows-based operating systems.
Public boot disk images that have been tested in Yandex Cloud are available for popular distributions of these systems.
Why can't I see my previous operations in the management console?
The management console stores information about events for 14 days.
on Personal Data
?
Does the service meet the requirements under Russian Federation Federal Law No. 152-FZ Yes, it does. You can read the full security audit conclusion
How do I contact technical support?
You can contact technical support in the Support
Can I get logs of my operations with services?
Yes, you can request log records about your resources from Yandex Cloud services. For more information, see Data requests.
How do I learn about the cost?
You can lean how much the service will cost in Compute Cloud pricing policy. You can also use our calculator.
Virtual machines
Technical specifications
What VM configuration (memory, vCPU) can I use?
When creating a VM, you select its vCPU performance level. This determines the required number and performance of cores (vCPUs). You can choose the computing resources that are appropriate for the expected load.
For more information, see vCPU performance levels.
How can I change the amount of RAM and the number of cores allocated to a VM?
For more information, see Changing VM computing resources.
How do I create a multi-interface VM?
You can add a network interface only when creating a VM. Currently, multiple interfaces can be created only on network images from Yandex Cloud Marketplace.
You can also create a NAT instance to use multiple network interfaces.
VM parameters
How do I increase quotas?
To increase quotas, submit a request on this page
After creating the request, you will be able to view it and track its status in the support section
Is nested virtualization supported? Can I host my VMs inside other VMs?
Nested virtualization is not supported for security reasons. If you did not find a suitable public image for a VM, you can upload your own image and create a VM based on it. See Creating a VM from a custom image.
Is data saved when I edit my VM parameters?
Yes, the data should be saved. However, please note that you should not restart your VM when writing data to the system disk because this might result in file system corruption.
To edit the parameters of your VM, follow these steps:
- Take a snapshot of the disk: see Creating a disk snapshot.
- Shut down the VM normally: see Stopping, starting, or restarting a VM.
- Edit the VM parameters: see Changing VM computing resources.
- Wait until the operation is completed (the Operations section in the Compute Cloud service).
- Start the VM.
- Make sure that the new parameters were applied.
Can I reduce vCPU or vRAM for a VM?
Yes, you can. However, if the load on the vCPU and/or vRAM was high enough when you changed the parameters, the VM may fail to start if you decrease these parameters.
If the load on the server is small and uniform, we recommend decreasing the parameters to avoid extra charges.
Can I change the FQDN?
The FQDN is issued to the VM at the time of its creation, and you cannot change it.
If you want to change the FQDN, delete the VM and create a new one. To preserve the consistency of the data:
- Stop the VM: see Stop.
- Take a snapshot of the disk: see Creating a disk snapshot.
- Create a new VM by selecting the snapshot as the source of its boot disk: see Create a VM with disks restored from snapshots. Specify the FQDN you need during creation.
Can the UUID of a VM change?
Standard operations for changing VM configuration, such as changing the number of vCPUs, the amount of vRAM, and adding disks, will not affect the UUID. However, in some cases, the UUID may change. For example, this may happen when updating BIOS or performing similar operations that affect the hardware part of the service.
Keep this in mind when using third-party software licenses. The best solution is to purchase a license that does not have any link to the UUID.
Can I install the required software on a VM when creating it?
Yes, you can. To do this, specify a custom script with commands to install the required software in the metadata of the VM instance you are creating. For more information, see Creating a VM with a custom configuration script.
How do I change metadata after creating a VM?
Use the updateMetadata API method.
This method enables you to update the metadata in the service without affecting the guest operating system run by the VM. If you need to update a parameter inside your VM after its creation, in most cases, the best way is to recreate the VM from a snapshot or make changes manually.
VM operations
Can I copy or clone an existing VM?
Yes, you can take snapshots of the disks attached to a VM and use them when creating a new VM.
Can I move my VM to a different availability zone?
You cannot directly change the availability zone where the VM is hosted. However, you can create a copy of the VM in the availability zone you need.
Can I move my VM to a different folder?
You can move a VM to another folder within a single cloud. For more information, see Moving a VM to another folder.
If I accidentally delete my VM, can I restore it?
No, you cannot. If you delete a VM, this cannot be undone.
To avoid losing your data in case of accidental deletion, you can configure disk backups using snapshots or specify that the disks should not be automatically deleted when deleting the VM.
Connection
How do I connect to a Linux VM?
Use this guide: Connecting to a Linux VM via SSH. If the computer you are connecting from has an older version of Windows (7, 8, or the first releases of Windows 10) and there is no built-in SSH console client, use PuTTY
The Linux images from Yandex Cloud are initially supplied without a graphical shell. Connection via SSH using a username and a password is disabled by default because this method is outdated and unsafe.
What should I do if I wasn't able even once to connect to the VM I created?
Your device should "see" the VM over the network:
- If you are connecting from the outside, you need to have a public IP address assigned to the VM or configure connectivity through another VM with a public IP address (e.g., through a NAT instance).
- Outgoing traffic to and from the VM must be allowed on your device.
Do not turn off or restart the VM immediately after creating it. For VMs with a small guaranteed vCPU performance, the initial launch process may take a long time (up to half an hour). If the VM is terminated prematurely, the initialization scripts might not have time to execute. In this case, delete the VM and create a new one.
How do I use root on a Linux VM?
When creating a Linux VM, do not use usernames reserved by the system, such as root
, admin
, etc., because cloud-init
will not be able to add a user with such a username. Try user
for username to create a VM.
To upgrade your permissions to root
, use sudo
. The user specified when creating the VM is a member of the sudo
group. root
does not have a password, so you can simply connect to the VM via SSH (see Connecting to a Linux VM via SSH) and enter this command:
sudo su
You can also execute various commands without switching to root
. For example, to shut down a VM from the guest OS, just enter the command:
sudo poweroff
What should I do if I cannot connect to a VM, even though the connection was working before?
Your data was likely taken over and third parties gained access to the VM. Take a disk snapshot (see Creating a disk snapshot) of the VM and create a new VM based on it (see Create a VM with disks restored from snapshots). If you succeeded connecting to the new VM, use stronger passwords and do not share your private data.
If the VM created from the snapshot is also unavailable for connection, see How do I get important data from a broken VM.
What should I do if I cannot connect to a VM from a Cloud Marketplace image?
Some Cloud Marketplace images have service usernames reserved, e.g., bitrix
in the 1C-Bitrix image. When creating a VM and connecting to it, use a username not reserved in the system, e.g., user
. Do not use root
, admin
, or other system usernames.
You can later change the bitrix
user password by running the sudo passwd bitrix
command.
What do I do if the Permission denied error occurs?
When connecting to a VM via SSH, the following errors may occur:
Permission denied (publickey)
Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
Common causes of errors include:
- Mistyped public key specified when creating a virtual machine.
- Invalid private key provided when attempting to establish a connection.
- Invalid data in the
authorized_keys
file.
To solve the connection issue, try providing the right private key using the -i
flag:
ssh -i <key_path/key_file_name> <username>@<VM_public_IP_address>
How do I set up an RDP/VNC connection to a Linux VM?
There are two options for enabling the graphical interface on Linux VMs:
- Use RDP or VNC. To do this:
-
Install the desktop environment on a Linux-based VM (Ubuntu/CentOS).
-
Install the xrdp or VNC server to connect via RDP or VNC, respectively.
-
Configure the software.
We recommend using a combination of a VNC server that only listens to localhost and an SSH tunnel. In this case, you eliminate the risk of attackers connecting to your VM via VNC and also encrypt the VNC traffic.
-
- Configure X11 forwarding onto the local computer. For Windows, use Xming
.- Install the desktop environment.
- Configure X11 forwarding and connect via SSH.
- Launch the application from the terminal.
What should I do if I cannot connect to a VM, even though the connection was working before?
Your data was likely taken over and third parties gained access to the VM. Take a disk snapshot (see Creating a disk snapshot) of the VM and create a new VM based on it (see Create a VM with disks restored from snapshots). If you succeeded connecting to the new VM, use stronger passwords and do not share your private data.
If the VM created from the snapshot is also unavailable for connection, see How do I get important data from a broken VM.
How do I use a serial console? How do I connect directly to a VM?
If you have issues while connecting to a VM over a network, you can use the serial console. For more information about the serial console, see Getting started with the serial console.
You can enable access to the serial console when creating or modifying a VM. The serial console will be available in the Yandex Cloud management console
For a Linux VM, you need to additionally configure password access for the user in advance by connecting via SSH and setting the password using the sudo passwd user
command (replace user
with the username you specified when creating the VM).
What do I do if an SSH key is lost?
If you set a user password, configure the VM serial console and connect to it. We recommend connecting through the CLI.
If no user password is set, take a snapshot of the VM's disk and create a new VM from the snapshot.
If the problem persists:
- Create a new disk from the VM snapshot.
- Attach it as a secondary disk to a different VM.
- Change the root directory with
chroot
. - Edit the configuration files that make the VM unavailable.
- Detach the disk from the VM.
- Create a new VM. Under Image/boot disk selection, go to the Custom tab and select your disk as the boot disk.
Why does the VM not work after a reboot?
The VM may stop working after a reboot for one of the following reasons:
- The VM was forcibly restarted while writing to the system disk. In this case, the file system could be damaged.
- The firewall and/or network was incorrectly configured.
- Changes were made to the
cloud-init
settings. - Changes were made to the Python system version, which is also used by
cloud-init
. - There was a problem with the service.
If you performed one of these actions, see How do I get important data from a broken VM. Otherwise, contact support.
How do I get important data from a VM that crashed?
When a VM crashes:
- Take a snapshot of the failed disk (see Creating a disk snapshot for details).
- Create a new VM with an additional (non-bootable) disk restored from the snapshot (see Create a VM with disks restored from snapshots for details).
- Connect to the VM (see Working on a VM for details).
- Mount the disk (see Mounting a disk created from a snapshot or image for details).
- Run a check of the disk file system.
- Transfer the data you need to the boot disk of your new VM.
Disks, snapshots, and images
How much disk space can I use for a virtual machine?
For disk limitations, see Quotas and limits in Compute Cloud.
How do I change the size of a disk?
You can increase your disk size within the limits by following the instructions Increasing the disk size. The data on the disk is kept. Make sure to wait until the operation is complete.
However, the architecture of technologies used in Yandex Cloud doesn't enable you to decrease the disk size. It's also impossible to create from the snapshot a disk smaller than the parent disk.
If the partition on the Linux boot disk doesn't expand automatically after increasing the disk size, use the following commands:
sudo growpart /dev/vda 2
sudo resize2fs /dev/vda2
For non-bootable disks, the partition size is not automatically increased. Use standard operating system tools for working with disks and their partitions, e.g., parted
, fdisk
, cfdisk
, sfdisk
, growpart
. For more information, see Increasing the size of a Linux disk partition.
To avoid accidentally losing data when resizing, we recommend that you first create a disk snapshot.
How do I upload a custom image?
See Uploading a disk image to Yandex Cloud.
To ensure that the VM created from your image functions properly, follow the steps specified in the guide.
If you have followed all recommendations and the image still fails to start up, or in case you have other questions, contact support.
What happens to the VMs running outdated OS versions?
You can use images with outdated OS versions on your VMs; however, you will not be able to get support for these VMs if you have any issues.
Should I use swap?
Avoid using swap in cloud systems whenever possible because the disk subsystem can become a bottleneck for the entire guest system. Network disk limits are too low to use the disk as a RAM extension.
Instead of swap, you can use the zram-config
utility. It allows you to organize a kind of swap inside the RAM itself thanks to compression, which is ten times faster than I/O with a disk. Keep in mind that with a high load on I/O and/or vCPUs, the use of zram-config
may negatively affect iowait
and, consequently, the performance of the network, disks, and vCPUs.
The best solution for increasing available memory is to expand the vRAM on the VM.
What should I do if a snapshot is larger than the data on the disk?
This happens if occupied sectors remain on a disk after you delete files from it.
The solution is to write a file consisting of zeros to the entire unoccupied disk space, then flush the cache to the disk, and delete the record about this file.
-
For Windows: stop disk operations and use the
SDelete
utility. You can learn more about the utility and download it in the Microsoft documentation . -
For Linux: stop disk operations and enter the following commands one-by-one:
dd if=/dev/zero | pv > full.disk
sync
rm full.disk
The "empty" space on the disk then becomes truly empty and you can create a disk snapshot. Its size will become closer to the currently used disk space.
Can I create several snapshots of the same disk at a time?
No, only a single snapshot can be created for one disk at a time. All other schedules for a given disk are ignored until a snapshot for this disk is created (manually or as scheduled).
How are snapshot quotas counted?
Snapshots are billable and count towards quotas
How do I move a VM to another folder/cloud?
-
Grant rights in your cloud to a user from another cloud:
- Role for the cloud:
resource-manager.clouds.member
. - Role for the folder:
viewer
orcompute.images.user
.
See the instructions Assigning roles.
- Role for the cloud:
-
Create an image from your snapshot under Snapshots or from the disk itself under Disks.
A user in another cloud must:
-
Run the CLI command below:
yc compute image create --source-image-id=<your_image_ID>
-
When creating a VM, specify this image as a boot disk.
How do I attach a new disk to a VM?
After creating and connecting a new disk to the VM, you need to mount it or assign it a letter, depending on the operating system. See Mounting a disk created from a snapshot or image.
How do I set up automatic backups?
For disk backups in Compute Cloud, you can make disk copies — snapshots. For automatic creation of snapshots, use schedules.
For more information, see Backups in Compute Cloud.
Why was a disk snapshot created later rather than exactly at the scheduled time?
Scheduled snapshots may be created with a slight delay depending on the current load on the service.
Can I create snapshots of the same disk according to several schedules?
Yes, you can add a disk to several schedules. There are fixed limits on the number of disk schedules.
In what time zone is the time written in disk snapshot schedule settings?
The time is provided for the UTC
Can I choose a folder for scheduled disk snapshots?
Snapshots are created in the same folder as the schedule, even if disks from other folders are added to the schedule.
What format of cron expressions is supported in disk snapshot schedules?
See section Cron expressions.
If the schedule is configured to keep several of the last disk snapshots, are old snapshots deleted before or after new ones are created?
After. A new snapshot is created first, then the old one is deleted. For example, if you want to keep only the last five snapshots, the first snapshot is deleted after the sixth one is created, the second is deleted after the seventh one is created, etc.
What happens to operations and created snapshots when disk snapshot schedules are changed, interrupted, or deleted?
All snapshot creation or deletion operations that started prior to changing, interrupting or deleting the schedule will be completed. Snapshots that were not deleted according to schedule retention settings are kept.
What happens to my data when I delete a virtual machine?
When selecting a disk to attach to a VM, you can specify that the disk should be deleted once you delete the VM. This option is also available when you create a VM, reconfigure it, or attach a new disk to it.
If a VM had any previously created disks attached, they will be detached when you delete the VM. The disk data is preserved, and this disk can be attached to another VM later.
If you would like to delete a disk with a VM, specify this option when creating the VM, reconfiguring it, or attaching the disk. Such disks will be deleted along with the VM.
Do I need to stop a VM to create disk snapshots? Do I have to wait until disk snapshots are created before I can start a virtual machine?
You do not have to stop the VM. However, keep in mind that a snapshot contains only the data present on the disk at the time of creating the snapshot. You need to take care of the data integrity yourself. For information about how to create disk snapshots, see Creating a disk snapshot.
A snapshot is created asynchronously. You can resume writing data to your disk immediately after running the create snapshot command without waiting for the snapshot generation to be completed.
Is it possible to download an image of a created VM?
This is not supported yet. However, you can copy data from a VM using application software, such as rsync, dd, or GNU Wget.
If you would like us to implement downloading or manually exporting VM images and disk snapshots to external resources or a local device, suggest this idea or vote for a similar one. We regularly review all the suggestions and add them to our development roadmap. We will notify you as soon as the idea you suggested or voted for has been implemented.
How do I detect processes that put a heavy load on a disk?
You can detect these processes using the iotop
/usr/sbin/iotop -botqqqk --iter=60 | grep -P "\d\d\d\d.\d\d K/s" >> /var/log/iotop.log
How can I find out the terms and conditions of technical support for public images?
The terms and conditions of technical support for public images may differ. For more information, see the product page in Yandex Cloud Marketplace.
Instance groups
What is Instance Groups?
Instance Groups is a component that allows you to create, use, and scale groups of similar instances in the Yandex Compute Cloud infrastructure.
With Instance Groups, you can:
- Create groups with the required number of instances and performance parameters.
- Scale the computing capacity up or down, depending on the load.
You work with an instance group as a single entity in the Yandex Compute Cloud infrastructure. This allows you to manage internal settings of instance groups to meet your app requirements.
How do I calculate the cost of using instance groups?
Creating an instance group is free of charge.
All other Yandex Cloud services, such as VMs and external IP addresses, are charged as usual.
How do I know I'm not overpaying?
To select the appropriate number of instances and minimize costs:
- Estimate the amount of computing resources required for your service and see the calculation examples and pricing policy for Yandex Compute Cloud.
- Try to frequently monitor the load on the service at different times of day.
Why can't I delete a service account linked to an instance group?
You cannot delete a service account used to manage an instance group while it is linked to this group. First, update the service account in the instance group settings or delete the instance group and then delete the service account.
Can I install the required software on a group instance when creating it?
Yes, you can. To do this, specify a custom script with commands to install the required software in the metadata section of your new instance's template. For more information, see Creating a VM with a custom configuration script.
Monitoring resource usage
Why does vCPU utilization displayed on the chart exceed 100%?
If you use cores with guaranteed, say, 5% vCPU performance, then this 5% represents 100% of the expected load for the monitoring system. If there are no "neighbors" on the physical core, you can be allocated up to 100% of vCPU performance, which is 20 times higher than the maximum expected load (×20 of 5%). Thus, the chart can show up to 2000%.
If you see the upper limit of 100% exceeded for quite a while in the graphs, we recommend increasing the guaranteed vCPU performance because "neighbors" may appear on the physical core at any time and your real utilization of physical core resources will drop to the guaranteed 5% (about 100 MHz). In this case, the guest system may not cope with the load and you'll lose access to the VM.
How do I track vRAM use through monitoring?
The Compute Cloud service can't measure vRAM consumption inside the guest operating system because for the service, memory consumption by the virtual machine is always the same: the one that is allocated the moment it is started.
To track the vRAM state, use the Yandex Monitoring service. It allows you to record your own metrics. See Writing custom metrics via the API. Just schedule a task to download data about the vRAM state and Monitoring will display them.
Licensing
The terms of use for Microsoft software are governed by the terms and conditions of the Microsoft license agreement that you enter into when purchasing a Microsoft product. The user is responsible for complying with the Microsoft licensing terms. Licensing recommendations are provided below. You are in no way obligated to follow such recommendations as they are not legally binding. If you have any questions about Microsoft software licensing and product usage rights, please consult your legal department or Microsoft reseller. The information on this page complies with the current Microsoft Product Terms
General questions
What is License Mobility?
License Mobility is a benefit provided to customers with Microsoft corporate licenses for eligible server software covered by active Microsoft Software Assurance (SA) agreements. With License Mobility, customers can use eligible Microsoft software when working with third-party cloud solution providers such as Yandex Cloud. See more details at the Microsoft website
What Microsoft software can I run on the Yandex Cloud platform?
Yandex Cloud supports server software available under the License Mobility through Software Assurance
How can I find out whether a Microsoft product is eligible for License Mobility?
This information is included in the terms of use for the Microsoft product. Whether or not a product is eligible for the License Mobility through Software Assurance program is indicated in the corresponding section of the Software Assurance agreement
Do I need to have a current Software Assurance agreement in place and participate in the License Mobility through Software Assurance program to deploy my own Microsoft licenses in Yandex Cloud?
Yes, you can. When using licensed Microsoft software in Compute Cloud, you must have a current Software Assurance agreement in place and participate in the License Mobility through Software Assurance program.
Why do I need to specify the address when using Microsoft products?
As of January 24, 2022, to use Microsoft products, you need to specify user names, names and tax IDs of legal entities, as well as addresses of individuals and legal entities. These are the requirements of the Microsoft licensing policy. This data can be sent to Microsoft. If you do not provide this data, you will not be able to run Microsoft products.
Can I use Microsoft products with my own licenses in Compute Cloud?
To learn more about Windows Server licensing, see the Use of personal licenses for Microsoft products section.
In the case of other software that you want to use inside your VM, see the terms of the license you purchased or contact Microsoft to find out whether you can use the product with such a license in Yandex Cloud.
Troubleshooting
This section describes typical problems that may arise when using Compute Cloud and the relevant solutions.
You cannot connect to a new VM with multiple network interfaces over SSH
When creating a Linux VM with multiple network interfaces, the additional network interfaces may not work correctly in the OS. In some cases, this issue can hinder network connectivity and prevent you from connecting to the VM over SSH.
To fix the issue, delete the VM and create a new one by providing additional cloud-init
Expand the Metadata section and add the user-data
key with the following configuration:
For Ubuntu
In the write_files.content.network.ethernets
configuration section, specify the settings for the required number of network interfaces you want to create on this VM, as shown below. Interfaces are numbered starting from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.
#cloud-config
datasource:
Ec2:
strict_id: false
ssh_pwauth: yes
users:
- name: <username>
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
ssh_authorized_keys:
- <public_SSH_key>
write_files:
- path: "/etc/netplan/01-netcfg.yaml"
permissions: "0644"
content: |
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: yes
eth1:
dhcp4: yes
dhcp4-overrides:
use-dns: false
use-routes: false
dhcp6: no
eth2:
dhcp4: yes
dhcp4-overrides:
use-dns: false
use-routes: false
dhcp6: no
runcmd:
- sleep 1
- sudo -i
- netplan apply
For Debian
In the Primary network interface
and Other network interfaces
configuration sections, specify the settings for the required number of network interfaces you want to create on this VM, as shown below. Interfaces are numbered starting from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.
#cloud-config
datasource:
Ec2:
strict_id: false
ssh_pwauth: yes
users:
- name: <username>
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
ssh_authorized_keys:
- <public_SSH_key>
write_files:
- path: "/etc/network/interfaces"
permissions: "0644"
content: |
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# Loopback network interface
auto lo
iface lo inet loopback
# Primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
# Other network interfaces
auto eth1
allow-hotplug eth1
iface eth1 inet dhcp
auto eth2
allow-hotplug eth2
iface eth2 inet dhcp
post-up ip route del default
runcmd:
- sleep 1
- sudo -i
- systemctl restart networking
Where:
name:
: Username for connecting to the VM over SSH.ssh_authorized_keys:
: List of public SSH keys to connect the user to the VM over SSH. You need to specify at least one public SSH key.
-
Create a file with the cloud-init configuration, e.g.,
vm-init.tpl
:For Ubuntu
In the
write_files.content.network.ethernets
configuration section, specify the settings for the required number of network interfaces you want to create on this VM, as shown below. Interfaces are numbered starting from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.#cloud-config datasource: Ec2: strict_id: false ssh_pwauth: yes users: - name: <username> sudo: ALL=(ALL) NOPASSWD:ALL shell: /bin/bash ssh_authorized_keys: - <public_SSH_key> write_files: - path: "/etc/netplan/01-netcfg.yaml" permissions: "0644" content: | # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: eth0: dhcp4: yes eth1: dhcp4: yes dhcp4-overrides: use-dns: false use-routes: false dhcp6: no eth2: dhcp4: yes dhcp4-overrides: use-dns: false use-routes: false dhcp6: no runcmd: - sleep 1 - sudo -i - netplan apply
For Debian
In the
Primary network interface
andOther network interfaces
configuration sections, specify the settings for the required number of network interfaces you want to create on this VM, as shown below. Interfaces are numbered starting from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.#cloud-config datasource: Ec2: strict_id: false ssh_pwauth: yes users: - name: <username> sudo: ALL=(ALL) NOPASSWD:ALL shell: /bin/bash ssh_authorized_keys: - <public_SSH_key> write_files: - path: "/etc/network/interfaces" permissions: "0644" content: | # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # Loopback network interface auto lo iface lo inet loopback # Primary network interface allow-hotplug eth0 iface eth0 inet dhcp # Other network interfaces auto eth1 allow-hotplug eth1 iface eth1 inet dhcp auto eth2 allow-hotplug eth2 iface eth2 inet dhcp post-up ip route del default runcmd: - sleep 1 - sudo -i - systemctl restart networking
-
When creating a VM, provide the created configuration file to it in the
--metadata-from-file
parameter, e.g.:yc compute instance create --name=multi-net-vm --hostname=multi-net-vm \ --zone ru-central1-a \ --create-boot-disk image-folder-id=standard-images,image-id=fd8bi0vgcf8vco49q3bm \ --cores=2 --memory=4G --core-fraction=100 \ --network-interface subnet-name=subnet1,ipv4-address=auto,nat-ip-version=ipv4 \ --network-interface subnet-name=subnet2,ipv4-address=auto \ --network-interface subnet-name=subnet3,ipv4-address=auto \ --metadata-from-file user-data=vm-init.tpl
-
Create a file with the cloud-init configuration, e.g.,
vm-init.tpl
:For Ubuntu
In the
write_files.content.network.ethernets
configuration section, specify the settings for the required number of network interfaces you want to create on this VM, as shown below. Interfaces are numbered starting from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.#cloud-config datasource: Ec2: strict_id: false ssh_pwauth: yes users: - name: <username> sudo: ALL=(ALL) NOPASSWD:ALL shell: /bin/bash ssh_authorized_keys: - <public_SSH_key> write_files: - path: "/etc/netplan/01-netcfg.yaml" permissions: "0644" content: | # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: eth0: dhcp4: yes eth1: dhcp4: yes dhcp4-overrides: use-dns: false use-routes: false dhcp6: no eth2: dhcp4: yes dhcp4-overrides: use-dns: false use-routes: false dhcp6: no runcmd: - sleep 1 - sudo -i - netplan apply
For Debian
In the
Primary network interface
andOther network interfaces
configuration sections, specify the settings for the required number of network interfaces you want to create on this VM, as shown below. Interfaces are numbered starting from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.#cloud-config datasource: Ec2: strict_id: false ssh_pwauth: yes users: - name: <username> sudo: ALL=(ALL) NOPASSWD:ALL shell: /bin/bash ssh_authorized_keys: - <public_SSH_key> write_files: - path: "/etc/network/interfaces" permissions: "0644" content: | # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # Loopback network interface auto lo iface lo inet loopback # Primary network interface allow-hotplug eth0 iface eth0 inet dhcp # Other network interfaces auto eth1 allow-hotplug eth1 iface eth1 inet dhcp auto eth2 allow-hotplug eth2 iface eth2 inet dhcp post-up ip route del default runcmd: - sleep 1 - sudo -i - systemctl restart networking
-
When creating a VM, provide the created metadata file to it in the
yandex_compute_instance.metadata
section, e.g.:resource "yandex_compute_instance" "multi-net-vm" { name = "multi-net-vm" platform_id = "standard-v2" zone = "ru-central1-a" resources { cores = "2" memory = "2" } boot_disk { initialize_params { image_id = "fd8bi0vgcf8vco49q3bm" } } network_interface { subnet_id = "e2lrucutusnd********" nat = true } network_interface { subnet_id = "e2lpp96bvvgp********" nat = false } network_interface { subnet_id = "e2lv9c6aek1d********" nat = false } metadata = { user-data = "${file("./vm-init.tpl")}" } }
Additional network interfaces do not work after you attach them to the existing VM
After you attach additional network interfaces to a Linux VM, they may fail to work correctly in the operating system. In some cases, this issue can hinder network connectivity and prevent you from connecting to the VM over SSH.
To fix this issue, try upgrading the VM's operating system to its latest version.
If upgrading the OS is not possible or does not help:
-
Connect to the VM over SSH.
If the SSH connection fails due to network connectivity issues, remove all the additional network interfaces and reboot the VM.
-
Update the OS network configuration:
UbuntuDebian-
Add the configuration of the new network interfaces to the
/etc/netplan/01-netcfg.yaml
file:sudo nano /etc/netplan/01-netcfg.yaml
In the
write_files.content.network.ethernets
configuration section, specify the settings for the required number of existing or new VM network interfaces, as shown below. Interfaces are numbered starting from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.# This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: eth0: dhcp4: yes eth1: dhcp4: yes dhcp4-overrides: use-dns: false use-routes: false dhcp6: no eth2: dhcp4: yes dhcp4-overrides: use-dns: false use-routes: false dhcp6: no
-
Assign the required permissions to the
/etc/netplan/01-netcfg.yaml
file:sudo chmod 0644 /etc/netplan/01-netcfg.yaml
-
Apply the configuration changes:
sudo netplan apply
-
Add the configuration of the new network interfaces to the
/etc/network/interfaces
file:sudo nano /etc/network/interfaces
In the
Primary network interface
andOther network interfaces
configuration sections, specify the settings for the required number of existing or new VM network interfaces, as shown below. Interfaces are numbered starting from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # Loopback network interface auto lo iface lo inet loopback # Primary network interface allow-hotplug eth0 iface eth0 inet dhcp # Other network interfaces auto eth1 allow-hotplug eth1 iface eth1 inet dhcp auto eth2 allow-hotplug eth2 iface eth2 inet dhcp post-up ip route del default
-
Restart the network service:
sudo systemctl restart networking
-
-
If you previously had to remove additional network interfaces, attach them again.