In OpenVZ, you can connect virtual machines to virtual networks of the following types:
- Bridged virtual network allows the virtual machine to use one of the physical server’s network adapters, which makes it appear as a separate computer on the network the corresponding adapter belongs to.
- Host-only virtual network allows the virtual machine to access only the hardware node and the virtual machines 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:
# prlsrvctl net list Network ID Type Bound To Host-Only host-only Bridged bridged enp0s5 network1 bridged enp0s6
From the command output, you can see that the network1
virtual network is attached to the enp0s6
physical adapter on the hardware node. 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:
# prlctl set MyVM --device-set net0 --network network1
Creating net0 (+) network=network1 mac=001C422D7493
The VM has been successfully configured.