The network is working fine, since I can do from inside QEMU:
wget example.com
But if I do:
ping example.com
it just shows the initial header and hangs:
PING example.com (93.184.216.34): 56 data bytes
I know ping
requires some extra permissions to run as mentioned at: https://stackoverflow.com/questions/37512291/how-is-ping-for-non-root-user-implemented-on-linux-distros
I tried the procedure at https://wiki.qemu.org/Documentation/Networking#Enabling_ping_in_the_guest.2C_on_Linux_hosts with on host:
sudo groupadd unpriv_ping
sudo usermod --append --groups unpriv_ping "$(id -nu)"
GROUP_ID="$(getent group unpriv_ping | cut -f 3 -d :)"
printf "net.ipv4.ping_group_range = ${GROUP_ID} ${GROUP_ID}\n" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
then I logged out and in again, but it did not help.
Neither did:
setcap cap_net_raw+eip qemu-system-x86_64
My full QEMU command line is:
x86_64-softmmu/qemu-system-x86_64 \
-device \
rtl8139,netdev=net0 \
-gdb \
tcp::45457 \
-kernel \
/home/ciro/bak/git/linux-kernel-module-cheat/out/linux/default/x86_64/arch/x86/boot/bzImage \
-m \
256M \
-monitor \
telnet::45454,server,nowait \
-netdev \
user,hostfwd=tcp::45455-:45455,hostfwd=tcp::45456-:22,id=net0 \
-no-reboot \
-smp \
1 \
-trace \
enable=pr_manager_run,file=/home/ciro/bak/git/linux-kernel-module-cheat/out/run/qemu/x86_64/0/trace.bin \
-virtfs \
local,path=/home/ciro/bak/git/linux-kernel-module-cheat/data/9p,mount_tag=host_data,security_model=mapped,id=host_data \
-virtfs \
local,path=/home/ciro/bak/git/linux-kernel-module-cheat/out,mount_tag=host_out,security_model=mapped,id=host_out \
-virtfs \
local,path=/home/ciro/bak/git/linux-kernel-module-cheat/rootfs_overlay,mount_tag=host_rootfs_overlay,security_model=mapped,id=host_rootfs_overlay \
-serial \
mon:stdio \
-M \
pc \
-device \
edu \
-append \
'root=/dev/vda nopat console_msg_format=syslog nokaslr norandmaps panic=-1 printk.devkmsg=on printk.time=y console=ttyS0' \
-nographic \
-drive \
file=/home/ciro/bak/git/linux-kernel-module-cheat/out/buildroot/build/default/x86_64/images/rootfs.ext2.qcow2,format=qcow2,if=virtio,snapshot \
;
Tested on Ubuntu 18.04 host with the following images:
/etc/sysctl.conf
and groups were modified on host. – Ciro Santilli TRUMP BAN IS BAD Oct 5 '18 at 12:50