LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   [KVM] adding guest computer to the network (https://www.linuxquestions.org/questions/linux-networking-3/%5Bkvm%5D-adding-guest-computer-to-the-network-583217/)

djgerbavore 09-08-2007 03:27 PM

[KVM] adding guest computer to the network
 
I'm trying to connect the guest to the same network as the host's. I'm using the KVM/Qemu.

kernel is 2.6.23-rc5
kvm/qemu userspace version is 36 (which is the newest version)

when i start the guest machine via a little script i wrote:
Code:

#!/bin/sh
# start up for kvm and qem
SIZE=512
BASE_NAME=win32xp
QEMU_BIN=/usr/local/bin/qemu-system-x86_64
KVM_DIR=/mnt/kvm/
WIN_QCOW=/mnt/kvm/$BASE_NAME.qcow

cd $KVM_DIR
$QEMU_BIN -net nic -net user -localtime -m 512 -soundhw all -usb -hda $WIN_QCOW 1>$BASE_NAME.log 2>$BASE_NAME.err

every works fine, I even have internet. However the ip address that is getting set is 10.0.2.1. Which isn't in the subnet i want. My network is of 192.168.1.XXX. I was wondering if there is a way to set the ip address on startup, so i'm on the same subnet as the host.

I tried goggling and researching but nothing seem to work.

http://fabrice.bellard.free.fr/qemu/qemu-doc.html#SEC25 talks about networking emulation options in qemu, but it doesn't say how to configure the ip address on startup or anything like that.

If anyone has any insight or tips on how to get this to work that would be very helpful.

Let me know if you need any other info.

Thanks,

djgerbavor3

acid_kewpie 09-08-2007 04:16 PM

sounds like it's doing natting and routing, not bridging, which is what you seem to be asking for. check here for bridging in kvm... http://www.watzmann.net/blog/index.p...vm_and_libvirt http://kabru.eecs.umich.edu/bin/view/Main/KvmSetup

djgerbavore 09-08-2007 08:19 PM

acid_kewpie that is what I was looking for...Thanks. I thought I need bridging but wasn't sure.
However I'm having trouble configuring the bridge, and I don't know how to debug it.

Basically I created TUN/TAP device called tap0 with tunctl command.

Then I need to create a bridge via:
Code:

sudo /usr/sbin/brctl addbr kvm-brigde
Then I do: (where eth0 is my wired ethernet card.
Code:

sudo /sbin/ifconfig tap0 0.0.0.0 up
sudo /sbin/ifconfig eth0 0.0.0.0 up

Then add the two interfaces to the bridge
Code:

sudo /usr/sbin/brctl addif kvm-bridge tap0
sudo /usr/sbin/brctl addif kvm-bridge eth0

Everything looks good:
Code:

bash-3.2$ /usr/sbin/brctl show
bridge name    bridge id              STP enabled    interfaces
kvm-bridge              8000.0019db6d7272      no              eth0
                                                        tap0
virbr0          8000.000000000000      no

So i decide to get a new ip address for eth0 via:
Code:

bash-3.2$ sudo /etc/init.d/network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:
Determining IP information for eth0... done.
                                                          [  OK  ]

Which is a fedora core script. so i check to see if I have a new ip address:
Code:

eth0      Link encap:Ethernet  HWaddr 00:19:DB:6D:72:72
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::219:dbff:fe6d:7272/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:120119 errors:0 dropped:0 overruns:0 frame:0
          TX packets:105029 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:78984845 (75.3 MiB)  TX bytes:2

But when I ping my router I get this:
Code:

bash-3.2$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
From 192.168.1.100 icmp_seq=1 Destination Host Unreachable
From 192.168.1.100 icmp_seq=4 Destination Host Unreachable
From 192.168.1.100 icmp_seq=5 Destination Host Unreachable

I even ran tcpdump on eth0 and nothing show up when I'm pinging.

So I'm alittle confused how to debug this. my route looks like this:
Code:

bash-3.2$ /sbin/route
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.1.0    *              255.255.255.0  U    0      0        0 eth0
192.168.122.0  *              255.255.255.0  U    0      0        0 virbr0
169.254.0.0    *              255.255.0.0    U    0      0        0 eth0
default        192.168.1.1    0.0.0.0        UG    0      0        0 eth0

Is there something I'm missing in order to start the bridge?

To get my internet connection back I remove the eth0 from the brigde:
Code:

sudo /usr/sbin/brctl delif kvm-bridge eth0

Thanks,

djgerbavor3

dubi 02-25-2009 04:24 AM

setting KVM guest IP
 
Did you solve your guest IP address with tthe bridging and how did you do it ?

djgerbavore 02-25-2009 09:23 AM

Unfortunately, I never got this to work. Are you having the same issue? What commands are you using? If we both are having the same problem we might be able to figure it out.

thanks,

djgerbavore

harsshal 06-10-2009 02:01 PM

Even I am having same problem:scratch:. I tried bridge, I tried editing XML file but no success. Please post here if you have solved it.


All times are GMT -5. The time now is 02:50 PM.