During writing of the last post I actually bricked my home router after installing a custom image. At the same time I didn't manage to get TFTP recovery working  so I started searching for ways to restore my home network so I could worry about that later.
The choice fell on using an ARM board to run OpenWrt, which required some creative workarounds. This post documents them.
What I want to replace:
router-switch combo: 1x WAN, 5x LAN, no WiFi
What I have:
64-bit ARM SBC, capable of hardware virtualization
USB 3.0 Ethernet adapter (if your SBC has 2x LAN natively that works too)
6-port Ethernet switch
eth0 will be the LAN,
eth1 the WAN.
The LAN bridge also gets an IP address for management (pick one outside your DHCP pool)
so you can SSH to the host even if the OpenWrt VM is not in operation.
I virtualized OpenWrt because it supports a few select boards (eg. Raspberry Pi's), but not the ones I have.
#!/bin/bash cd /root exec qemu-system-aarch64 -enable-kvm -cpu host \ -nographic -M virt,highmem=off -m 128 -smp 4 \ -kernel openwrt-armvirt-64-Image -append "root=fe00" \ -drive file=openwrt-armvirt-64-rootfs-ext4.img,format=raw,if=none,id=hd0 \ -device virtio-blk-pci,drive=hd0 \ -nic bridge,br=br0,model=virtio -nic bridge,br=br1,model=virtio
If the default OpenWrt configuration has address conflicts with the rest of your network, you can adjust it ahead of time like so:
Now suppose you want to import the configuration of your old OpenWrt install,
except: it has totally different interface names all over! Not a problem either
as you can rename them by adding the following lines to
If you did everything right up until this point you can shut down the SBC, plug in all the cables, let it reboot and an OpenWrt router should appear in your network at http://192.168.1.1 just as if it was a real device.
net.core.default_qdisc = pfifo_faston the host can save some CPU time, not sure whether this breaks QoS
If you have a WiFI USB adapter you could pull it into the VM and enjoy wireless too! See here for an example
When running this setup long term it would make sense to strip down the host OS
The QEMU serial console could be bound to a socket or PTS to interact with it even when