VM network interfaces
A virtual machine can have one or more network interfaces. When creating a VM, you need to configure at least one of its network interfaces by selecting the subnet to connect your VM to, configuring internal and public IP addresses, and adding the required security groups. This will allow the VM to connect to other services on the intranet and internet.
Note
The Predictable Network Interface Nameseth0, eth1, ..., ethN, where N is the network interface number in the VM configuration, starting from zero. The numbering may contain gaps: for example, after deleting interface No. 1, the eth0 and eth2 names are retained.
When preparing a custom VM image, we recommend to disable this schema during the build stage. After disabling the schema, check the network setting bindings to interface names and update them if required. Reboot the VM and make sure all network interfaces are getting IP addresses via DHCP.
After the network interface is connected, the VM will be assigned an internal IP address in the subnet. A public IP address will be assigned only if you specified it in the network interface settings.
You can find out the IP addresses, FQDNs, and other information in the management console by going to the Network section on the virtual machine page. This data can be used to connect to the VM.
On VMs created from public Linux images, the IP address and host name (FQDN) are not automatically written to the /etc/hosts file. This may affect the sudo command.
You can change the network interface settings on stopped VMs by assigning a public IP address, changing the subnet, selecting other security groups, or configuring the DNS settings.
You can also add more network interfaces and delete them from both stopped and running VMs. However, to avoid VM routing issues, we recommended adding and removing network interfaces on stopped VMs.
The feature of adding and removing network interfaces on running VMs is at the Preview stage. To access the feature, contact
If the network interfaces you added are inactive or you can no longer connect to your VM, see Troubleshooting.
Note
You can restrict creating a VM with multiple network interfaces and assigning public IP addresses to network interfaces at the folder, cloud, or organization level using the compute.denyMultipleNic and compute.denyPublicIpAssigning access policies. For more information, see Access policies.
Recommendations
For stable network operation on a VM, follow these recommendations:
- To maintain network connectivity, add network interfaces to stopped VMs.
- Assign a public IP address to a single VM's network interface only.
Internal IP address
For each network interface of a VM, you can specify an internal IP address that will be assigned to that interface. If the internal IP address is not specified, it will be assigned automatically from the IP address range of the relevant subnet.
Note
Currently, only IPv4 addresses are supported. Yandex Compute Cloud VMs and DB hosts provide access to and from the internet via public IP addresses only.
An internal IP address can be used to access a VM from another VM. You can use an internal IP address only to connect to the VMs that belong to the same cloud network.
You can change the internal IP address of a network interface after you create a VM.
Public IP address
To access your virtual machine from the internet, you can get a public IP address.
The public IP address can be assigned automatically from the Yandex Cloud address pool or selected from a list of reserved public IP addresses.
If a public IP address was assigned automatically, it will be released if you stop a VM. The VM will get a new public IP address the next time you start it. If you restart a VM, it retains the automatically assigned public IP address.
You can make a public IP address static. For more information, see Making a VM public IP address static.
For more information about IP address pricing, see the Public IP addresses section of the Virtual Private Cloud documentation.
The public IP address of the VM's network interface is mapped to its internal IP address through NAT. Therefore, all requests to the VM from the external IP address of its network interface are sent to the internal IP address of that interface. For more information about NAT, see RFC 3022
Host name and internal FQDN
When creating a VM, it is assigned a host name and internal FQDN that can be used to access one VM from another within the same cloud network. You can get the FQDN together with information about the VM.
Once the VM is created, you cannot change its host name and internal FQDN.
The assigned FQDN depends on the specified (CreateInstanceSpec.hostname). The host name must be unique in your virtual network.
-
You cannot specify the
hostnameparameter in the management console for a new VM. Instead, the user-defined VM name is used:- If you leave the Name field empty when creating a VM, this internal FQDN will be assigned:
<VM_ID>.auto.internal. - If you enter a VM name in the Name field, this internal FQDN will be assigned:
<VM_name>.<region>.internal.
- If you leave the Name field empty when creating a VM, this internal FQDN will be assigned:
-
When using the CLI, API, and Terraform, FQDNs are created as follows:
- If you do not specify a
hostname, the VM will get a unique FQDN in this format:<VM_ID>.auto.internal. - If a
hostnameis specified and does not contain the.symbol, it is treated as an FQDN prefix. The VM will get an internal FQDN in this format:<hostname>.<region>.internal. - If a
hostnameis specified and contains the.symbol in the middle or at the end, it is treated as an FQDN. The VM will get an internal FQDN that will be the same ashostname. You cannot specify an FQDN beginning with or containing only a period (.).
- If you do not specify a
Examples
| Specified host name | VM FQDN |
|---|---|
<not_specified> |
<VM_ID>.auto.internal |
breathtaking |
breathtaking.ru-central1.internal |
this-is-sparta |
this-is-sparta.ru-central1.internal |
hello.world or hello.world. |
hello.world |
breathtaking. |
breathtaking |
.why |
error (FQDN starts with ".") |
. |
error (FQDN contains dots "." only) |
MAC address
Once the network interface is connected to a VM, it will be assigned the device MAC address.
You can find out the MAC address from a VM or in the resource information using the Yandex Cloud API.
Use cases
- Creating a bastion host
- Implementing fault-tolerant scenarios for NAT VMs
- Configuring an SFTP server based on CentOS 7
- Assigning a domain name to a web server VM
- Deploying Remote Desktop Gateway
A folder is a logical space where you create and group your Yandex Cloud resources. Just like folders in your file system, Yandex Cloud folders make resource management simpler. For more information, see Folder.
A cloud is an isolated logical space where folders and other Yandex Cloud resources are created. You cannot move resources from one cloud to another. For more information, see Cloud.
An organization is the highest resource in the Yandex Cloud resource model hierarchy that consolidates the resources of all other services. It is also used for user management as well as authentication and authorization management. For more information, see Organization.