Configuring network interfaces of virtual machines

You can add new network interfaces to your virtual machines, edit IP addresses and security groups for the existing interfaces, and remove network interfaces by detaching them.

Limitations

  • You cannot manage network interfaces of shelved VMs.
  • A VM that is connected to a dual-stack network always receives an IPv6 address, if the IPv6 subnet is in the SLAAC or DHCPv6 stateless mode.

To attach a network interface to a virtual machine

Admin panel

  1. On the Compute > Virtual machines > Virtual machines screen, click the required virtual machine.
  2. On the Overview tab, click Edit in the Network interfaces section.
  3. In the Network interfaces window, click Add to attach a network interface.
  4. In the Add network interface window, select a compute network to connect to, and then specify MAC address, IPv4 and/or IPv6 addresses, and security groups. By default, MAC and primary IP addresses are assigned automatically. To specify them manually, clear the Assign automatically check boxes, and enter the desired addresses. Optionally, assign additional IP addresses to the network interface in the Secondary IP addresses section. Note that a secondary IPv6 address is not available for an IPv6 subnet that works in the SLAAC or DHCPv6 stateless mode.

    Secondary IP addresses, unlike the primary one, will not be automatically assigned to the network interface inside the virtual machine guest OS. You should assign them manually.

    After specifying the network interface parameters, click Add.

  5. Click Done to finish editing VM network interfaces and save your changes.

Command-line interface

Use the following command:

vinfra service compute server iface attach [--fixed-ip <ip-address | ip-address=
                                           <ip-address>,subnet=<subnet> | 
                                           ip-version=<ip-version>>]
                                           [--spoofing-protection-enable | 
                                           --spoofing-protection-disable]
                                           [--security-group <security-group> | 
                                           --no-security-groups]
                                           --server <server>
                                           --network <network> [--mac <mac>]
--fixed-ip <ip-address|ip-address=<ip-address>,subnet=<subnet>|ip-version=<ip-version>>
Desired IP address and/or subnet. This option can be used multiple times.
--spoofing-protection-enable
Enable spoofing protection for the network interface
--spoofing-protection-disable
Disable spoofing protection for the network interface
--security-group <security-group>
Security group ID or name. This option can be used multiple times.
--no-security-groups
Do not set security groups
--server <server>
Virtual machine ID or name
--network <network>
Network ID or name
--mac <mac>
MAC address

For example, to connect the virtual network myprivnet to the virtual machine myvm and allocate the IP address 192.168.129.8, run:

# vinfra service compute server iface attach --network myprivnet --fixed-ip 192.168.129.8 --server myvm

The created network interface will appear in the vinfra service compute server iface list output:

# vinfra service compute server iface list --server myvm
+----------------+----------------+-------------------+-----------------+
| id             | network_id     | mac_address       | fixed_ips       |
+----------------+----------------+-------------------+-----------------+
| 690ed3f2-<...> | 0710372e-<...> | fa:16:3e:54:59:08 | 192.168.129.8   |
| a5b13bf3-<...> | 1bf2c9da-<...> | fa:16:3e:b9:33:bb | 192.168.128.100 |
+----------------+----------------+-------------------+-----------------+

To edit a network interface of a virtual machine

Admin panel

  1. On the Compute > Virtual machines > Virtual machines screen, click the required virtual machine.
  2. On the Overview tab, click Edit in the Network interfaces section.
  3. In the Network interfaces window, click the ellipsis button next to the interface you want to edit, and then click Edit.
  4. In the Edit network interface window, modify the network interface parameters as follows:

    • Change the primary IP address. To update the address inside the VM guest OS, restart the network interface.
    • Add or remove secondary IP addresses.
    • Modify security groups assigned to the VM.

    After updating the required parameters, click Save.

  5. Click Done to finish editing VM network interfaces and save your changes.

Command-line interface

Use the following command:

vinfra service compute server iface set [--fixed-ip <ip-address | ip-address=
                                        <ip-address>,subnet=<subnet> | 
                                        ip-version=<ip-version>>]
                                        [--spoofing-protection-enable | 
                                        --spoofing-protection-disable]
                                        [--security-group <security-group> | 
                                        --no-security-groups]
                                        --server <server> <interface>
--fixed-ip <ip-address|ip-address=<ip-address>,subnet=<subnet>|ip-version=<ip-version>>
Desired IP address and/or subnet. This option can be used multiple times.
--spoofing-protection-enable
Enable spoofing protection for the network interface
--spoofing-protection-disable
Disable spoofing protection for the network interface
--security-group <security-group>
Security group ID or name. This option can be used multiple times.
--no-security-groups
Do not set security groups
--server <server>
Virtual machine ID or name
<interface>
Network interface ID

For example, to unassign security groups from the network interface with the ID 611abc06-7557-44c9-bbf8-31fef817e802 attached to the virtual machine myvm, run:

# vinfra service compute server iface set --server myvm --no-security-groups 611abc06-7557-44c9-bbf8-31fef817e802

To detach a network interface from a virtual machine

Admin panel

  1. On the Compute > Virtual machines > Virtual machines screen, click the required virtual machine.
  2. On the Overview tab, click Edit in the Network interfaces section.
  3. In the Network interfaces window, click the ellipsis button next to the interface you want to detach, and then click Remove.
  4. Click Done to finish editing VM network interfaces and save your changes.

Command-line interface

Use the following command:

vinfra service compute server iface detach --server <server> <interface>
--server <server>
Virtual machine ID or name
<interface>
Network interface ID

For example, to detach the network interface with the ID 471e37fd-13ae-4b8f-b70c-90ac02cc4386 from the VM myvm, run:

# vinfra service compute server iface detach 471e37fd-13ae-4b8f-b70c-90ac02cc4386 --server myvm