How to bridge virtual machine network to host network


I want to run home assistant on my home server. I want to run it in a virtual machine so i can enable all features. But I’m really struggling with getting the network to work. I want to access homeassistant on port 8123 but i just can’t get it to work. I’ve tried everything i found online.

I currently have a bridge network to my lan. I created a virsh network with the following config file

    <forward mode="bridge" />
    <bridge name="br0" />

and started the virtual machine after changing the network settings to connect to bridget-network. I however still can’t access the homeassistant on Also using sudo virsh with anything network related keeps hanging after executing, unless i sudo systemctl start libvirtdbut that stops again after a few seconds. I’m really lost at what i should do now. I have very little experience with networks and linux networking.
In firewall-cmd i have already forwarded the correct port. But it is not even showing up when i do sudo netstat -tulpn

1 Like

How did you create the br0 device? Is it ethernet or wifi.

I have never had an issue in communication between host and VM when i attach the VM to the default 'virbr0` device that is created by fedora when qemu & libvirt are used. I also easily communicate with the VM from other devices on the LAN. The only issue is that other devices on the LAN must have a route added to redirect traffic from the gateway to the local network that is assigned to the virbr0 device. In my case my host is on the network and the VM is on the network. Thus my gateway has a route to redirect all traffic to the network to the host IP which then forwards it via virbr0 to the VM.

My host is connected to the LAN via wifi but that does not matter as long as the bridge device is not attached directly to the wifi adapter. Fedora routes traffic both ways very nicely.

I avoid using NAT and do not connect directly to an adapter on the host with a bridge.

I don’t completely understand what you mean. Did you setup something in your router to allow other computers to access the virtual machine, or change something on the computer hosting the virtual machine.

I did try to use the default virbr0, i however ran into the issue you described of not being able to access the virtual machine from the local network.

I used the script on this website to set up the bridge. Which i found on the libvirt wiki

On my router I created a routing entry for the network of the VM and pointed it to the address of the host. Without creating such a local routing entry the 192.168.X.X address range is unrouteable since it is one of the designated private subnets globally.

You are confusing virtual and bridged networking.
Bridged networking does not require extra subnets.
Guest requests IP from the router over the host’s bridge.
Clients can access the host and the guest on the same subnet.

As i understand it from reading posts here (though I have never personally tried) bridging to a wifi interface does not seem to work. It apparently does to ethernet.

In my case my housing does not allow ethernet wiring to be installed so I use wifi and my method works reliably.

I have followed both of the tutorials you posted for setting up the bridge connection. However port 8123 for homeassistant is still not working. The port also does not appear to be open when i run
netstat -tulpn

Be sure to run that command on the guest.
Also confirm the guest has obtained IP from the router in the same subnet as the host.

shouldn’t the guest have the same ip as the host?

Certainly not, each guest VM should use a different IP.
Bridged networking provides symmetric connectivity in the host’s subnet with unique IPs.
This helps simplify routing and eliminate the need for port forwarding across the LAN.

After looking in my routers devices tab i saw indeed a new device called homeassistant had been added with a different ip address. after connecting to that ip i was able to access the homeassistant UI.
Thank you very much!