O.K. I am now using netplan again, moved to the HWE stack, rolled back my systemd-networkd related changes, and cleaned up some other garbage from this saga. So, this is what I did to make my libvirt/QEMU VMs work on my LAN via a host bridge. There are a great many references that I should list and give credit to, but I didn't keep track.
First, I wanted to get rid of the libvirt default stuff for the NAT method that uses iptables rules. Why?
- Because I want complete control of the host iptables rules for myself.
- Because I never ever want any VM to be the NAT way.
So first, keep a copy of the default.xml file in /etc/libvirt/qemu/networks, just in case there is ever a need to go back and because it gets deleted:
Code:
sudo cp default.xml default.xml.original
Now,
Code:
virsh net-destroy default
virsh net-undefine default
Edit your netplan .yaml file to define the bridge. On my system the default .yaml file was called 01-netcfg.yaml in /etc/netplan. This is after edit:
Code:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: no
bridges:
br0:
interfaces: [ enp3s0 ]
dhcp4: yes
# dhcp4: no
# addresses: [192.168.111.136/24]
# gateway4: 192.168.111.1
# nameservers:
# addresses: [192.168.111.1]
# dhcp6: no
# link-local: [ ]
# parameters:
# stp: true
# forward-delay: 4
Where I have commented out a static host address version and couple of other things. Some references say one needs stp, but I disagree.
In /etc/libvirt/qemu/networks create an xml file to define the bridged network for the VMs. The file prefix name can be whatever is desired. It will get re-written later, so suggest to keep an original copy:
Code:
doug@s19:/etc/libvirt/qemu/networks$ ls -l
total 24
drwxr-xr-x 2 root root 4096 Apr 30 07:11 autostart
-rw------- 1 root root 367 Apr 30 06:54 br0.xml.original
-rw-r--r-- 1 root root 96 Apr 18 15:09 bridge.xml.original
-rw------- 1 root root 576 Apr 23 13:08 default.xml.original
-rw------- 1 root root 383 Apr 30 07:10 host-bridge.xml
-rw-r--r-- 1 root root 104 Apr 30 07:10 host-bridge.xml.original
doug@s19:/etc/libvirt/qemu/networks$ cat /etc/libvirt/qemu/networks/host-bridge.xml.original
<network>
<name>host-bridge</name>
<bridge name='br0'/>
<forward mode="bridge"/>
</network>
doug@s19:/etc/libvirt/qemu/networks$ sudo cp host-bridge.xml.original host-bridge.xml
virsh net-define host-bridge.xml
virsh net-autostart host-bridge
virsh net-start host-bridge
virsh net-list --all
Name State Autostart Persistent
------------------------------------------------
host-bridge active yes yes
Probably want to re-boot here.
For VMs being converted from the NAT method, use "virsh edit" and change the network area to, for example, this:
Code:
<interface type='bridge'>
<mac address='52:54:00:60:ea:0e'/>
<source bridge='br0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
And for creating a new VM, at least the way I do it:
Code:
virt-install -n desk-ii -r 8192 \
--disk path=/home/doug/vm/desk-ii.img,bus=virtio,size=50 \
-c impish-desktop-amd64.iso \
--network bridge=br0,model=virtio,mac=52:54:00:60:ea:5e \
--video=vmvga --graphics vnc,listen=0.0.0.0 --noautoconsole -v --vcpus=4
Tested on 4 VMs. two old ones converted from the NAT method and 2 brand new ones, defined to use the host bridge to start with.
Note: I still have to double check some things, so there might yet be edits.
Bookmarks