VK Cloud logo

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.

Preparatory steps

Get information about the VM network interface configuration:

  1. Go to the VK Cloud management console.

  2. Select the project where the virtual machine is located.

  3. Go to the Cloud Computing → Virtual Machines section.

  4. Click the name of the desired virtual machine.

  5. Go to the Networks tab.

  6. 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:

    Parameter
    Value
    Network name
    demoNetwork
    Subnet name
    demoSubnet
    Gateway
    10.0.0.1
    CIDR
    10.0.0.0/24
    Private IP address
    10.0.0.5
    Private IP address combined with the CIDR prefix
    10.0.0.5/24
    Floating IP address
    192.0.2.22
    MAC address
    fa:16:3e:aa:bb:cc
    Firewall settings
    default

1. Verify that the network interface is configured correctly

  1. Connect to the virtual machine console and log in.

  2. Run the command:

    ip link show
    Output example
    1: 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 enp0s3

    In the command output, find the name of the interface for which the link\ether parameter matches the MAC address obtained earlier. In this example, it is ens3.

  3. Run the command, substituting the interface name obtained in the previous step:

    ip address show ens3
    Output example
    2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000     link/ether fa:16:3e:aa:bb:cc brd ff:ff:ff:ff:ff:ff     altname enp0s3     inet 10.0.0.5/24 metric 100 brd 10.0.0.255 scope global dynamic ens3     valid_lft 603373sec preferred_lft 603373sec     inet6 fe80::f816:3eff:feb4:d70f/64 scope link        valid_lft forever preferred_lft forever

    The output must contain:

    • Information about the interface state: state UP.
    • The private IP address of the virtual machine combined with the /24 prefix from the subnet CIDR. In the example output, this IP address (10.0.0.5/24) is specified in the inet parameter.
  4. Run the command:

    ip route show default
    Output example
    default via 10.0.0.1 dev ens3 proto dhcp src 10.0.0.5 metric 100

    Make 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 show and ip route show commands 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 show and ip route show commands does not contain the information listed above, the network interface settings are incorrect. Configure the network interface.

2. Configure the VM network interface

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.
  1. Make the /etc/netplan/50-cloud-init.yaml file look as follows:

    network:    ethernets:        ens3: # Interface name            dhcp4: false            addresses:                - 10.0.0.5/24 # Private IP address + prefix from CIDR            routes:                - to: 0.0.0.0/0                  via: 10.0.0.1 # Gateway address            nameservers:                addresses:                    - 5.61.237.120                    - 5.61.237.127            match:                macaddress: fa:16:3e:aa:bb:cc # MAC address            set-name: ens3    version: 2

    If necessary, specify other DNS servers in the networks.ethernets.ens3.nameservers.addresses parameter.

  2. Run the command:

    sudo netplan apply
  3. Prevent automatic changes to the edited configuration file:

    echo 'network: {config: disabled}' | sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

3. Check access to the VM

Try to connect to the virtual machine.

If the connection fails, run diagnostics for network issues on the VM, starting from step 2.

Was this article helpful?