How to create VLAN interface and bind it to the virtual network?
Creating VLAN Adapters
Virtuozzo allows you to create new VLAN adapters on the Virtuozzo server. You can use these adapters later on to connect your virtual machines and Containers to any of the available Virtual Networks. VLAN adapters can be made using the
vznetcfg vlan add command. To create a new VLAN adapter, you need to specify two parameters:
- LAN ID—an arbitrary integer number which will uniquely identify the virtual LAN among other VLANs on the server.
- Physical network adapter on the server to which the VLAN is to be bound.
For example, you can execute the following command to make a new VLAN adapter, associate it with a VLAN having the ID of 5 (i.e. with VLAN 5), and attach the VLAN adapter to the eth0 physical adapter on the server:
# vznetcfg vlan add eth0 5
Creating a Virtual Network
Virtual networks serve as binding interfaces between the virtual network adapters in virtual machines and Containers and the physical, VLAN, and virtual network adapters on the Virtuozzo server. Using virtual networks, you can connect virtual machines and Containers to different networks.
You can create your own virtual networks using the
vznetcfg utility. For example, to make a new virtual network with the name of VLAN5, you can run one of the following commands:
# vznetcfg net new VLAN5
# prlsrvctl net add VLAN5
By default, both commands create host-only virtual networks.
NOTE: In the current version of Virtuozzo, you can create up to 16 host-only virtual networks.
The total number of Bridged and Host-only Virtual networks cannot exceed the maximum number of Linux bridges(1024).
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.
To connect the eth0.5 adapter to the VLAN5 virtual network, run this command on the server:
# vznetcfg net addif VLAN5 eth0.5
prlsrvctl utility allows to create bridged networks. In this case the adapter should be specified at once:
# prlsrvctl net add VLAN5 -t bridged --ifname eth0.5
NOTE: Only one interface can be attached to virtual network.
To check that the eth0.5 vlan adapter has been successfully added to the VLAN5 virtual network, you can execute the following command:
# vznetcfg if list Name Type Network ID Addresses eth0.5 vlan VLAN5
Changing slave interface of Virtual Network
In order to switch host-only virtual network to bridged or to change existing slave interface, perform the following command:
# prlsrvctl net set VLAN5 -t bridged --ifname eth0.5
Connecting Containers\VM to Virtual Networks
# prlctl set VMName\CTID --device-set net0 --network VLAN5
In the example above
net0 should be changed to the actual number of network interface.
To check the list of available network devices for the VM\CT
# prlctl list -if VMName\CTID | grep net net0 (+) dev='vme66797f68.0' network='VLAN5' mac=001C42933231 card=e1000 preventpromisc=off mac_filter=off ip_filter=off
If the container\VM has no network interfaces, it can be created with the following command:
prlctl set VMName\CTID --device-add net --network <network_id>