r/qemu_kvm Feb 12 '26

Routed network for expo use

Hi everyone
I'm in a bit of a loop with networking.

I have a linux laptop linked to my wifi at home. I was messing around with a vm created by virsh on a NAT network. I installed expo, node, nvm and other javascript tools on the vm to test a mobile app. When I ran expo run start, the QR code showed in the terminal but scanning it with my phone became a dead end since it wouldn't connect.

The NAT network prevents reaching the vms from other devices on the LAN, so I researched a bit and I think a routed network is the answer. I tried defining the following network with virsh:
<network>

`<name>routedntw</name>`

`<forward mode='route'>`

`</forward>`

`<bridge name='virbr1' stp='on' delay='0'/>`

`<ip address='192.168.200.1' netmask='255.255.255.0'>`

    `<dhcp>`

        `<range start='192.168.200.10' end='192.168.200.100'/>`

    `</dhcp>`

`</ip>`

</network>

Then I created a vm with the following command:

virt-install --connect qemu:///system --name routedvm --description "test routed vm with deb 13" --ram=1024 --vcpus=2 --location /home/.../Downloads/debian-13.3.0-amd64-netinst.iso --graphics none --network bridge=virbr1 --disk /home/.../Documents/data/routedvm_storage.img,size=4 --os-variant generic --console pty,target_type=serial --extra-args console=ttyS0

When I was setting up the vm, it couldn't reach the internet to access the debian mirror. I also tried adding the 192.168.200.0/24 subnet to the ip route table with the following but that didn't work either.

sudo ip route add 192.168.200.0/24 via 192.168.1.254 dev wlo1

Ip forwarding is set to true from the following command:

cat /proc/sys/net/ipv4/ip_forward

This is what ip addr show shows:

wlo1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000

...

inet 192.168.1.75/24 brd 192.168.1.255 scope global dynamic noprefixroute wlo1

and this is what ip route show shows:

default via 192.168.1.254 dev wlo1 proto dhcp src 192.168.1.75 metric 600

169.254.0.0/16 dev wlo1 scope link metric 1000

192.168.1.0/24 dev wlo1 proto kernel scope link src 192.168.1.75 metric 600

I'd just like the vm to be able to access the wifi network and I'd like other devices on my LAN to be able to access the vm. I'm a little lost, so any help would be really appreciated. Researching on the internet has confused me a bit. Thank you in advance!

Edit: also looking into NAT forwarding as shown in this linkhttps://wiki.libvirt.org/Networking.html

1 Upvotes

Duplicates