Ce contenu n'est pas disponible dans la langue sélectionnée.
20.16.9. Network Interfaces
The network interface devices are modified using management tools that will configure the following part of the Domain XML:
... <devices> <interface type='bridge'> <source bridge='xenbr0'/> <mac address='00:16:3e:5d:c7:9e'/> <script path='vif-bridge'/> <boot order='1'/> <rom bar='off'/> </interface> </devices> ...
Figure 20.35. Devices - network interfaces
There are several possibilities for specifying a network interface visible to the guest virtual machine. Each subsection below provides more details about common setup options. Additionally, each
<interface>
element has an optional <address>
sub-element that can tie the interface to a particular pci slot, with attribute type='pci'
(Refer to Section 20.16.3, “Device Addresses”).
20.16.9.1. Virtual networks
This is the recommended configuration for general guest virtual machine connectivity on host physical machines with dynamic / wireless networking configurations (or multi-host physical machine environments where the host physical machine hardware details are described separately in a
<network>
definition). In addition, it provides a connection whose details are described by the named network definition. Depending on the virtual network's forward mode
configuration, the network may be totally isolated (no <forward>
element given), NAT'ing to an explicit network device or to the default route (forward mode='nat'
), routed with no NAT (forward mode='route'/
), or connected directly to one of the host physical machine's network interfaces (using macvtap) or bridge devices (forward mode=' bridge|private|vepa|passthrough'/
)
For networks with a forward mode of bridge, private, vepa, and passthrough, it is assumed that the host physical machine has any necessary DNS and DHCP services already setup outside the scope of libvirt. In the case of isolated, nat, and routed networks, DHCP and DNS are provided on the virtual network by libvirt, and the IP range can be determined by examining the virtual network config with
virsh net-dumpxml [networkname]
. There is one virtual network called 'default' setup out of the box which does NAT'ing to the default route and has an IP range of 192.168.122.0/255.255.255.0. Each guest virtual machine will have an associated tun device created with a name of vnetN, which can also be overridden with the <target>
element (refer to Section 20.16.9.11, “Overriding the target element”).
When the source of an interface is a network, a portgroup can be specified along with the name of the network; one network may have multiple portgroups defined, with each portgroup containing slightly different configuration information for different classes of network connections. Also, similar to
<direct>
network connections (described below), a connection of type network
may specify a <virtualport>
element, with configuration data to be forwarded to a vepa (802.1Qbg) or 802.1Qbh-compliant switch, or to an Open vSwitch virtual switch.
Since the actual type of switch may vary depending on the configuration in the
<network>
on the host physical machine, it is acceptable to omit the virtualport type attribute, and specify attributes from multiple different virtualport types (and also to leave out certain attributes); at domain startup time, a complete <virtualport>
element will be constructed by merging together the type and attributes defined in the network and the portgroup referenced by the interface. The newly-constructed virtualport is a combination of both. The attributes from lower virtualport cannot make changes on the ones defined in higher virtualport. Interfaces take the highest priority, portgroup is lowest priority.
For example, to create a properly working network with both an 802.1Qbh switch and an Open vSwitch switch, you may choose to specify no type, but both
profileid
and an interfaceid
must be supplied. The other attributes to be filled in from the virtual port, such as such as managerid
, typeid
, or profileid
, are optional.
If you want to limit a guest virtual machine to connecting only to certain types of switches, you can specify the virtualport type, and only switches with the specified port type will connect. You can also further limit switch connectivity by specifying additional parameters. As a result, if the port was specified and the host physical machine's network has a different type of virtualport, the connection of the interface will fail. The virtual network parameters are defined using management tools that modify the following part of the domain XML:
... <devices> <interface type='network'> <source network='default'/> </interface> ... <interface type='network'> <source network='default' portgroup='engineering'/> <target dev='vnet7'/> <mac address="00:11:22:33:44:55"/> <virtualport> <parameters instanceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/> </virtualport> </interface> </devices> ...
Figure 20.36. Devices - network interfaces- virtual networks