KVM (LIBIVRT) bridge and NAT mode coexistence

Source: Internet
Author: User

Requirements Description:

  1. In order to cooperate with the project acceptance, and to verify the smooth process, the original deployed on a public network server 7 KVM virtual machine to migrate to the easy-to-carry offline (Dell Precision m6800/i7/32g/ 256SSD+2T).

  2. 7 KVM VMs in 4 are windows7,3 are domestic kylin, each equipped with a public network IP(for the purpose of remote demonstration). Because the IP in the project code is written dead, the offline VM host IP must use the IP address on the original public cable ;4 windows , and 3 Kylin are located in different network segments, examples:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/75/0D/wKioL1Yxt-XQswrYAAEhyTlO3yc572.jpg "title=" 1.png " alt= "Wkiol1yxt-xqswryaaehytlo3yc572.jpg"/>

3. There are currently only two network segments, the physical machine windows7 is using bridge mode, so and the work station in a network segment,Kylin using the Nat mode, I created a virbr0 network card, let kylin access;

4. when more network segments are needed, the configuration can be used to create a network;

Implementation steps:

    1. operating system installation,KVM and libvirt use not to repeat, directly record the migration process;

    2. the original image of the CP , note that when the CP virtual machine mirroring, the virtual machine must be shut down, otherwise the mirror can not be used (in the actual enterprise, is generally used in the more mature virtualization products, these products can be directly to the virtual machine online migration, But most of the deployment is inconvenient, so I use the most primitive method - Manually migrating these virtual machines)

    3. the document focuses on Nat , basically want NAT host to communicate with Bridge host

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/75/10/wKiom1YxuICDYlN4AAJTWaOUcXU556.jpg "title=" 2.png " alt= "Wkiom1yxuicdyln4aajtwaoucxu556.jpg"/>

you can see that these hosts are running: we need to turn them off . CP Mirror

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/75/10/wKiom1YxuInjI6mjAAO9FRQ7nbI556.jpg "title=" 3.png " alt= "Wkiom1yxuinji6mjaao9frq7nbi556.jpg"/>

these mirrors are fully 109G, andCP 1 hours is finally OK:

    1. The XML file of the Cp virtual machine ;

this XML file determines the configuration of the virtual machine, memory,CPU, network, have this file to control, generally located in the/etc/libvirt/qemu/location; (different system locations may vary)

    1. Define a NAT Network;

directory where the configuration file is located:/etc/libvirt/qemu/networks/, default exists , and we have a copy of CP modified on its basis:

CD/ETC/LIBVIRT/QEMU/NETWORKS/CP default.xml Kylin.xmlvim kylin.xml<network> <name>kylin</name> <bridge name= "Virbr0"/> <forward/> <ip address= "219.239.247.1" netmask= "255.255.255.0" > <static > <range start= "219.239.247.2" end= "219.239.247.254"/> </static> </ip></network>

Explain:

An address needs to be configured for the Virbr0 , andthe host in NAT mode needs to set the gateway to that IP;

can define whether the IP is dhcp or static, the default is DHCP, I so it does not error and can be used, as can be changed;

Save exit Wq After the definition is complete :

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/75/0D/wKioL1YxuNvjTbNlAADq-MtL98w737.jpg "title=" 4.png " alt= "Wkiol1yxunvjtbnlaadq-mtl98w737.jpg"/>

You can look at the existing Nat network, the default network is there, I now delete it to enable my own, (also can not delete).

Virsh net-undefinedefault (delete default network command)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/75/10/wKiom1YxuLbjTIUZAAC9poQBBaQ632.jpg "title=" 5.png " alt= "Wkiom1yxulbjtiuzaac9poqbbaq632.jpg"/>

Now look, there's no more.

Execute Virsh net-define kylin.xml release this network;

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/75/0D/wKioL1YxuPTg0LR_AADm7ITIFSU549.jpg "title=" 6.png " alt= "Wkiol1yxuptg0lr_aadm7itifsu549.jpg"/>

But the state is invalid, we start it;

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/75/10/wKiom1YxuMWyriqHAAFkis9XS70252.jpg "title=" 7.png " alt= "Wkiom1yxumwyriqhaafkis9xs70252.jpg"/>

Can see that it has been started;

You can also join auto-start to avoid manually booting every time you boot

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/75/10/wKiom1YxuNDgtvV8AAGjATCwIDk405.jpg "title=" 8.png " alt= "Wkiom1yxundgtvv8aagjatcwidk405.jpg"/>

The Autostart position is already the Yes State;

Information on Br0 and virbr0 can also be seen through brctl show , which shows that our bridge and NAT networks are ready; Bridge Network configuration, only need to modify the network card configuration file, and then restart it;

The NAT network definition ends here;

    1. Configure the virtual machine XML file (Focus 2);

<interface type= ' network ' > <mac address= ' 52:54:00:62:5b:e6 '/> <source network= ' Kylin '/> < Model type= ' Virtio '/> <address type= ' pci ' domain= ' 0x0000 ' bus= ' 0x00 ' slot= ' 0x03 ' function= ' 0x0 '/> </interf Ace>

directory where the virtual machine configuration file is located:/etc/libvirt/qemu

The above two places are different from bridge mode, note that the source network should write the net name, instead of writing the NIC name as bridge;


This article is from the "LIJP" blog, make sure to keep this source http://jiapeng.blog.51cto.com/6706171/1707664

KVM (LIBIVRT) bridge and NAT mode coexistence

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.