Lists
2021-Dec-08 00:44 UTC
[CentOS] Qemu - enabling "bridge mode" for primary physical interface for VMs
I have a physical host with a single physical network adapter. I want to host several VMs on host. (guest1 - guest4) The guest systems are accessible via 192.168.122.* as is the default with qemu/virsh. There are 4 IP addresses being routed to the primary interface on host. I can set up an alias for the NIC and "see" these ip addresses. I understand that it's possible to allow the 4 VM guest systems to each have a "direct" fixed IP address and access the addresses \via the host network adapter, while the host retains its fixed IP. I've been googling like crazy and there is a lot of stale and conflicting information. Has anybody here done this successfully? Host and all guests are running CentOS 8. Thanks. Ben S -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part. URL: <http://lists.centos.org/pipermail/centos/attachments/20211207/7f160505/attachment-0004.sig>
Gordon Messmer
2021-Dec-08 01:18 UTC
[CentOS] Qemu - enabling "bridge mode" for primary physical interface for VMs
The easiest way to set up bridged mode is to use virsh to convert the eth0 configuration to a new bridge, br0: ??? virsh iface-bridge eth0 br0 --no-stp
Chris Adams
2021-Dec-08 04:25 UTC
[CentOS] Qemu - enabling "bridge mode" for primary physical interface for VMs
Once upon a time, Lists <lists at benjamindsmith.com> said:> I understand that it's possible to allow the 4 VM guest systems to each have a > "direct" fixed IP address and access the addresses \via the host network > adapter, while the host retains its fixed IP.If you are running NetworkManager (the default), it's not too hard. Here's an example step-by-step for changing an existing interface "em1" to be a bridge "br0": # Create a bridge interface nmcli con add type bridge ifname br0 bridge.stp no # Copy all the IPv4/IPv6 config from an existing interface nmcli con mod bridge-br0 $(nmcli -f ipv4.method,ipv4.addresses,ipv4.gateway,ipv6.method,ipv6.addresses,ipv6.gateway con show em1 | grep -v -- -- | sed 's/: */ /') # -or- just set an IPv4 address/gateway to known values nmcli con mod bridge-br0 ipv4.method manual ipv4.address 10.1.1.2/24 ipv4.gateway 10.1.1.1 ipv6.method ignore # Make a connection for the physical ethernet em1 to be part of the bridge nmcli con add type ethernet ifname em1 master bridge-br0 # Switch from the "regular" em1 to the bridge nmcli con down em1; nmcli con up bridge-br0; nmcli con up bridge-slave-em1 # Disable the original config nmcli con mod em1 autoconnect 0 Then you set your VMs to use the bridge - in the libvirt XML for example, you'd have something like: <interface type='bridge'> <mac address='52:54:00:12:34:56'/> <source bridge='br0'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> Inside the VM, configure the interface just as if it was a physical system on that subnet. -- Chris Adams <linux at cmadams.net>