You are not logged in.

#1 2010-08-30 06:00:05

brandnewmath
Member
Registered: 2010-02-01
Posts: 14

Another KVM Bridged Networking Thread

Hello everyone,

I'm having some trouble getting KVM bridged networking to work following the instructions here:

http://wiki.archlinux.org/index.php/Qem … _with_QEMU

The VM I set up to test is running CentOS 5.5 and is unable to get an IP address. Here's what I run before attempting to start it:

Turn off wireless:

% sudo netcfg -a

Running 'ip link sh' shows that wlan0 is down after this.

Allow forwarding and adjust iptables:

% su -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
% sudo iptables -P FORWARD ACCEPT
% cd /proc/sys/net/bridge
% su -c 'for f in bridge-nf-*; do echo 0 > $f; done'

Start the bridge:

% sudo brctl addbr br0
% sudo brctl addif br0 eth0
% sudo ip link set up dev eth0
% sudo dhcpcd br0

Occasionally br0 times out and I have to run dhcpcd twice, but it comes up eventually. I can ping out to the Internet at this point.

I believe that when I start my VM at this point tap networking is supposed to work, but obviously I am doing something wrong. I have tried starting it both as root and as my regular user. For reference, here is my run-qemu script:

#!/bin/sh

USERID=`whoami`
IFACE=`sudo tunctl -b -u $USERID`
MAC=`echo -n "FF:FF"; for n in 1 2 3 4; do echo -n ":" && cat /dev/urandom | tr -dc '0-9A-F' | head -c 2; done`

qemu-kvm -daemonize -net nic,macaddr="${MAC}" -net tap,ifname="${IFACE}" \
-k en-us -m 512 -smp 2 $*

sudo tunctl -d $IFACE &> /dev/null

...and my /etc/qemu-ifup script:

#!/bin/sh

echo "Executing /etc/qemu-ifup"
echo "Bringing up $1 for bridged mode..."
sudo ip link set dev $1 up
echo "Adding $1 to br0..."
sudo /usr/sbin/brctl addif br0 $1
sleep 2

I originally used 'sudo /sbin/ifconfig $1 0.0.0.0 promisc up' in place of 'ip link set ...' but without any different results. I have also tried a completely empty iptables ruleset, with all chains set to ALLOW, just in case; no dice.

Does anyone have any ideas? Thanks for any help you can provide, I appreciate your time.


--
James

Offline

#2 2010-08-31 15:55:11

Sin.citadel
Member
Registered: 2008-01-22
Posts: 267

Re: Another KVM Bridged Networking Thread

try setting a static ip first for both br0 and the qemu tap interface, and see if the host and VM are able to communicate properly, if they cant, dont add the tap interface to br0, assign the tap interface an ip, and see if you are able to communicate with the VM.

Offline

Board footer

Powered by FluxBB