Connecting a qemu virtual machine to the host machine
Using a qemu virtual machine that was created feels just like using any other physical machine until it’s time for remote access, or doing any networking-related activities( ports, IP address, etc… ). then you realize that it is connected using NAT. meaning you do not have access to the machine, can’t ssh into it, or connect to any of its ports.
Now What to do:
Generally speaking, there are two ways we could achieve connectivity between the host machine and the guest virtual machine, the first approach is using Port-Forwarding, which gives us the ability to make a mapping between a port on the guest machine to a port on the host machine. The other solution is attaching the guest machine to a Bridge Network, making the host and guest machines fully connected.
Port-forwarding:
port-forwarding is a more restricted approach because it requires the need to configure or map every pair of ports manually, but it might be all one needs in some scenarios for example, needing to expose one port to text a web service or expose a database.
Using quickemu makes creating those mappings (port-forwarding) trivial, all we need to do is add a single line to the configuration file which could be found inside the virtual machine directory under the name PATH_TO_VM/<VM_NAME>.conf, for example:
#!/usr/bin/quickemu --vm
guest_os="macos"
disk_img="macos-ventura/disk.qcow2"
img="macos-ventura/RecoveryImage.img"
macos_release="ventura"
# here >>
port_forwards=("8081:80")
in the above example, the port 80 on the guest is mapped to the port 8081 on the host.
Bridge Network
Unlike port-forwarding, there is a requirement to use the bridge method. It necessitates the existence of an Ethernet connection(Port), and there is a workaround the requirements, if like my case your machine does not have a physical Ethernet port and you mainly use WIFI. All we need to do is connect a mobile phone to the machine using USB-type A or a TYPE-C and have tethering activated. following these steps should Create a bridge network and attach it to a VM:
- [optional] Add an Ethernet port using mobile phone:
as you can see here, I’m using WIFI so there is no Ethernet port when running ip -br a:

No Ethernet
now after activating tethering on the phone and connecting it using USB.

Etherenet
- now just edit the following script as follows:
#! /usr/bin/bash
sudo brctl addbr virtbr0
sudo brctl addif virtbr0 enp0s20f0u1c4i2
sudo ip addr add << NETWORK_MASK > dev virtbr0
sudo ip link set virtbr0 up
sudo iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT
now just replace the NETWORK_MASK with your network mask, which can be found in the:

Network Mask
finally, make the script executable by running chmod +x script.sh, now run it at last ./script.sh.
- Attach the virtual machine to the bridge network, by editing the config file.
add the following line to the end of the config file.
network="virtbr0"
for more details
to have more insight about the whole thing from using quickemu, and creating a bridge network, to creating react-native ios development builds on Linux following me on Instagram where I will soon share some tutorial videos.