9

I'm trying to emulate a raspberry pi on my ubuntu 13.04. I installed qemu and it works well except for the network.

I followed this procedure. On the virtual machine, the file /etc/network/interface looks like this

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static

address 192.168.20.106  # your IP  
gateway 192.168.20.1     # IP of the Router
netmask 255.255.255.0   # Network mask

I launch qemu like this sudo qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -append "root=/dev/sda2" -hda 2013-09-25-wheezy-raspbian.img -kernel kernel-qemu -redir tcp:5022::22.

On ubuntu, when I do a ifconfig, I have this result :

br0   Link encap:Ethernet  HWaddr 8e:0f:b1:ad:1c:18  
      inet adr:10.10.10.2  Bcast:10.255.255.255  Masque:255.0.0.0
      adr inet6: fe80::8c0f:b1ff:fead:1c18/64 Scope:Lien
      UP BROADCAST MULTICAST  MTU:1500  Metric:1
      Packets reçus:8 erreurs:0 :8 overruns:0 frame:0
      TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 lg file transmission:0 
      Octets reçus:792 (792.0 B) Octets transmis:5092 (5.0 KB)

eth0  Link encap:Ethernet  HWaddr 90:2b:34:39:b4:1d  
      UP BROADCAST MULTICAST  MTU:1500  Metric:1
      Packets reçus:0 erreurs:0 :0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 lg file transmission:1000 
      Octets reçus:0 (0.0 B) Octets transmis:0 (0.0 B)

lo    Link encap:Boucle locale  
      inet adr:127.0.0.1  Masque:255.0.0.0
      adr inet6: ::1/128 Scope:Hôte
      UP LOOPBACK RUNNING  MTU:65536  Metric:1
      Packets reçus:12770 erreurs:0 :0 overruns:0 frame:0
      TX packets:12770 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 lg file transmission:0 
      Octets reçus:2121321 (2.1 MB) Octets transmis:2121321 (2.1 MB)

wlan1 Link encap:Ethernet  HWaddr ac:f1:df:79:01:80  
      inet adr:192.168.20.106  Bcast:192.168.20.255  Masque:255.255.255.0
      adr inet6: fe80::aef1:dfff:fe79:180/64 Scope:Lien
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      Packets reçus:5283 erreurs:0 :48 overruns:0 frame:0
      TX packets:5252 errors:0 dropped:5 overruns:0 carrier:0
      collisions:0 lg file transmission:1000 
      Octets reçus:2806386 (2.8 MB) Octets transmis:1461531 (1.4 MB)

on the virtual machine, ping 192.168.20.106 works because it is the local address but ping 192.168.20.1 does not works. I also tried to set a different address for real and virtual machine.

Whan can I do?

  • Documenting how to make this work somewhere would be brilliant. I'm trying to get the same thing working with a more recent QEMU and Raspbian distro, with no joy so far. Sadly, the link above is dead (and not in the wayback machine) and newer versions of QEMU have deprecated the -redir option. – Tom Sep 7 '16 at 12:06
5

It would be nice to see the output of ifconfig on your virtual machine too.

According to http://en.wikibooks.org/wiki/QEMU/Networking with the options you've specified you should get NAT with a virtual DHCP server, not direct bridging onto your local IP network, so your hard-coded IP addresses probably wouldn't work. Try:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp

reboot or use ifdown/ifup to reconfigure eth0 and see if it finds the virtual DHCP server. ifconfig and route -n should tell you if it worked - you'll have a local IP and a gateway route.

Assuming it did work you should be able to ssh from your host to your VM using:

ssh -p 5022 localhost

because that port is setup by the -redir clause in your command-line.

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.