I have read many documentation and threads but could not figure out how to allow the guest machine to access the internet.
Below is the command for creating the guest Alpine Linux machine on MacOS x86_64 (Ventura 13.2.1)
$ qemu-system-aarch64 \
-M virt \
-m 4096 \
-rtc base=utc,clock=host,driftfix=slew \
-bios QEMU_EFI.fd \
-device virtio-rng-pci \
-device virtio-balloon \
-nographic \
-no-reboot \
-serial mon:stdio \
-drive if=virtio,file=user-data.qcow2 \
-monitor unix:monitor.sock,server,nowait \
-netdev user,id=net1,hostfwd=tcp:127.0.0.1:10022-:22 \
-device virtio-net-pci,netdev=net1 \
-smp 4 \
-cdrom boot.iso \
-drive if=virtio,file=tmp.qcow2 \
-cpu cortex-a72
And within the guest, this is the network output
$ ifconfig -a
eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:56
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
LOOPBACK 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:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
ping: sendto: Network unreachable
What should be done to make the guest machine reach the internet? Would appreciate if I could see 2 types of networking:
- Have the guest with a dedicate IP address, were the host operating system could interact with the guest using the guest IP address
- Have the guest just access the internet, whether it is a bridge or NAT
Thanks