Qemu & Bridge

From wiki.linuxonlinehelp.de
Jump to: navigation, search

Enable virtual sharing of a Network Interface Card

DO NOT CHANGE OVER SSH CAUSE YOU CAN BE LOCKED OUT!

(called "bridge network") edit /etc/network/interfaces ans set:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto br0
iface br0 inet static
address 192.168.178.XXX  <-- your PC IP
netmask 255.255.255.0
gateway 192.168.178.1
bridge_ports eth0
bridge_fd 5
bridge stp no

QEMU Scripts IFUP / DOWN MISSED BY DEFAULT SETUP !!

(on a default debian squeeze setup this scripts are not available)

Create with nano..

sudo nano /etc/qemu-ifup

Insert this text..

#!/bin/sh

switch=$(/sbin/ip route list | awk '/^default / { print $5 }')
/sbin/ifconfig $1 0.0.0.0 up
/usr/sbin/brctl addif ${switch} $1

Create with nano...

sudo nano /etc/qemu-ifdown

Insert this text..

#!/bin/sh

# NOTE: This script is intended to run in conjunction with qemu-ifup
#       which uses the same logic to find your bridge/switch

switch=$(/sbin/ip route list | awk '/^default / { print $5 }')

/usr/sbin/brctl delif $switch $1
/sbin/ifconfig $1 0.0.0.0 down