5.3. Configuring Virtual Machines and Containers in Host-Routed Mode¶
You can configure the following parameters of network adapters that operate in the host-routed mode:
IP addresses and network masks
DNS servers
DNS search domains
5.3.1. Setting IP Addresses¶
The session below shows how to set IP addresses for the virtual machine MyVM
and the container MyCT
# prlctl set MyVM --device-set net0 --ipadd 10.0.186.100/24
# prlctl set MyVM --device-set net0 --ipadd 1fe80::20c:29ff:fe01:fb07
# prlctl set MyCT --ipadd 10.0.186.101/24
# prlctl set MyCT --ipadd fe80::20c:29ff:fe01:fb08
net0
in the commands above denotes the network card in the virtual machine MyVM
to assign the IP address to. You can view all network cards of a virtual machine using the prlctl list VM_name -i
command. For the container MyCT
, you do not need to specify the network card name; prlctl set
automatically performs the operation on the default adapter that always operates in the host-routed mode.
5.3.2. Setting DNS Server Addresses¶
To set a DNS server for the virtual machine MyVM
and the container MyCT
, you can use the following commands:
# prlctl set MyVM --device-set net0 --nameserver 192.168.1.165
# prlctl set MyCT --nameserver 192.168.1.165
5.3.3. Setting DNS Search Domains¶
To set a DNS search domain for the virtual machine MyVM
and the container MyCT
, run these commands:
# prlctl set MyVM --device-set net0 --searchdomain 192.168.10.10
# prlctl set MyCT --searchdomain 192.168.10.10
Note the following:
You can only configure network settings of virtual machines that have Virtuozzo guest tools installed.
Network adapters operating in the routed mode must have at least one static IP address assigned.
To be able to assign network masks to containers operating in the
venet0
networking mode, set theUSE_VENET_MASK
parameter in the/etc/vz/vz.conf
configuration file toyes
.Containers can only have one network adapter operating in the host-routed mode. This adapter is automatically created when you create a container.
You can set name servers and search domain in
/etc/vz/vz.conf
with theNAMESERVER
andSEARCHDOMAIN
parameters. If set toinherit
, the values will be copied from/etc/resolv.conf
on the host.
5.3.3.1. Switching Virtual Machine Adapters to Host-Routed Mode¶
By default, a virtual adapter in any newly created virtual machine starts operating in the bridged mode (see Connecting Virtual Environments to Virtual Networks for details). To change the current network mode to host-routed, you can run the following command:
# prlctl set <VM_name> --device-set Net_ID --type routed
For example, to set the net0
adapter in the virtual machine MyVM
to operate in the host-routed mode, use this command:
# prlctl set MyVM --device-set net0 --type routed