Qemu

Instalación, configuración y uso:

  • ¿Cómo funciona la red en Qemu?

By using the option ‘-net user’ (default configuration if no ‘-net’ option is specified), QEMU uses a completely user mode network stack (you don't need root priviledge to use the virtual network). The virtual network configuration is the following:

         QEMU VLAN      <------>  Firewall/DHCP server <-----> Internet
                           |          (10.0.2.2)
                           |
                           ---->  DNS server (10.0.2.3)
                           |     
                           ---->  SMB server (10.0.2.4)

The QEMU VM behaves as if it was behind a firewall which blocks all incoming connections. You can use a DHCP client to automatically configure the network in the QEMU VM. The DHCP server assign addresses to the hosts starting from 10.0.2.15.

In order to check that the user mode network is working, you can ping the address 10.0.2.2 and verify that you got an address in the range 10.0.2.x from the QEMU virtual DHCP server.

Note that ping is not supported reliably to the internet as it would require root priviledges. It means you can only ping the local router (10.0.2.2).

When using the built-in TFTP server, the router is also the TFTP server.

When using the ‘-redir’ option, TCP or UDP connections can be redirected from the host to the guest. It allows for example to redirect X11, telnet or SSH connections.

Qemu en la red

Hay varias maneras para que un sistema virtual pueda acceder a la red en donde se encuentra el sistema real, aquí explicamos el que utiliza al sistema real (host) como bridge y usando dispositivos tun/tap.
Necesitamos:
En el kernel: deben estar activas estas opciones. Si no, habría que marcarlas y recompilar.
tun: "Network device support" -> "Universal TUN/TAP device driver support"
bridging: "Networking options" -> "802.1d Ethernet Bridging"
Aplicaciones: bridge-utils

  • 1- Cargar el módulo tun :

modprobe tun

  • 2- Dar de baja la interfaz, configurar el bridge, y agregar la interfaz al bridge:
ifconfig eth2 down
brctl addbr br0
ifconfig eth2 0.0.0.0 promisc up
ifconfig br0 192.168.1.54 netmask 255.255.255.0 broadcast 192.168.1.255 up
brctl stp br0 off
brctl setfd br0 1
brctl sethello br0 1
brctl addif br0 eth2
route add default gw 192.168.1.1
  • 3- Configuración para que el sistema virtual se una al bridge

Cuando la máquina virtual arranque, cargará un script que creará en el sistema host (el real) una interfaz tun que vinculará a la máquina virtual. Este script, /etc/qemu-ifup , si no existe hay que crearlo con el siguiente contenido:

#!/bin/sh
ifconfig $1 0.0.0.0 promisc up
brctl addif br0 $1

Luego debemos darle permisos de ejecución

chmod +x /etc/qemu-ifup

  • 4- Arrancando qemu

Debemos arrancar qemu pasandole como parámetro que ejecute el script qemu-ifup , utilizando además como parámetro para la red una interfaz tun/tap

Instalación del módulo para aceleración kqemu

# aptitude install qemu kqemu-source qemu-launcher qemuctl kqemu-common

Compilamos el modulo de kernel kqemu:

# aptitude install module-assistant
# module-assistant prepare
# module-assistant build kqemu-source
# module-assistant install kqemu-source
# depmod -a
# modprobe kqemu

Comprobamos que el módulo se encuentre cargado

ls -l /dev/kqemu

Para ver los módulos cargados:

lsmod

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License