3

I created a virtual Raspbian environment on Qemu as given here

But I am unable to connect to the Internet from the Raspbian although I am connected on the host machine ( Ubuntu 12.04 ) enter image description here

You can see in the screenshot that the Raspbian is unable to ping google. The host machine is connected to the Internet via a 3G Dongle.

3

While brought up your guest OS, If you didn't specify any nic interface, by default QEMU will create one and assign the IP 10.0.2.15. but it will not have any connectivity. so guest OS will not able to ping host OS. (For more details about QEMU networking refer http://wiki.qemu.org/Documentation/Networking).

Better way I would suggest is bridge->tap configuration. All you have to do is:

  1. Install ethernet bridge administration(brctl) -> sudo apt-get install bridge-utils
  2. Install tunctl to create and manage persistent TUN/TAP interfaces -> sudo apt-get install uml-utilities
  3. Install libvirt-visualization management system. This will automatically setup a DHCP server and a bridge(virbr0) -> sudo apt-get install qemu-kvm libvirt-bin

Verify whether DHCP server is runing:

root@unknown:~# ps -ef | grep dns
121       1377     1  0 Dec13 ?      00:00:00 /usr/sbin/dnsmasq -u libvirt-dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/default.pid --conf-file= --except-interface lo --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases --dhcp-lease-max=253 --dhcp-no-override

Verify bridge interface is created, and it is configured to DHCP gateway:

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 MULTICAST  MTU:1500  Metric:1
          RX packets:619 errors:0 dropped:0 overruns:0 frame:0
          TX packets:685 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:44276 (44.2 KB)  TX bytes:51576 (51.5 KB)  

4. Bind eth0 to virbr0 -> brctl addif virbr0 eth0

5.Create a tap interface and make it up -> tunctl -t tap0 && ifconfig tap0 up

6.Bind tap0 to virbr0 -> brctl addif virbr0 tap0

7.Make sure tap0&eth0 are binded:

root@unknown:~# brctl show
bridge name bridge id  STP enabled interfaces
virbr0  8000.1a9819c54ba8 yes       eth0
                                    tap0

8.My configuration:

root@unknown:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 48:84:3c:c6:33:34  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:20070 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20070 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1697375 (1.6 MB)  TX bytes:1697375 (1.6 MB)

tap0      Link encap:Ethernet  HWaddr 1a:98:19:c5:4b:a8  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

virbr0    Link encap:Ethernet  HWaddr 78:84:3c:e6:38:98  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:619 errors:0 dropped:0 overruns:0 frame:0
          TX packets:685 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:44276 (44.2 KB)  TX bytes:51576 (51.5 KB)

wlan0     Link encap:Ethernet  HWaddr cd:af:76:c4:6d:99  
          inet addr:192.168.1.5  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: ff70::ceff:78dd:fdc1:6d95/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1338984 errors:0 dropped:0 overruns:0 frame:0
          TX packets:997145 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1521507128 (1.5 GB)  TX bytes:142971835 (142.9 MB)

9. Brought qemu with NIC -

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

enter image description here

Refer this

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.