Virtual Network (1)-How to use it in a guest

Source: Internet
Author: User

This article will tell you a question: KVM guest uses libvirt XML to define how to use virtual network?


1) Nat, route, isolated type

Defining virtual network in host creates a dummy bridge, which is the equivalent of a switch. The guest only needs to be connected to this switch.

In the XML of the guest, add:

# Virsh Edit vm...<interface type= ' network '/><source network= ' Net1 '/> ====>net1 is a virtual network already defined </ Interface>, .....

This is the simplest XML, which will automatically add some necessary information such as MAC,PCI address, model type, and so on after saving. Of course, you can specify it manually.


2) User (userspace slirp stack), Vhost-user,multicast Tunnel, TCP tunnel,udp unicast tunnel type

Can only be referenced by interface in the guest. If user is a type that is available to a non-privileged user provided by QEMU, you can refer to this:

<interface type= ' user '/> (mac,pci address, model type if not specified, will be generated automatically)


3) Bridge (use of exsiting host Linux Bridge)

There is a Linux bridge on its own, which can be defined as a network for guest (no more bridge creation) or directly to guest. The two approaches are essentially the same.


# Virsh Net-dumpxml birdge-net<network> <name>bridge-net</name> <forward mode= ' Birdge '/> < Bridge name= ' br0 '/> </network># virsh edit vm...<interface type= ' network ' > <source network= ' Bridge-net ' ></interface>


Direct to Guest by:

<interface type= ' bridge ' > <source bridge= ' br0 '/></interface>


4) Macvtap (including Bridge,vepa,private,passthrough four species), Hostdev

A network can be set as a interface pool, referenced in the form of a network, or can be referenced directly. The same 3), both ways are essentially the same.

Define Interface Pool

<network> <name>direct-macvtap</name> <forward mode= "Bridge" > <interface dev= "Eth20"/> <interface dev= "eth21"/> <interface dev= "eth22"/> <interface D ev= "eth23"/> <interface dev= "eth24"/> </forward> </network>
<network> <name>hostdev-net</name> <forward mode= ' hostdev ' managed= ' yes ' > <driver name= ' V Fio '/> <address type= ' pci ' domain= ' 0 ' bus= ' 4 ' slot= ' 0 ' function= ' 1 '/> <address type= ' pci ' domain= ' 0 ' bus = ' 4 ' slot= ' 0 ' function= ' 2 '/> <address type= ' pci ' domain= ' 0 ' bus= ' 4 ' slot= ' 0 ' function= ' 3 '/> </forward> </network>

Direct reference in Guest

# Virsh Edit vm...<interface type= ' direct ' > <source dev= ' enp0s25 ' mode= ' Vepa '/></interface>
# Virsh Edit vm ... <interface type= ' hostdev ' managed= ' yes ' > <source> <address type= ' PCI ' DOMA in= ' 0x0000 ' bus= ' 0x00 ' slot= ' 0x19 ' function= ' 0x0 '/> </source> </interface>


This article is from the "11517071" blog, please be sure to keep this source http://11527071.blog.51cto.com/11517071/1843234

Virtual Network (1)-How to use it in a guest

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.