Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 02-20-2006, 07:34 AM   #1
Registered: Sep 2005
Posts: 850

Rep: Reputation: 30
Qemu networking Again?!

Just want to find out how you everyone did it. Here's my setup. I setup qemu and my host OS is Ubuntu Linux while my Guest is Windows 2000.
I have two ethernet cards with the following IP addresses:

eth0 (Static IP provided by my ISP)
eth1 (local address)

I want to enable both of these connections on my guest OS. I tried to read infos from the forum but its just too complicated to a newbie like me.

Is it possible to use both of my connection in my guest OS? If so, how will I be able to achieve it? Secondly, is it possible to share files within the host and guest OS? I will need to do programming on the guest OS and transfer it to the server or at least in the host OS. But I can't seem to make it work. Third, can qemu guest os use the modem to dial-up? Everyones might be busy nowadays but I'll be grateful if someone will help me on this. Thanks.
Old 02-23-2006, 04:38 AM   #2
Registered: Dec 2003
Location: Roc City (Rochester-NY)
Distribution: Slacker 4 Life
Posts: 125

Rep: Reputation: 15
Okay, I'll go ahead and try for two out of three (maybe 2 1/2).

First. I'm assuming the eth0 and eth1 you mentioned are hostOS NICs. Getting the guest OS to use these is a breeze. You'll want to employ the "-net tap" option. The exact specifics of doing so are available in the man page however I will suggest a snippet that comes without even the slightest implication of usability.

qemu -net nic,macaddr=AA:AA:AA:AA:AA:AA -net tap,iface=tap0 \
     -net nic,macaddr=BB:BB:BB:BB:BB:BB -net tap,iface=tap1 qemu.img
Notice that your specifiying different MACs for the interface (otherwise they'll both default to the same MAC) and while it may not be necessary to name the interfaces, I've found it to be so in the past (that's troubleshooting that you don't want to do).
Now, from there just to give you a heads up, qemu will expect an executable file in the /etc directory named `qemu-ifup` to be present. If what you have explained here is the sum total of your Qemu networking, the contents of the qemu-ifup file may look something like this:

/sbin/ifconfig eth0 down
/sbin/ifconfig eth0 promisc up
/sbin/ifconfig tap0 promisc up
/sbin/ifconfig eth1 down
/sbin/ifconfig eth1 promisc up
/sbin/ifconfig tap1 promisc up

/sbin/brctl addbr br0
/sbin/brctl stp br0 off
/sbin/brctl setfd br0 1
/sbin/brctl sethello br0 1
/sbin/brctl addif br0 eth0
/sbin/brctl addif br0 tap0

/sbin/brctl addbr br1
/sbin/brctl stp br1 off
/sbin/brctl setfd br1 1
/sbin/brctl sethello br1 1
/sbin/brctl addif br1 eth1
/sbin/brctl addif br1 tap1

/sbin/ifconfig br0 up
/sbin/ifconfig br1 up
But wait there's more. So far we've discussed which command line flags to use as well as teh cretion and configuration of a file, BUT we also need to make adjustments to the kernel. You'll need to compile and load the kernel modules for briding (bridge.ko) and for the tun/tap interface (tun.ko).
We are almost there my friend (this sounds like a lot but it's really 15-20 minutes worth of "work"). There are many different ways to do this next part but I'll tell yo uwaht I think is best (since you asked). The tun module will create a dynamic device called /dev/net/tun which qemu will need access to to create the device. for this reason most people say run qemu sudoed 'cause root has access to everything. NOT A BIG FAN OF THIS IDEA. What I did instead was edit the /etc/udev/rules.d/udev.rules to dynamically assign ownership of /dev/net/tun to Owner:root Group:net. Then I just created the net group and added myself to it. Also, /etc/qemu.ifup should have the same ownership levels. Knock out these three things and you SHOULD (no warranties!!) have what it is you're looking for. It's really not as complicated as it looks (20 minutes TOPS).
For sharing files between guest and host OS' there of course is the -smb option which requires you to have smb installed on the host OS. Again, not my preferred option. What I do instead when moving files back and forth is just scp them. is the host os and you can scp (on a host only connection) from your guest os to your host OS no problem. Your max DTR is about 200k-300k so for larger files beprepared to wait a while BUT that has nothing to do with the scp option. If for some strange reason you prefer scp'ing from the host to the guest over vice versa, you can use the -redir option to allow connections in that direction.
That's my promised two out of three, now as far as the modem thing is concerned, who the heck still has a modem?? J/K I know a few thrid world countries still use them regularly (potable water first, then high speed internet). The bridging trick from the first answer should work once the modem is establed on ppp0 or whatever interface it's going to be. Now I know I said the other stuff isn't guarenteed to work, but this really isn't as this is something I've never actually done buffer (just shooting from the hip). Good luck.


P.S. Just to recap in case you got lost, you will need:
Qemu Flag: -net nic -net tap
Kernel Module: bridge.ko tun.ko
Software: brctl
File: /etc/qemu-ifup
Permissions: /etc/demu-ifup /dev/net/tun
Software: scp, WinSCP
2 1/2)
[everything from 1)]
Old 02-23-2006, 04:59 PM   #3
Registered: Sep 2005
Posts: 850

Original Poster
Rep: Reputation: 30
THanks man...I am grateful someone like you is patient enough to teach a newbie. I'll do this tomorrow and I'll give you updates.
Old 02-26-2006, 07:02 PM   #4
Registered: Sep 2005
Posts: 850

Original Poster
Rep: Reputation: 30

I did eveything as instructed. if I run:
qemu -net nic,macaddr=00:80:AD:85:A5:B0 -net tap,iface=tap0 \
-net nic,macaddr=00:01:03:03:FA:7E -net tap,iface=tap1 -hda /home/don/myos as instructed, I get

warning: could not open /dev/net/tun: no virtual network emulation
Could not initialize device 'tap'

I did everything you told me but it just can't seem to work.. Hope you can help me on this.
Old 02-27-2006, 03:36 AM   #5
Registered: Dec 2003
Location: Roc City (Rochester-NY)
Distribution: Slacker 4 Life
Posts: 125

Rep: Reputation: 15
Well, you've got a pretty specific error message there so I would say troubleshooting this shouldn't be too difficult.

"warning: could not open /dev/net/tun:" tells me that /dev/net/tun doesn't exist or your user doesn't have rights to the file. If /dev/net/tun doesn't exist then the tun.ko module isn't loading.

If it does exist and you just don't have permission to use it you have several options to rememdey the situation:

1) chmod/chown: This will fix it until next reboot.
2) sudo: This will have qemu run as root (NOT RECOMMENDED).
3) /etc/udev/rules.d/udev.rules && /etc/group: This is the fix that I recommended in my first post. It is permanent and more secure than option 2).

I'd be very surprised to hear that either of the situations above wasn't the root cause of your current issues but if so, post back and maybe someone a little bit brighter than myself can shed some light on the subject.
Old 02-27-2006, 06:24 AM   #6
Registered: Sep 2005
Posts: 850

Original Poster
Rep: Reputation: 30
How can I configure the tap device? I have tried configuring tun with modprobe tun and the command tunctl -u 'user' -t tun0. Does it mean I also have to issue a command:

tunctl -u 'user' -t tap0
tunctl -u 'user' -t tap1

I've also read in some howtos that you can issue a command:


Does the script you posted automatically configures the IP of the tap device?

Should I specify a different IP from my ethernet cards?

Okay, here's what I want to do:

1.) I want to retain my host IP with my guest OS. In such a way that I can ping other workstations as if I'm just running on my host OS.

2.) Configure file sharing from host os,guest os, and other networks with the use of samba.

Forgive me for my ignorance, I'm just a newbie and hope you can help me out on this one. Thanks. I'm glad you're helping me out.
Old 02-28-2006, 09:24 AM   #7
Registered: Sep 2005
Posts: 850

Original Poster
Rep: Reputation: 30
More on qemu and networking


I were able to activate my local IP as if it is connected on my guest OS. Thanks to you. Some comments, I wasn't able to get my exact address on my guest OS. It gave me another IP address ( though. My problem is that the IP did not reflect on my guest OS. Any ideas on how to activate it? I also can't ping (IP address of my host OS). I will try to use scp to transfer files from host to guest and vice versa. HOw about USB plug and play? Does qemu support for USB plug and play in Windows 2K? Thanks.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
qemu Networking, snapshot, disc swapping depam Linux - Software 0 02-18-2006 04:57 AM
QEMU networking bridge not working tisource Linux - Software 1 02-01-2006 01:29 PM
qemu--getting Samba networking going dgermann Linux - Networking 2 01-08-2006 02:47 PM
qemu paul_mat Linux - General 3 12-09-2005 12:48 PM
qemu: qemu stopped right after command exec bitpicker Linux - Software 1 03-04-2005 11:25 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:52 AM.

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