Configure a bridge network for Qemu in Ubuntu

Source: Internet
Author: User

In the qemu network, a bridge network is required to connect the Virtual Machine Nic to the real physical network. Generally, the qemu bridging network is implemented by using the tap virtual network card. For details, refer to the relevant documentation. Here only describes how to configure the bridging network:

 

1. Install the tap-related tools

Sudo apt-Get install UML-utilities

2. Configure the bridge

Sudo VI/etc/Network/interfaces

Modify to the following:

Auto lo <br/> iface lo Inet loopback <br/> auto br0 <br/> iface br0 Inet static <br/> bridge_ports eth0 tap0 <br/> address 10.0.7.6 <br/> netmask 255.255.255.0.0 <br/> network 10.0.0.0 <br/> broadcast 10.0.255.255 <br/> gateway 10.0.0.2

3. Create a tap network Startup Script

Sudo vi/etc/qemu-ifup

Create a qemu-IFUP script and write the following content:

#! /Bin/sh <br/> # set-x <br/> switch = br0 <br/> if [-n "$1"]; then <br/>/usr/bin/sudo/usr/sbin/tunctl-u 'whoam'-t $1 <br/>/usr/bin/sudo/sbin/ip link set $1 up <br/> sleep 0.5 s <br/>/usr/bin/sudo/usr/sbin/brctl addif $ switch $1 <br/> exit 0 <br/> else <br/> echo "Error: no interface specified "<br/> exit 1 <br/> fi

4. Create an empty tap network shutdown script (to avoid a warning when the VM is shut down)

Sudo vi/etc/qemu-ifdown

The content is as follows:

#! /Bin/sh

After the configuration is complete, run the following command to start qemu and directly use the bridge without other configuration (filename is the image file path ): Sudo qemu-system-x86_64-hda $ filename-net Nic, model = e1000, macaddr = de: ad: Be: EF: 3E: 10 Net tap-M 512-VNC 10.60.1.124: 10

 

Related Article

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.