Here is a script for creating a CentOS Stream 9 VM. Update ISO if needed.
#!/bin/sh
NAME=$1
MEMORY=$2
CPUS=$3
DISK=$4
DESCRIPTION=$5
ISO=/var/lib/libvirt/iso/CentOS-Stream-9-latest-x86_64-dvd1.iso
echo "Choose anaconda TEXT install mode (2)."
sudo virt-install \
--name $NAME \
--memory $MEMORY \
--vcpus $CPUS \
--disk size=$DISK \
--location $ISO \
--osinfo centos-stream9 \
--description "$DESCRIPTION" \
--network bridge:virbr0 \
--graphics none \
--console pty,target.type=serial -x 'console=ttyS0,115200n8'
use anaconda text mode
update your time zone
make yourself a user account with adminstrator privilege
after the VM is up, log in and change the network with the following:
#!/bin/sh
DEVICE=$1
IP=$2
sudo nmcli con mod $DEVICE ipv4.method manual
sudo nmcli con mod $DEVICE ipv4.dns "172.19.28.11 172.19.28.12"
sudo nmcli con mod $DEVICE ipv4.dns-search lis.ncgr.org
sudo nmcli con mod $DEVICE ipv4.addresses $IP/16
sudo nmcli con mod $DEVICE ipv4.gateway 172.20.0.1
Then, shut down the VM. On the host, update the network configuration to use the br0 bridge using virsh edit:
<interface type='bridge'>
<mac address='52:54:00:a6:0d:f3'/>
<source bridge='br0'/>
<model type='rtl8139'/>
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</interface>
Start the VM, and it should be able to talk to the world.