2

Objective: I would like to install several virtual (emulated) Raspberry machines on the laptop, connect them to each other and to the laptop. Afterwards I would like to send tcp packets from virtual machines to mysql on host localhost (and back to machines).

Achieved: On Ubuntu 14.04 I virtualized Raspberry through mounting Raspbian on Qemu (i.e. running virtual machine) source: http://www.soslug.org/wiki/raspberry_pi_emulation.

I run the machine through entering qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -append "root=/dev/sda2 panic=1" -hda Occidentalis_v02.img & (note: Occidentalis is an alternative version of Raspbian)

so from different folders I am running different instances of QEMU.

MySQL is running.

Problem: Each instance has the same IP address 10.0.2.15, and can't ping the host IP or reverse. enter image description here

Assumption: I assume that I need to create a new connection in the host computer (such as eth0, lo, br0, or etc.). I saw something regarding port forwarding, but I am not sure that its exactly what I need, because I would like to have constant connection between machines and host's "localhost".

If anyone could help me out:

  1. how to connect such a connection on host.
  2. how to configure raspbian machine (configuration of IP etc)
  3. how to connect machines to each other?
  4. anything else to establish this network scenario.

Would highly appreciate any help.

Thanks,

1

Try this:

  1. Install tunctl & libvirt

    tunctl — create and manage persistent TUN/TAP interfaces

    sudo apt-get install uml-utilities

    libvirt — visualization management system. This will automatically setup a DHCP server and a bridge(virbr0).[ if you already have DHCP/bridge, you may skip this and make use of vmnet1/vmnet8 ]

    sudo apt-get install qemu-kvm libvirt-bin

root@unknown:~# ifconfig virbr0 
virbr0    Link encap:Ethernet  HWaddr 62:80:41:0f:0b:56
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:224 errors:0 dropped:0 overruns:0 frame:0
          TX packets:252 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:15728 (15.7 KB)  TX bytes:18926 (18.9 KB)
  1. Create tap interface and bind with virbr0
root@unknown:~# tunctl -t tap0 && ifconfig tap0 up  
root@unknown:~# tunctl -t tap1 && ifconfig tap1 up 
root@unknown:~# brctl addif virbr0 tap0 
root@unknown:~# brctl addif virbr0 tap1

root@unknown:~# brctl show
bridge name   bridge id       STP enabled interfaces
virbr0        8000.6280410f0b56   yes     eth0
                                          tap0
                                          tap1
  1. Bring up your instances:

    Instance-1

    qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda 2014-09-09-wheezy-raspbian.img -net nic,macaddr=00:16:3e:00:00:01 -net tap,ifname=tap0,script=no,downscript=no
    

    Instance-2

    qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda 2014-09-09-wheezy-raspbian_1.img -net nic,macaddr=00:16:3e:00:00:02 -net tap,ifname=tap1,script=no,downscript=no
    

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.