Skip to content

Instantly share code, notes, and snippets.

@amf3
Last active January 6, 2026 10:49
Show Gist options
  • Select an option

  • Save amf3/eaf6ccd0d3a8bdfd9572938c87397353 to your computer and use it in GitHub Desktop.

Select an option

Save amf3/eaf6ccd0d3a8bdfd9572938c87397353 to your computer and use it in GitHub Desktop.
Emulate OpenWRT in QEMU on MacOS with M2 Processor

Notes on running OpenWRT in QEMU on MacOS.

  1. Install QEMU with homebrew
$ brew install qemu
  1. Download a OpenWRT image. We want a armvirt/64 image.
# Snapshot dir does not have armvirt images, need to pick a release.
# https://downloads.openwrt.org/releases/22.03.5/targets/armvirt/64/
# -rw-r--r--@ 1 adam  staff  21157896 Jul 31 21:49 openwrt-22.03.5-armvirt-64-Image-initramfs
  1. Bash script to start the VM
#!/bin/bash

qemu-system-aarch64 -m 1024 -smp 2 -cpu host -M virt,highmem=off \
-nographic \
-accel hvf \
-kernel openwrt-22.03.5-armvirt-64-Image-initramfs \
-device virtio-net,netdev=net0 -netdev user,id=net0,net=192.168.1.0/24,hostfwd=tcp:127.0.0.1:1122-192.168.1.1:22 \
-device virtio-net,netdev=net1 -netdev user,id=net1,net=192.0.2.0/24
  1. Login into the OpenWRT VM & setup port forwarding
$ ssh -p1122 -L :8080:127.0.0.1:80 root@127.0.0.1   
  1. To install Luci on the running image
# opkg update
# opkg install luci

More info on installing Luci is here

  1. Open Safari & visit http://127.0.0.1 to use the luci interface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment