You are not logged in.

#1 2013-06-04 11:32:58

Torxed
Member
Registered: 2013-01-10
Posts: 202

Bridging a qemu machine, can't communicate externally or internally

Ok i've bashed my head against the wall the entire day.
What am I doing wrong, I've just re-installed a new host to run the kvm-machine and this is the setup:

Starting qemu with: qemu-system-x86_64 -enable-kvm -cdrom archlinux-2013.06.01-dual.iso -boot d /dev/mapper/loop0p1 -net nic,model=rtl8139 -net tap,ifname=tap0

My up-script:

#!/bin/sh

echo "Executing /etc/qemu-ifup"

echo "Creating bridge"
sudo brctl addbr br0
brctl stp br0 off
brctl setfd br0 1

ip tuntap add dev $1 mode tap user doxid group kvm

sudo ip link set $1 up promisc on
sudo ip link set eth0 up promisc on

sudo brctl addif br0 $1
sudo brctl addif br0 eth0

sudo ip link set up dev br0
sudo ip link set up dev $1

sleep 2

I've manually prepared eth0 with 10.0.2.1/24 without a network connection externally, at the moment my internet is on my WiFi and gives me a completely different challenge so for now, i just want to be able to SSH into my virtual machine.

when starting the virtual machine, i do:
ip addr add 10.0.2.15/24 dev ens3

And my ip addr says:

[root@host ~]# ip addr
4: eth0: <NO-CARRIER,BROADCAST,MULTICAST,PROMISC,UP> mtu 1500 qdisc pfifo_fast master br0 state DOWN qlen 1000
    link/ether d0:67:e5:4c:e2:09 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.1/24 scope global eth0
       valid_lft forever preferred_lft forever
18: tap0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UNKNOWN qlen 500
    link/ether aa:27:85:8b:ff:b2 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::a827:85ff:fe8b:ffb2/64 scope link 
       valid_lft forever preferred_lft forever
19: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    link/ether aa:27:85:8b:ff:b2 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::a827:85ff:fe8b:ffb2/64 scope link 
       valid_lft forever preferred_lft forever

But i still can't ping the hosts.
I can ping "me self" from both machines but can't ping across the bridge.

Also, i've done both.

iptables -A FORWARD -j ACCEPT
iptables -t nat -A POSTROUTING -s 10.0.2.0/24 -o br0 -j MASQUERADE    (and tried for eth0, tap0 and br0 just because i'm crying of frustration of calling myself a good network technician and hoping to get lucky without thinking)..

Oh and ofc: sysctl net.ipv4.ip_forward=1


Still nothing. "Destination Host Unreacable"

Offline

#2 2013-06-04 12:28:51

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: Bridging a qemu machine, can't communicate externally or internally

You should be seeing an ip address for br0
I'm not sure as I set my bridge up at boot and run dhcpcd against it, but I think that you need to do an 'ip addr add' for the br0 device.

This may be it:

ip addr add 10.0.2.15/24 dev ens3

But the ens3 confuses me.


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#3 2013-06-04 12:42:51

Torxed
Member
Registered: 2013-01-10
Posts: 202

Re: Bridging a qemu machine, can't communicate externally or internally

skanky wrote:

You should be seeing an ip address for br0
I'm not sure as I set my bridge up at boot and run dhcpcd against it, but I think that you need to do an 'ip addr add' for the br0 device.

This may be it:

ip addr add 10.0.2.15/24 dev ens3

But the ens3 confuses me.

That might be it, will try it out in a bit (about to jump on a plane home).
Yea sorry, i can see how ens3 might be confusing.. It's the NIC of the virtual host.



Clairification:

          eth0   \
           br0 ---\-- == Physical machine.
  ens3 --> tap0   /


ens3 == Virtual machine

And they go something like:

Last edited by Torxed (2013-06-04 12:43:16)

Offline

#4 2013-06-04 13:20:57

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: Bridging a qemu machine, can't communicate externally or internally

Torxed wrote:

That might be it, will try it out in a bit (about to jump on a plane home).
Yea sorry, i can see how ens3 might be confusing.. It's the NIC of the virtual host.

Ah, I see. Again, my virtual machines get their ip addresses from dhcp.
I would have thought though, that you'd set that in the machine itself?

The only thing I set up "externally" is the MAC address.

I can try and gather the whole lot up, but they're a bit spread out in functions and service files.
I think I got most of it from a post on this forum.

EDIT: I also don't use up and down scripts. I think (vague memory) that I had trouble getting them to work. You have to specifiy no script on the qemu command line.

-net tap,ifname=tap0,script=no,downscript=no

Last edited by skanky (2013-06-04 13:26:53)


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

Board footer

Powered by FluxBB