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