On 06.06.2025 23:10, Charles Curley wrote:
I'm setting up a new machine running trixie to run virtual machines,
using virt-manager. virt-manager sets up a natted network for the
virtual machines.

Is it possible to set things up so that the virtual machines are on the
same network as the host machine? The host is on 192.168.100.0/24. Can
I have the virtual machines also on 192.168.100.0?

Thank you.

Yes, you need to setup bridge interface on your host, think of it as virtual network switch and each VM and host would connect to its ports.
Your host network config should look like this:
$ sudo brctl show
bridge name     bridge id               STP enabled     interfaces
host-bridge             8000.fa04d78693ed       yes VLAN20
srv-node1-vnet0
...

$ sudo virsh net-dumpxml --network host-bridge
<network>
  <name>host-bridge</name>
  <uuid>5b7b8ec5-ca1a-4066-8664-a2d107c9b083</uuid>
  <forward mode='bridge'/>
  <bridge name='host-bridge'/>
</network>

Network portion of VM config should look like this:
$ sudo virsh dumpxml --domain srv-node1
...
<interface type='bridge'>
      <mac address='52:54:00:34:55:2b'/>
      <source bridge='host-bridge'/>
      <target dev='srv-node1-vnet0'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</interface>
...

<forward mode="bridge"/> part is essential.
The upside of this setup is that you will loose "double-NAT", which is default for libvirt\KVM, and prevent libvirt from modifying iptables ruleset. The downside is you'll have to provide DHCP service for VMs from external router and also make your host into a router to forward traffic from and to VMs. I wish I could provide a simple example from my system, but my configuration is more complicated, because I've split a single ethernet interface into multiple VLANs and use two bridges to completely isolate one VM from the host. It was easier for me to configure a complicated network setup like this with NetworkManager.

The whole setup could be done by reading these articles:
https://wiki.debian.org/BridgeNetworkConnections
https://wiki.libvirt.org/Networking.html#bridged-networking-aka-shared-physical-device


--

 With kindest regards, Alexander.

 Debian - The universal operating system
 https://www.debian.org

Reply via email to