2011年2月6日星期日

Setup network interface for Qemulator under Ubuntu 10.04

1. Create a script file:

#! /bin/bash

# create a bridge
brctl addbr br0

# enable promiscuous mode for the physical network interface X
# Here, the example is eth0
ifconfig eth0 0.0.0.0 promisc

# add the network interface X to the bridge
brctl addif br0 eth0

# get IP for the bridge
# for static IP, add this line (xxx.xxx.xxx.xxx is the IP you want to use):
# ifconfig br0 xxx.xxx.xxx.xxx
# for DHCP, add this line:
# dhclient br0
dhclient br0

# set read-write mode
chmod 0666 /dev/net/tun

2. Start qemulator:
sudo qemulator [enter]

3. Setup netwrok interface for a virtual machine:

3.1 Add netwrok card.
Suppose you want to add two network cards (one of them is rtl8139 and another is i82557b), then set the value of "addition custom qemu options" to:
-net,nic,vlan=1,model=rtl8139 -net,nic,vlan=2,model=i82557b

3.2 Configure network setting.
Under "Network" tab, select "Custom setup". Then add "Network cards":
Network Type = Open a TUN/TAP interface
MAC address = [empty]
VLAN = [lan number. For example, according to the above setting, 1 = rtl8139, 2 = i82557b]
TUN/TAP configuration script = [empty]
Name of network interface = [any string]

Then, run the script to setup bridge interface firstly and then run qemulator to start the virtual machine.

沒有留言: