Welcome to the new location of Alien's Wiki, sharing a single dokuwiki install with the SlackDocs Wiki.

Welcome to Eric Hameleers (Alien BOB)'s Wiki pages.

If you want to support my work, please consider a small donation:

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
slackware:qemu [2007/11/16 09:19] – Talk about "modprobe kqemu" and udev. alienslackware:qemu [2008/09/01 11:04] (current) – Explain user mode networking alien
Line 150: Line 150:
  
 When you're done with installing from CD, do not forget to at least remove the ''-boot d'' commandline parameter, so that the virtual computer will start from it's hard drive instead of booting from the CDROM. When you're done with installing from CD, do not forget to at least remove the ''-boot d'' commandline parameter, so that the virtual computer will start from it's hard drive instead of booting from the CDROM.
 +
  
  
 ==== Networking your virtual machine ==== ==== Networking your virtual machine ====
  
-By default, QEMU uses a feature which is called //user-mode network//. QEMU will run an internal DHCP server that can assign an IP address to the virtual computer in case that is configured to use DHCP. The network range and gateway are hard-coded into QEMU but it allows your virtual machine to call out to your host machine and beyond. For user-mode networking, you don't need to configure anything on your host. will probably document user-mode networking sometime later, but for now I suggest you read [[slackware:vde | my article on VDE]] where I show how you can use [[http://vde.sourceforge.net/ | VDE (virtual distributed ethernet)]] in combination with dnsmasq to get a much enhanced network experience.+=== User mode networking === 
 + 
 +By default, QEMU uses a feature which is called //user-mode network//. QEMU will run an internal DHCP server that can assign an IP address to the virtual computer in case that is configured to use DHCP. The network range and gateway are hard-coded into QEMU but it allows your virtual machine to call out to your host machine and beyond. For user-mode networking, you don't need to configure anything on your host. \\ QEMU will enable user mode networking by default if you do not pass it any network parameters at all, or if you start it like this: <code> 
 +qemu -net nic -net user <other qemu parameters> 
 +</code> The network characteristics for user mode networking are as follows: 
 +|Gateway/DHCP/TFTP server: |10.0.2.2 |  
 +|DNS server:               |10.0.2.3 |  
 +|Samba server:             |10.0.2.4 |  
 +|Netmask:                  |255.255.255.0 |  
 +|Guest IP:                 |any address above 10.0.2.15 |  
 + 
 +There are limitations to the user mode networking due to the nature of the implementation. 
 + 
 +  * QEMU will act as a firewall between guest OS and the host computer, so that no network communication is possible from any host program to the guest OS. For instance, you will not be able to setup a ssh session to the guest. \\ To get around this dilemma, QEMU has a "''-redir''" optional argument which enables you to redirect certain ports on the host. Traffic destined for these ports will end up at the guest. For example, let's redirect port 22000 on the localhost to port 22 in the guest, in order to setup a ssh session into the guest: <code> 
 +qemu -redir tcp:22000::22 <other qemu options> 
 +</code> If the guest is running a SSH server at port 22, then it is possible to connect a ssh session on the host to the guest's SSH server like this: <code> 
 +ssh -p 22000 localhost 
 +</code> 
 +  * There is actually no proper network connection between the guest and the world outside the Virtual Machine. QEMU will intercept TCP and UDP packets from the guest, dissect them and pass their data payload on to destination computers as if QEMU itself were sending the data. In reverse, QEMU will grab the return traffic and re-assemble TCP and UDP packets for the guest OS. This private implementation of a network stack in QEMU results in TCP and UDP traffic working transparently for the guest OS, but ICMP packets (ping, traceroute for instance) will not be able to pass the boundary. This should not be a concern to you. However lots of people will run a ''ping'' as their first test of the network in QEMU's guest OS and are led to believe that the guest's network is not functional because they do not see a ping response. 
 + 
 +=== Connecting multiple guests to a VLAN === 
 + 
 +QEMU knows the concept of VLAN's. Think of a VLAN as a virtual switch, emulated by QEMU, to which you connect your guest. You typically use a vlan to connect multiple guests into a virtual network. By default, QEMU assigns //vlan=0// to your guest if you do not specify a vlan number. So, the following two commands are basically the same: <code> 
 +qemu -net nic,vlan=0 -net user <other qemu parameters> 
 +qemu <other qemu parameters> 
 +</code> In addition, I advise you to assign your guest OS's network card a fixed MAC address. If you do not assign a MAC address, QEMU will randomly pick a value and many OS-es will not like that (for instance, Slackware's UDEV will create new interfaces eth1, eth2, ... everytime it finds a new MAC address for your interface card at boot). You can assign a MAC address as follows (you can make up any value that is valid, i.e. 6 bytes separated by colons, in hexadecimal representation): <code> 
 +qemu -net nic,vlan=0,macaddr=51:45:4d:55:00:01 
 +</code> 
 +When several guests are connected using the same vlan number, any network packet that is sent by one of the guests, will be distributed over the vlan to all of the other guests. This allows for transparent network communication between the guests.\\ **NOTE** this has nothing to do with the ability of the guests to connect to the world outside QEMU! 
 + 
 +=== Virtual Distributed Ethernet (VDE) === 
 + 
 +To overcome the limitations of //user mode networking//, I suggest you read [[slackware:vde | my article on VDE]] where I show how you can use [[http://vde.sourceforge.net/ | VDE (virtual distributed ethernet)]] in combination with dnsmasq to get a much enhanced network experience. Using VDE, you will be able to make your QEMU guest fully accessible to programs running on your host, and if you bridge your network connections, you can make your Virtual Machines appear on your LAN as if they were real machines.
  
 ==== Advanced topics ==== ==== Advanced topics ====
 Hardware virtualization with QEMU ()
SlackDocs