[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Qemu: network connection host => guest



Hi,

Well... here it goes...  I'm citing "by memory", but I'm confident I
remember all the steps.

1 -> Get tun working.  For this you have to load kernel module "tun.ko".
If you have a standard kernel, probably it's already compiled and you
just have to "modprobe tun" (as root).

2 -> Now, you have to configure a tun-based virtual netwrok on the host.
QEMU does that for you.  Just create a file "/etc/ifup-qemu" containing
"/sbin/ifup $0 127.20.0.1" and "chmod 755 /sbin/ifup"

3 -> Then you may start QEMU (version 8.0, version 7.x doesn't work this
way) with "qemu -net nic -net tap image-file.qemu"

4 -> After booting, you have to configure network on the client with
"/sbin/ifconfig eth0 172.20.0.2"

5 -> And it's done...  :-)

Note: I'm assuming you're working as root.  Device "/dev/tun" does not
have write permission to "others"... to have root as a non-root user,
you have to

1 -> Add the user to the suduers

2 -> Create a small script "qemu.sh" with (and chmod it 755)
-------------------------------------------------------
#!/bin/bash
# The next two lines are needed only if you want to
# load the QEMU accelerating module
#KQEMU_MOD=$HOME/Kernel-Modules/kqemu.ko
#lsmod | fgrep -q kqemu || sudo insmod $KQEMU_MOD
sudo chmod 666 /dev/net/tun
qemu -net nic -net tap qemu-disk-image.img
-------------------------------------------------------

3 -> Change the file "/etc/qemu-ifup" to
-------------------------------------------------------
#!/bin/bash
sudo /sbin/ifup $0 127.20.0.1
-------------------------------------------------------

And it should work for a non-root user (if he's in sudoers).
It's also possible to have it running for non-sudoers too, but it's a
bit more tricky.  I guess you don't need that... do you?

Hope this helps.  If you can't get it working, let me know.

Regards,
João Lourenço

On Thu, 2006-05-18 at 11:41 -0500, anoop aryal wrote:
> On Friday 12 May 2006 16:41, Joao Lourenco wrote:
> > Hi,
> >
> > Yes.  It is possible to have a network connection between the host
> and
> > the virtual (QEMU) machine.  The way you setup the connection
> depends on
> > your host OS: Window$ or Linux.  If you search the web for a while
> > you'll find some suggestions for both OS.  If you can't make it
> work,
> > let me know, and I'll try to prepare a small HOWTO for you (for a
> Linux
> > based host, I don't use Win#@$).
> 
> i've tried some of the howtos and it seems to fail at the point where
> they 
> tell me to setup a tun device on the host OS. i did read something
> about 
> tun/tap being broken but since i don't know tun/tap at all, can't tell
> if 
> it's me doing something wrong.
> 
> i've been trying to setup hurd as a guest OS inside linux (using
> qemu). i've 
> got hurd running. just couldn't figure out the tun setup on linux to
> get a 
> network going between the host and the guest OS.
> 
> if you could post a short howto (for tun or any other ways to network
> the 
> host/guest OSs), i'd appreciate it much. if it makes things easier you
> can 
> assume both the host and the guest OSs being linux.
> 
-- 
Joao Lourenco                  Tels: (+351) 212 948 536
Dep. Informatica                     (+351) 212 948 300
FCT / Univ. Nova de Lisboa      Ext: 10740
Quinta da Torre                 Fax: (+351) 212 948 541
P-2829-516 CAPARICA   http://www-asc.di.fct.unl.pt/~jml



Reply to: