I just set up an ARM64 image using QEMU and I'm trying to access the internet from within the binary. The host OS(Ubuntu) receives internet from the eth0 interface. I have the tap0 interface set up. I've added tap0 and eth0 to virbr0.
$ brctl show virbr0
bridge name bridge id STP enabled interfaces
virbr0 8000.080027c9997e yes eth0
tap0
Now, I try to start the VM as follows :-
sudo qemu-system-aarch64 -machine virt -cpu cortex-a57 -nographic -smp 1 -m 512 \
-global virtio-blk-device.scsi=off -device virtio-scsi-device,id=scsi \
-drive file=ubuntu-core-14.04.1-core-arm64.img,id=coreimg,cache=unsafe,if=none -device scsi-hd,drive=coreimg \
-kernel vmlinuz-3.13.0-55-generic \
-initrd initrd.img-3.13.0-55-generic \
-netdev user,id=unet -device virtio-net-device,netdev=unet \
-net nic -net tap,ifname=tap0,script=no,downscript=no \
--append "console=ttyAMA0 root=/dev/sda"
The output of ifconfig on host is as follows :-
$ ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:c9:99:7e
inet6 addr: fe80::a00:27ff:fec9:997e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2942 errors:0 dropped:0 overruns:0 frame:0
TX packets:7889 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:239227 (239.2 KB) TX bytes:557156 (557.1 KB)
tap0 Link encap:Ethernet HWaddr 8e:3d:c3:0e:58:36
inet6 addr: fe80::8c3d:c3ff:fe0e:5836/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:412 errors:0 dropped:427 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:21432 (21.4 KB)
virbr0 Link encap:Ethernet HWaddr 08:00:27:c9:99:7e
inet addr:10.0.2.15 Bcast:0.0.0.0 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2928 errors:0 dropped:0 overruns:0 frame:0
TX packets:2940 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:195163 (195.1 KB) TX bytes:236587 (236.5 KB)
Once I start the VM, the output of ifconfig is as follows.
root@localhost:~# ifconfig
eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:57
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fe12:3457/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:846 (846.0 B) TX bytes:3320 (3.3 KB)
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:65536 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:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
However, I don't seem to be able to ping any remote addresses(eg: 8.8.8.8). Why does this happen? How can I fix this?
[EDIT] When starting the VM I get the following warnings.
W: /etc/qemu-ifup: no bridge for guest interface found
Warning: hub port hub0port0 has no peer
Warning: vlan 0 with no nics
Warning: netdev hub0port0 has no peer
Warning: requested NIC (anonymous, model unspecified) was not created (not supported by this machine?)
virbr0uses10.0.2.25as an address, that is private. So what's your route to8.8.8.8? – ikrabbe Jul 5 '15 at 21:5310.0.2.25and nothing else, how is this private IP routed to access the internet? Show us yourip routeon the host, would be a first approach. It also seems that your virtual host through tap0 has the same address as thevirbr0. How do you ping from the host to the client and vice versa? – ikrabbe Jul 6 '15 at 6:13-net nic -net tap,ifname=tap0not-net user. You'd use theuserstuff if you were not configuring your own bridge. – mikeserv Jul 6 '15 at 6:22