LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-08-2007, 03:27 PM   #1
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Rep: Reputation: 30
[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

Last edited by djgerbavore; 09-08-2007 at 03:29 PM.
 
Old 09-08-2007, 04:16 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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
 
Old 09-08-2007, 08:19 PM   #3
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Original Poster
Rep: Reputation: 30
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
 
Old 02-25-2009, 04:24 AM   #4
dubi
LQ Newbie
 
Registered: Jul 2005
Posts: 2

Rep: Reputation: 0
setting KVM guest IP

Did you solve your guest IP address with tthe bridging and how did you do it ?
 
Old 02-25-2009, 09:23 AM   #5
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Original Poster
Rep: Reputation: 30
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
 
Old 06-10-2009, 02:01 PM   #6
harsshal
Member
 
Registered: Jul 2006
Location: New York, NY
Distribution: redhat,ubuntu,RHEL,fedora,centOS
Posts: 105

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Linux Computer To Home Network StreetRacer0491 Linux - General 2 06-25-2006 05:48 PM
adding guest mode to x server? linuxmandrake Linux - Software 3 12-01-2005 07:19 AM
Adding more computer to my network djgerbavore Linux - Networking 5 08-16-2005 08:09 PM
Adding computer to network HadesThunder General 3 06-30-2004 03:14 AM
shutting down computer w/o KVM jonfa Linux - Networking 6 05-29-2001 05:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration