qemu: Enable guest access to the internet


Manuel Wagesreither
 

Hi all,

I would like to configure my host to allow the yocto-built qemu guest access the internet. I'm running qemu with kvm virtualization and slirp, and according to [1] it should just work. I'd like to find out why it doesn't.

[1] https://www.linux-kvm.org/page/Networking#User_Networking

Here's the current situation:

* The guest has ip 10.0.2.15 and can ping my host with `ping 10.0.2.2`.
* The host has no ip 10.0.0.0/16.
* The guest cannot ping my hosts only ipv4 interface (besides lo) `ping 192.168.178.24`.
* The guest cannot ping devices in the same LAN as my host: `ping 192.168.178.101`.
* The host has sysctl configured like so:

net.ipv4.conf.all.accept_source_route = 1
net.ipv4.conf.all.send_redirects = 1
net.ipv4.ip_forward = 1
net.ipv6.conf.all.accept_source_route = 1
net.ipv6.conf.all.forwarding = 1

* The hosts routing table:

Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.178.1 0.0.0.0 UG 600 0 0 wlp3s0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 wlp3s0
192.168.178.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp3s0

* runqemu starts qemu with hostfwd=tcp::2222-:22. That is, qemu is instructed to on the host listen on port 2222 and forward packets to port 22 of the guest.
* From the host I can ssh into the guest with `ssh root@localhost -p2222`.

When the ssh connection is up, `netstat -tupen` on the host prints

Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 127.0.0.1:2222 127.0.0.1:37548 ESTABLISHED 1000 34788 2301/qemu-system-x8
tcp 0 0 127.0.0.1:37548 127.0.0.1:2222 ESTABLISHED 1000 40091 2331/ssh

`netstat -tuen` inside the guest prints

Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 ::ffff:10.0.2.15:22 ::ffff:10.0.2.2:37548 ESTABLISHED


Has anyone any ideas?

Thanks, regards,
Manuel

Join yocto@lists.yoctoproject.org to automatically receive all group messages.