Using a network bridge with KVM VMs on Oracle Linux 8
Hello, and welcome to today's video presentation on using a network bridge with KVM VMs on
Oracle Linux 8.
This video will create a couple of virtual machines that leverage a network bridge using
both the command line and the Cockpit web console.
So let us get started.
For this demo, I use a physical Oracle Linux 8 system pre-configured with the KVM virtualization
packages, and an Oracle Linux 8.2 guest VM associated with the default KVM NAT network.
Beyond the default NAT virtual network (virbr0), the system is pre-configured with a bridged
network (br0).
Additional details on configuring those items are available in our other Linux and KVM videos
linked in the description and at the end of this video.
The steps in this video apply to physical, and on-premise systems and not intended for
Oracle Cloud Infrastructure.
Oracle Linux 8 provides several ways to create virtual machines.
In the first example, use the command-line tools virt-install and virsh to create a virtual
machine connected to the network bridge.
Open a terminal on the KVM host.
Ensure before getting started to stage the latest Oracle Linux 8 ISO file.
If the file does not yet exist, download it using curl by using the command provided on
screen.
Stage the ISO file in the /var/lib/libvirt/images directory for this demo.
Another bit of information needed to create the VM is the os-variant ID that matches the
planned guest OS install.
Look up the ID using the command osinfo-query.
Since installing Oracle Linux 8.2, search for the ID by typing in a terminal the command
osinfo-query os | grep -i oracle
The command output lists all the different IDs for Oracle Linux.
From the list, the Oracle Linux 8.2 specific ID is ol8.2.
The virt-install command will attempt to launch virt-viewer as part of VM creation to complete
the os installation.
Due to the use of sudo and VM creation within the System hypervisor, grant the sudo session
access to the X display by typing xhost +.
This command disables the X access control and allows the sudo session permission to
open applications within the active X display.
Alternatively, let the access fail and use a VNC connection.
Now that the preparatory steps are complete create a new virtual machine.
Type the virt-install command displayed on the screen.
[ silence while typing sudo virt-install --virt-type kvm --name ol8-test01 --memory 1024 --vcpus
1 --os-variant ol8.2 --cdrom /var/lib/libvirt/images/OracleLinux-R8-U2-x86_64-dvd.iso --network bridge=br0,model=virtio --graphics
vnc --disk path=/var/lib/libvirt/images/ol8-test01.qcow2,size=10 ]
The command creates a new VM with the name ol8-test01 and a network bridge defined using
the option --network brdige=br0,model=virtio.
Note the bridge (br0) is not a virtual network, and users do not need to define it as one.
The fact that the bridge is not a virtual network also means that br0 will not appear
when running the command sudo virsh net-list --all, which displays a list of all the libvirtd
virtual network devices.
Additional details regarding the virt-install options are available from the manual page
by typing man virt-install.
Execute the virt-install command entered into the terminal by hitting the Enter key.
The creation process writes out the XML file containing the VM configuration, allocates
the disk, and starts the VNC console session.
If the sudo session has access to the X display, a Virt Viewer window will display and provide
access to complete the virtual machine install.
If the sudo session does not have access to the X display, a warning will appear, indicating
that the virt-viewer cannot open the display.
If virt-viewer fails, use a VNC viewer as an alternate method to connect to the Graphical
console session.
Determine the details of the installers Graphical VNC session by typing sudo virsh dumpxml ol8-test01
| grep vnc
The output displays the virtual machines console VNC port (5900) and listen address (127.0.0.1).
Since the demo is running on the same physical KVM host, open a VNC viewer such as vinagre
to make the connection by typing vinagre 127.0.01:5900.
If performing this installation on a remote host, leverage a local ssh port forward as
in ssh -L 5900:127.0.0.1:5900 username@kvm_host.
Once establishing the local port forward, connect to the local ssh listening port using
a VNC client.
For additional help using a local ssh port forward, please check out our other Linux
videos linked in the description and at the end of this video.
Complete the installation.
As this will take a while to complete, I will fast forward to to the end.
Validate that the VM received an address assignment from the network bridge by logging into the
VM and running the command ip add from the terminal or console.
Now that you installed a bridge-based virtual machine using virt-install, do the same using
the Cockpit web console.
Open the web console in a browser and log in with your credentials.
Click Virtual Machine in the navigation panel on the left and then the Create VM button
on the right.
The Create New Virtual Machine panel will display.
Enter the selections matching what is on the screen.
Be sure to uncheck the Immediately Start VM option before clicking the Create button.
The ol8-test02 virtual machine will display in the list.
Click the Network Interfaces in the ol8-test02 details.
Note that Cockpit created the virtual machine with the bridged network despite not having
a network selection option listed in the Create New Virtual Machine panel.
Once you created the network bridge, Cockpit uses the bridge as the default network when
creating new virtual machines.
That covers using a network bridge to create a new virtual machine using both the command-line
and the Cockpit web console.
Thank you for watching this video and enjoy using KVM on Oracle Linux 8.
Please check our additional information on Oracle Linux 8 in the Oracle Linux 8 Documentation
or Oracle Linux Learning Library.