VM networking
When creating a VM, you need to specify its network interface settings by selecting the subnet to connect the VM to, configuring an internal and public IP address, and adding the required security groups. This will allow the VM to connect to other services on the intranet and internet.
Once the network interface is connected, the VM will be assigned an internal IP address in the subnet and an internal FQDN. A public IP address will only be assigned in case it was specified when creating the VM.
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 hostname (FQDN) are not automatically written to the /etc/hosts
file. This may affect running 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.
Internal IP address
You can specify the internal IP address at which the VM will be accessible after being created. If do not specify any internal IP, it will be assigned automatically.
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 after you create a VM.
Public IP address
You can get a public IP address to access a VM from the internet.
A public IP address is assigned automatically and cannot be chosen. The address is allocated from the Yandex Cloud address pool.
When a VM is stopped, its public IP address is released, and it gets a new public IP address when started next time. When the VM is restarted, its public IP address is saved.
You can make a public IP address static. For more information, see Making a VM's public IP address static.
For more information about IP address pricing, see the Public IP addresses section of the Virtual Private Cloud documentation.
The VM's public IP address is mapped to its internal IP address through NAT. This means all requests to the VM from an external IP address are sent to an internal IP address. 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 a certain VM from another VM within the same cloud network.
Once the VM is created, you cannot change its host name and internal FQDN.
The assigned FQDN depends on the specified host name (CreateInstanceSpec.hostname)
. The host name must be unique in your virtual network.
-
You cannot specify the
hostname
parameter 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, the
<VM_ID>.auto.internal
internal FQDN will be assigned. - If you enter a VM name in the Name field, the
<VM_name>.<region>.internal
internal FQDN will be assigned.
- If you leave the Name field empty when creating a VM, the
-
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 the<VM_ID>.auto.internal
format. - If a
hostname
is specified and contains no periods (.
), it is treated as an FQDN prefix. The VM will get an internal FQDN in the<hostname>.<region>.internal
format. - If a
hostname
is specified and contains a period (.
) in the middle or at the end, it is treated as an FQDN. The internal FQDN assigned to the VM is the same as thehostname
. FQDNs cannot start with a period (.
) or only contain periods (.
).
- 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.