Re: qemu: Enable guest access to the internet

Matthias Klein

Hello Manuel,

the last time I tried, I had to set the IP and the gateway in the guest.

Then everything worked through the tap device.

Best regards,

-----Ursprüngliche Nachricht-----
Von: yocto@... <yocto@...> Im Auftrag von Manuel Wagesreither via
Gesendet: Samstag, 19. März 2022 01:13
An: yocto@...
Betreff: [yocto] qemu: Enable guest access to the internet

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.


Here's the current situation:

* The guest has ip and can ping my host with `ping`.
* The host has no ip
* The guest cannot ping my hosts only ipv4 interface (besides lo) `ping`.
* The guest cannot ping devices in the same LAN as my host: `ping`.
* 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 UG 600 0 0 wlp3s0 U 1000 0 0 wlp3s0 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 ESTABLISHED 1000 34788 2301/qemu-system-x8
tcp 0 0 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: ::ffff: ESTABLISHED

Has anyone any ideas?

Thanks, regards,

Join to automatically receive all group messages.