Configuring Virtual Machines and Containers in Bridged Mode
This section describes all operations related to configuring virtual machines and containers that operate in bridged mode.
Managing Virtual Networks
A virtual network acts as a binding interface between a virtual network adapter in a virtual machine or container and the corresponding network adapter on the hardware node. Using virtual networks, you can include virtual machines and containers in different networks. Virtuozzo Server enables you to manage virtual networks as follows:
- Create virtual networks.
- Configure virtual network parameters.
- List existing virtual networks.
- Delete virtual networks.
These operations are described in the following subsections in detail.
Creating Virtual Networks
By default, Virtuozzo Server creates the following virtual networks on the server:
- Bridged virtual network that is connected to one of the physical adapters on the hardware node (e.g.,
enp0s5) and provides virtual machines and containers included in this virtual network with access to the network behind this physical adapter. - Host-only virtual network that is connected to a special virtual adapter on the server and allows the virtual machines and containers joined to this virtual network to access only the server and the other virtual machines and containers on this network.
You can create your own virtual networks using the prlsrvctl command. For example, to create a new virtual network network1, you can run:
| |
By default, the command creates a host-only virtual network, but you can change its type if needed (see Configuring Virtual Network Parameters).
Creating Network Bridges for Network Adapters
To connect a network adapter to a bridged virtual network, you need to create a network bridge first. A network adapter can be physical (enp<X>s<Y>) or logical: a VLAN (enp<X>s<Y>.<N>) or a bonding interface (bond<N>).
For example, to create a network bridge for the VLAN interface, you can use the NetworkManager text-based user interface tool, nmtui, as follows:
On the node, start
nmtui:1# nmtuiIn the tool TUI, use the arrow keys and Tab to navigate through the options, Enter to select an option, and Space to set and clear check boxes.
On the NetworkManager TUI screen, select Edit a connection from the menu.

On the next screen, select Add to add a new connection.

To add a new network bridge, choose Bridge from the drop-down list in the New connection window and press Create.

On the Edit connection screen:
In the Profile name field, enter the connection profile name. This name with the
ifcfg-prefix will be used for creating the interface configuration file in the/etc/sysconfig/network-scripts/directory.In the Device field, specify the device name of the new network bridge.
Press Add to specify a slave network interface.
In the New connection window, choose VLAN from the drop-down list and press Create.

In the Edit connection window, specify the profile name and device name of the VLAN interface in the Profile name and Device fields, respectively, and press OK.
The Parent and VLAN ID fields are filled in automatically.

The chosen VLAN interface will appear in the Slaves section.
Clear the Enable STP (Spanning Tree Protocol) check box.

Configure static IP parameters of the network bridge:
In the IPv4 CONFIGURATION section, press Automatic and choose Manual from the drop-down list.

Press Show to expand the section.
Assign a static IP address, set the default gateway and the DNS server for the network bridge in the corresponding fields.

Configure other network parameters if required and press OK.
The network bridge for the VLAN adapter will appear in the list of existing connections.

To exit
nmtui, press Back and then Quit.
After creating the network bridge, you can check its configuration file stored in the /etc/sysconfig/network-scripts/ directory. For example:
| |
Configuring Virtual Network Parameters
Virtuozzo Server allows you to configure the following parameters for a virtual network:
The networking mode in which the virtual network is operating.
Before changing the virtual network type to bridged, a network bridge must be created for the virtual network. See Creating Network Bridges for Network Adapters.
The description of the virtual network.
All these operations can be performed using the prlsrvctl utility. For example, if you need to configure the network1 virtual network. This virtual network is currently configured as a host-only network and has the following description: This is a host-only virtual network. To change these parameters, you can execute the following command:
| |
This command configured the network1 virtual network as follows:
- Changes the virtual network type to bridged.
- Changes the virtual network description to the following: “This is now a bridged virtual network”.
Listing Virtual Networks
To list the virtual networks existing on the hardware node, you can use the prlsrvctl utility as shown below.
| |
This utility displays the following information on virtual networks:
| Column | Description |
|---|---|
| Network ID | The name assigned to the virtual network. |
| Type | The networking mode set for the virtual network. |
| Bound To | The adapter on the hardware node connected to the virtual networks, if any. |
Connecting Virtual Networks to Adapters
By connecting an adapter on the physical server to a virtual network, you can join all virtual machines and containers included in the virtual network to the network to which the corresponding adapter is connected.
Consider the following example:
- The
enp0s6physical adapter and thenetwork1virtual network exist on the hardware node. For information on creating virtual networks, see Creating Virtual Networks. - The
enp0s6physical adapter is connected to the local network. - The
br1network bridge for theenp0s6physical adapter is created. For information on creating network bridges, see Creating Network Bridges for Network Adapters. - The container
MyCTis connected to thenetwork1virtual network. Detailed information on joining virtual machines and containers to virtual networks is given in Connecting Virtual Environments to Virtual Networks.
To connect the enp0s6 adapter to the network1 virtual network and thus to join the container MyCT to the network behind enp0s6, run this command on the server:
| |
To check that the enp0s6 physical adapter has been successfully added to the network1 virtual network, you can execute the following command:
| |
As you can see, the enp0s6 adapter is now joined to the network1 virtual network. That means that the container MyCT whose virtual network adapter is connected to network1 can access the local network behind enp0s6.
Deleting Virtual Networks
At any time, you can remove a virtual network that you do not need any more from the physical server. To do this, you can use the prlsrvctl utility. For example, you can delete the network1 virtual network by running the following command:
| |
To check that network1 has been successfully removed, execute this command:
| |
Managing Virtual Network Adapters in Virtual Environments
Virtuozzo Server provides you with ample opportunities of configuring virtual network adapters in virtual environments and including them in different network environments. This section shows you the way to perform the following operations:
- Create new virtual network adapters and delete existing ones.
- Configure the parameters of an existing virtual network adapter.
- Join virtual network adapters to virtual networks.
All these operations are described in the following subsections in detail.
Creating and Deleting Virtual Adapters
A virtual environment can have up to 15 virtual network adapters. Each adapter can be connected to a different network. For example, if you need to create a new virtual adapter for the virtual machine MyVM. To do this, you can execute the following command:
| |
To check that the network adapter (net1) has been successfully added to the virtual machine, run this command:
| |
At any time, you can remove the newly created network adapter (net1) by executing the following command:
| |
Configuring Virtual Adapter Parameters
Virtuozzo Server allows you to configure the following parameters of virtual adapters:
Configuring MAC Addresses
If you need for some reason to regenerate the current MAC address of a network adapter, you can use the following command:
| |
This command sets the MAC address of 00:1C:42:2D:74:00 for the net1 adapter in the virtual machine MyVM. If you do not know what MAC address to assign to your virtual adapter, you can generate a new one with prlctl set. For example:
| |
Configuring IP Parameters
As any other standalone server, each virtual environment must have a number of TCP/IP settings configured in the proper way to successfully operate on the network. These settings include:
- IP address
- Default gateway
- DNS server
Usually, you define all these settings when you create a virtual environment. However, if you have not yet set any of the settings or want to modify any of them, you can use the prlctl set command. For example, you can execute the following command to assign the IP address of 192.129.129.20 to the net1 adapter in the virtual machine MyVM, set the default gateway to 192.129.129.1 and the DNS server to 192.192.192.10:
| |
Along with a static assignment of network parameters to a virtual adapter, you can make the adapter receive its TCP/IP settings automatically using the Dynamic Host Configuration Protocol (DHCP). For example, you can run this command to make the net1 adapter in the virtual machine MyVM get its IP settings through DHCP:
| |
Connecting Virtual Environments to Virtual Networks
In Virtuozzo Server, you can connect virtual environments to virtual networks of the following types:
- Bridged virtual network allows a virtual environment to use one of the physical server network adapters, which makes it appear as a separate computer on the network the corresponding adapter belongs to.
- Host-only virtual network allows a virtual environment to access only the physical server and the virtual environments joined to this network.
By default, any newly created adapter is connected to the Bridged network. To join a virtual machine to another network, use the prlctl set command. For example, the following session demonstrates how you can connect the net0 adapter of the virtual machine MyVM to the network1 virtual network.
Before connecting the virtual machine MyVM to the network1 virtual network, you may wish to check the network adapter associated with this virtual network. You can do it, for example, using the following command:
| |
From the command output, you can see that the network1 virtual network is attached to the enp0s6 physical adapter on the physical server. That means that, after connecting the virtual machine MyVM to the network1 virtual network, the virtual machine will be able to access all computers on the network where the enp0s6 adapter is connected.
Now you can run the following command to join the net1 adapter of the virtual machine MyVM to the network1 virtual network:
| |
To check that the network adapter (net1) has been successfully joined to the network1 virtual network, execute
| |