Set QEMU Networking up on macOS by socket_vmnet
Contents
The previous post Run Ubuntu in QEMU on macOS (Apple Silicon) instructed us how to set QEMU networking up by vde_vmnet. However, the vde_vmnet was deprecated. This post is a guide to set QEMU networking up by the successor socket_vmnet.
Prerequisite
- ubuntu-24.04-live-server-arm64.iso
- QEMU >= 9.0
- socket_vmnet >= 1.1.4
- macOS >= Sonoma (Apple Silicon)
Preparation
|
|
Test
|
|
If the test is failed, try to restart the service by the following command.
|
|
Install Ubuntu
Download QEMU EFI.
1
curl -L https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd -o QEMU_EFI.fd
Create an image.
1
qemu-img create -f raw -o preallocation=full ubuntu.img 40G
Boot QEMU to install Ubuntu.
1 2 3 4 5 6 7 8 9 10 11
socket_vmnet_client "$(brew --prefix)/var/run/socket_vmnet" \ qemu-system-aarch64 \ -machine virt,accel=hvf \ -cpu host \ -smp 8 \ -m 8G \ -device virtio-net-pci,netdev=net0 -netdev socket,id=net0,fd=3 \ -drive if=virtio,format=raw,file=./ubuntu.img \ -cdrom <path/to/ubuntu iso> \ -nographic \ -bios QEMU_EFI.fd
Boot Ubuntu in QEMU
|
|
Log into the server by SSH
Get the name of the network device.
1 2 3 4 5 6
$ ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp0s1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
We can see the name of the network device is
enp0s1
.Get the IP address.
1 2 3 4 5
$ ip route default via 192.168.105.1 dev enp0s1 proto dhcp src 192.168.105.2 metric 100 192.168.105.0/24 dev enp0s1 proto kernel scope link src 192.168.105.2 metric 100 192.168.105.1 dev enp0s1 proto dhcp scope link src 192.168.105.2 metric 100
We can see the IP address is
192.168.105.2
.Log into the server
1
ssh 192.168.105.2
Author Adonis Ling
LastMod 2024-05-27 (e0f278f)