Configuring a VM Network Interface
After adding a network interface to a VM, check and, if necessary, adjust its settings in the VM operating system.
Get information about the VM network interface configuration:
-
Go to the VK Cloud management console.
-
Select the project where the virtual machine is located.
-
Go to the Cloud Computing → Virtual Machines section.
-
Click the name of the desired virtual machine.
-
Go to the Networks tab.
-
Write down the following information about the network:
- network and subnet name;
- gateway and CIDR for the subnet;
- IP addresses: private IP address and Floating IP address (if any);
- MAC address;
- Firewall settings (list of security groups).
The following values will be used as an example:
ParameterValueNetwork namedemoNetworkSubnet namedemoSubnetGateway10.0.0.1CIDR10.0.0.0/24Private IP address10.0.0.5Private IP address combined with the CIDR prefix10.0.0.5/24Floating IP address192.0.2.22MAC addressfa:16:3e:aa:bb:ccFirewall settingsdefault
-
Connect to the virtual machine console and log in.
-
Run the command:
ip link showOutput example1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:002: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000link/ether fa:16:3e:aa:bb:cc brd ff:ff:ff:ff:ff:ffaltname enp0s3In the command output, find the name of the interface for which the
link\etherparameter matches the MAC address obtained earlier. In this example, it isens3. -
Run the command, substituting the interface name obtained in the previous step:
ip address show ens3Output example2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000link/ether fa:16:3e:aa:bb:cc brd ff:ff:ff:ff:ff:ffaltname enp0s3inet 10.0.0.5/24 metric 100 brd 10.0.0.255 scope global dynamic ens3valid_lft 603373sec preferred_lft 603373secinet6 fe80::f816:3eff:feb4:d70f/64 scope linkvalid_lft forever preferred_lft foreverThe output must contain:
- Information about the interface state:
state UP. - The private IP address of the virtual machine combined with the
/24prefix from the subnet CIDR. In the example output, this IP address (10.0.0.5/24) is specified in theinetparameter.
- Information about the interface state:
-
Run the command:
ip route show defaultOutput exampledefault via 10.0.0.1 dev ens3 proto dhcp src 10.0.0.5 metric 100Make sure the output contains:
- The gateway IP address (
via 10.0.0.1). - The interface name obtained earlier (
dev ens3). - The private IP address of the virtual machine (
src 10.0.0.5).
If the output of the
ip address showandip route showcommands contains the information listed above, the network interface settings are correct. Skip the remaining steps of the instructions.If the output of the
ip address showandip route showcommands does not contain the information listed above, the network interface settings are incorrect. Configure the network interface. - The gateway IP address (
Configure the network using the network configurator of your OS. Depending on the OS distribution, different network configurators are used:
netplan— a solution used mainly in Ubuntu, as well as in Debian 12 and later cloud images.ifupdown— a network configurator used in standard Debian images, as well as in Debian 11 and earlier cloud images.network-scripts— used in RHEL-based distributions: CentOS, AlmaLinux, and others.wicked— a network configurator used in the OpenSUSE distribution.
-
Make the
/etc/netplan/50-cloud-init.yamlfile look as follows:network:ethernets:ens3: # Interface namedhcp4: falseaddresses:- 10.0.0.5/24 # Private IP address + prefix from CIDRroutes:- to: 0.0.0.0/0via: 10.0.0.1 # Gateway addressnameservers:addresses:- 5.61.237.120- 5.61.237.127match:macaddress: fa:16:3e:aa:bb:cc # MAC addressset-name: ens3version: 2If necessary, specify other DNS servers in the
networks.ethernets.ens3.nameservers.addressesparameter. -
Run the command:
sudo netplan apply -
Prevent automatic changes to the edited configuration file:
echo 'network: {config: disabled}' | sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
Try to connect to the virtual machine.
If the connection fails, run diagnostics for network issues on the VM, starting from step 2.