KVM/qemu bridging network settings

Source: Internet
Author: User

There are two methods to configure the KVM network. First, the default mode is usermode networking. packets are transmitted through the host interface in Nat mode. Second, with bridged networking, external machines can be directly connected to virtual machines, just like connecting to your host. I will focus on the bridging method and pass the test on ubuntu10.10. Mainly refer to the https://help.ubuntu.com/community/KVM/Networking.

First, user mode
Virtual machines can use network services, but other machines in the LAN, including the host machine, cannot connect to it. For example, it can browse Web pages, but external machines cannot access the Web servers deployed in it.
By default, the virtual machine obtains the IP address space 10.0.2.0/24, and the Host IP address is 10.0.2.2 for Virtual Machine access. You can SSH to the host (10.0.2.2) and use SCP to copy files.

Second, Bridge Mode
This mode allows a virtual machine to have a network just like an independent host. This mode requires Nic support. Generally, wired network cards are supported, and most wireless network cards are not supported (for example, ipw3945, wireless network card on my t400 )!

A) create a Network Bridge on the host
1) install bridge-utils
Sudo apt-Get install bridge-utils
2) We will change the network settings and stop the network first.
Sudo invoke-rc.d networking stop
If it is set with remote connection, we need to complete the subsequent settings, and then restart the network sudo invoke-rc.d networking restart, if there is a step in the middle of the error, you will not be able to connect ..
3) Modify/etc/Network/interfaces and use the following replace directly.
A) static IP Mode
Auto Lo
Iface lo Inet loopback

Auto eth0
Iface eth0 Inet Manual

Auto br0
Iface br0 Inet static
Address 192.168.0.10
Network 192.168.0.0
Netmask 255.255.255.0
Broadcast 192.168.0.255
Gateway 192.168.0.1
Bridge_ports eth0
Bridge_stp off
Bridge_fd 0
Bridge_maxwait 0

B) DHCP Mode
Auto Lo
Iface lo Inet loopback

Auto eth0
Iface eth0 Inet Manual

Auto br0
Iface br0 Inet DHCP
Bridge_ports eth0
Bridge_stp off
Bridge_fd 0
Bridge_maxwait 0
4) restart the network
Sudo/etc/init. d/networking restart

B) randomly generate a KVM MAC address.
Macaddr = "52: 54: $ (dd If =/dev/urandom COUNT = 1 2>/dev/null | md5sum | SED's/^ /(.. /)/(.. /)/(.. /)/(.. /). * $ // 1:/2:/3:/4/') "; echo $ macaddr
You can also specify a MAC address, but note that the first byte must be an even number, such as or 52, and cannot be an odd number (01). Otherwise, unexpected problems may occur. Because the odd number is retained for multicasting. For example, KVM can receive ARP packets and reply, but these replies may confuse other machines. This is an Ethernet rule, not a KVM problem.
I directly set the NIC address to macaddr = "32: 32: 32: 32: 32: 32: 32"

C) Change the previously installed Virtual Machine network to the bridging mode or install a new virtual machine to use the bridging network.
I wrote a script file.
# Start KVM. WINXP
Userid = 'whoam'
Macaddr = "32: 32: 32: 32: 32: 32: 32"
Model = e1000e
Iface = 'sudo tunctl-B-u $ userid'
KVM-net Nic, VLAN = 0, macaddr = $ macaddr-net tap, VLAN = 0, ifname = $ iface $ @
Sudo tunctl-d $ iface
# End KVM. WINXP
Run the following command to install WINXP using the ISO file:
Sudo./KVM. Bridge-M 512-hda WINXP. IMG-CDROM/home/software/zh-hans_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74070.iso-boot d
Run the following command to run the installed virtual machine:
Sudo./KVM. Bridge-M 512-hda WINXP. IMG-boot C

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.