Pre-requisite
- Install Debian 11 or Ubuntu 20.04 server as required.
Optional
- I had upgraded the kernel version by compiling the kernel as explained in this how-to.
Installing KVM on Debian
Simple and easy – First, install the required packages
apt install -y qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon virt-manager
Additionally, I had installed libguestfs-tools, for customizing VMs before spinning up VMs
apt install -y libguestfs-tools
Bridge interfaces allow the guest VMs to communicate through the HOST., and connect to the real network. You will first need to allow IP forwarding in the kernel params. Edit /etc/sysctl.conf and uncomment the following configuration
net.ipv4.ip_forward=1
Configure the bridge interfaces. In my case, I have four servers and all have 4 x 1 G NICs plus 2 x 10G NICs.
My choice: The first 1G NIC will not be bridged and used for server management. All other 3 1G NICs would be bridged, for use by VMs hosted on the server. All VMs will be configured with a minimum of 1 bridged 1G NIC for management of the VM. Contents of /etc/network/interfaces. Gateway Info, IP Adress used are based on my local setup. DNS configuration is done as part for installing servers.
source-directory /etc/network/interfaces.d
auto eno1
iface eno1 inet static
address 10.99.1.3/16
gateway 10.99.0.1
auto eno2
iface eno2 inet manual
auto eno3
iface eno3 inet manual
auto eno4
iface eno5 inet manual
#10 G Ports - Set mtu to 9000 - supported by NIC
auto enp4s0
iface enp4s0 inet manual
mtu 9000
auto enp5s0
iface enp5s0 inet manual
mtu 9000
auto br2
iface br2 inet manual
bridge_ports eno2
bridge_stp off
bridge_waitport 0
bridge_fd 0
auto br3
iface br3 inet manual
bridge_ports eno3
bridge_stp off
bridge_waitport 0
bridge_fd 0
auto br4
iface br4 inet manual
bridge_ports eno4
bridge_stp off
bridge_waitport 0
bridge_fd 0
auto br5
iface br5 inet manual
bridge_ports enp4s0
bridge_stp off
bridge_waitport 0
bridge_fd 0
auto br6
iface br5 inet manual
bridge_ports enp5s0
bridge_stp off
bridge_waitport 0
bridge_fd 0
Optional: NIC bonding as required, click here for a how-to.
Normally the config for a virtual network called “default” is installed as part of the libvirt package, and it is set up to autostart when libvirtd is started. On reboots it is better to enforce auto start.
virsh net-start default
virsh net-autostart default
modprobe vhost_net
echo vhost_net | tee -a /etc/modules
Better to disable AppArmor – all service behind UTM device
systemctl stop apparmor
systemctl disable apparmor
apt remove -y apparmor