For installing on a bare metal server, skip to section 2 of this article.
If you wish to try installing locally on VirtualBox first, start with section 1 and read forward.
1. Create an Ubuntu 22.04 Virtual Machine on Oracle VirtualBox
First, you need to create an Ubuntu 22.04 virtual machine. The process is very straightforward and described in this article.
To enable the nested virtualization for a virtual machine on Windows and on macOS:
Windows: Go to the virtual machine
Settings > System and on the tab
Processor check the checkbox “Enable Nested VT-x/AMD-V” to enable nested virtualization for the virtual machine.
Settings > Network for your bridged adapter set
Promiscuous Mode: Allow All.
Or your nested virtual machines will have problems with accessing the Internet. And you will have problems with accessing your nested virtual machine by IP in your network (though you would be able to access it by IP from your KVM virtual machine).
macOS: With your VM selected go to
Settings > System, go to the tab
Processor and check the checkbox “Enable Nested VT-x/AMD-V”:
And you can turn the
Promiscuous Mode on in the adapter settings in
Settings > Network:
Please notice: If the checkbox “Enable Nested VT-x/AMD-V” is grayed out on macOS like this:
Find out what is the default virtual machine folder in
Preferences > General:
Go to your default machine folder in the terminal. And run:
VBoxManage modifyvm <VirtualMachineName> --nested-hw-virt on
For example, if the name of your virtual machine is
vm_22 70, run:
VBoxManage modifyvm 'vm_22 70' --nested-hw-virt on
2. Install KVM packages
On your Ubuntu 22.04 server:
Check that your CPU supports virtualization:
sudo apt install -y cpu-checker kvm-ok
It should output:
INFO: /dev/kvm exists
KVM acceleration can be used
Install the necessary packages:
sudo apt install -y qemu-kvm virt-manager libvirt-daemon-system virtinst libvirt-clients bridge-utils
If you are not sure, what each particular package means, use the package search for Ubuntu.
3. Configure Network Interfaces
3.1 Disable the
netfilter for bridges
It is recommended.
To disable the
/etc/sysctl.d/bridge.conf with the content:
net.bridge.bridge-nf-call-ip6tables=0 net.bridge.bridge-nf-call-iptables=0 net.bridge.bridge-nf-call-arptables=0
2) Create the file
ACTION=="add", SUBSYSTEM=="module", KERNEL=="br_netfilter", RUN+="/sbin/sysctl -p /etc/sysctl.d/bridge.conf"
3) Reboot the system:
3.2 Find the MAC address of the network interface enp0s3
You will need it in section 3.3 in the
To find the MAC address of the NIC (Network Interface Controller)
enp0s3, run in the terminal:
ip a show
The MAC address will be in the section
link/ether of the
enp0s3 network interface description.
Or you could run the command:
lshw -C network
Which will output the MAC address in the “serial:” entry.
Also, see the Ubuntu Network Configuration.
3.3 Add the bridge to netplan
Change the file
/etc/netplan/00-installer-config.yaml content to:
network: version: 2 # renderer: networkd ethernets: enp0s3: dhcp4: false dhcp6: false # addresses: [192.168.1.60/24] # nameservers: # addresses: [22.214.171.124, 126.96.36.199] # routes: # - to: default # via: 192.168.1.1 bridges: br0: dhcp4: false dhcp6: false interfaces: [ enp0s3 ] macaddress: 08:00:27:a1:e6:19 addresses: [192.168.1.60/24] nameservers: addresses: [188.8.131.52, 184.108.40.206] routes: - to: default via: 192.168.1.1 mtu: 1500 parameters: stp: true forward-delay: 4
You can also use
0.0.0.0/0 instead of the word “
See if you have any
netplan configuration errors:
sudo netplan generate
To apply the changes:
sudo netplan apply
Please also see this article on configuring KVM on Ubuntu 20.04 machine.
Please notice: Unfortunately, the command normally used for trying a new network configuration:
sudo netplan try
(where changes would be applied temporarily and rolled back unless you pressed Enter within 120 seconds), would not work if you had a bridge configured. You would get a message:
br0: reverting custom parameters for bridges and bonds is not supported
Please carefully review the configuration and use ‘netplan apply’ directly.
So if you are on a bare metal server and your hosting company does not give you IPMI access to the server, you need to be extra careful with your
Now, if you run
, you’ll see that the network interface
enp0s3 description contains
master br0. This means that the NIC (Network Interface Controller)
enp0s3 now belongs to
Also, you probably do not need the network interface
virbr0. You can delete it:
virsh net-destroy default net-undefine default quit
As a result, the network will be destroyed, the symlink
/etc/libvirt/qemu/networks/autostart/default.xml will be deleted and the file
/etc/libvirt/qemu/networks/default.xml will be deleted.
You can check that the NIC (Network Interface Controller)
virbr0 does not exist:
3.4 Add the bridge to KVM
Create the file
br0.xml with the following content:
<network> <name>br0</name> <forward mode="bridge"/> <bridge name="br0"/> </network>
The file could be, for example, in your Linux user home directory. If you are under root, it could be, for example,
name – the short name of your virtual network. It can be any alpha-numeric string (of course, no 2 networks should have the same name)
forward – means our virtual network must be connected to a physical network. mode=”bridge” in our case means we are connecting to a bridge created outside of libvirt.
bridge – determines the name of the bridge to which we are connecting.
Please also see the libvirt documentation for the network XML format.
Run in the terminal (please substitute
/path/to/br0.xml with your real Linux path to
sudo virsh net-define /path/to/br0.xml net-start br0 net-autostart br0 net-list quit
Additional reading: you could also check the following articles:
Now, when KVM was installed, you could proceed to creating Ubuntu 22.04 virtual machines on KVM.