QEMU and networking

Eric S. Johansson esj at harvee.org
Wed Nov 9 04:06:11 UTC 2005


Steven Heimann wrote:
> Has anyone had any success getting tun0 networking working with Ubuntu
> 5.10 and QEMU.
> 
> I have compiled QEMU from source because I wanted Win2k which needs a
> flag not available on the standard Ubuntu version (-win2k-hack).  I have
> installed uml-utilities which was was needed to configure the tun0
> device.  I have configured tun0 chmod 666 so it would be writable.
> 
> I have (after much stuffing around) managed to get a device tun0 on my
> host with ip 192.168.12.2 and an ethernet ip of 192.168.12.3 on the
> Win2k guest.
> 
> However, they will not talk to each other.  I can not ping the host from
> the guest or vica versa.
> 
> I need to use tun type networking because I need a particular program on
> the guest to be able to talk to the rest of the network.  This program
> is not using http/port 80 so I can not use user-net.
> 
> Any suggestions?

yup, been there got confused by that.

guest OS to host OS vacations happens over its own private network. 
Check /etc/qemu-ifup the default sets the host side interface to 
172.20.0.1  the guest should be 172.20.0.XX.  I use .10.

with this configuration, guest and host should be able to talk.  Once 
they can talk and then you can start thinking about the next stage which 
is routing.

routing is a bit strange but you need to put a route on the default 
route device (firewall, router) or every single device that will speak 
to the guest OS.  You need to route from your local network to the guest 
OS network using the host machine as the gateway.  Then the return route 
will go via the default route device and back to the guest OS via the 
host OS.

yes, it's confusing.  I wish I had the time to draw an ASCII Art 
diagram.  maybe this rough diagram will serve.

G === H --- A --- D --- H === G

G = guest OS.  On network 172.20.0.0/24
H = host OS.  Has two interfaces. one on 172.20.0.0/24 and the other on 
the local network.
A = application machine on local network
D = default route device on local network

yes, this kind of funky routing will work but it can cause problems. 
Debug using TCP dump looking at source and destination addresses for 
packets.

the reason you cannot put the TUN device on the local network is because 
the host OS will not know how to route the packets.  Yes, it's a real 
pain in the butt.  yes, colinux does a bridging trick with winpcap which 
we should be able to use here but... sometimes open-source projects 
don't know how to share information with each other.

---eric





More information about the ubuntu-users mailing list