ObjectiveInstall KVM with bridged networking and virt-manager on Ubuntu 18.04 Bionic Beaver
RequirementsA working install of Ubuntu 18.04 with root privileges
- # - requires given linux commands to be executed with root privileges either directly as a root user or by use of
- $ - requires given linux commands to be executed as a regular non-privileged user
Other Versions of this TutorialUbuntu 20.04 (Focal Fossa)
IntroductionKVM is the Linux kernel's own answer to virtualization. As a result, it's the lightest, most stable, and most universal virtualization option for Linux systems. While, KVM isn't as simple to set up as packaged solutions like VirtualBox, it's ultimately more efficient and flexible.
When you pair KVM with a graphical manager like virt-manager, it's extremely simple to use, and it integrates well with your Linux desktop. It's also simple to get VM guests on your regular network through bridged networking. This provides a more seamless experience overall.
Install The PackagesEven though the capabilities for KVM are built into the kernel itself, there are a couple of packages that you'll need to get started. They're all standard packages in the default Ubuntu repositories, so install them first.
$ sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager
Configure The Network BridgeBefore you can dive in and start making virtual machines, you're going to need to set up a network bridge. Bridged networking is what allows your VMs to access your network and be assigned their own IP addresses.
To start, find out what names your network interfaces have been assigned. This guide will use
eth0, but your interface will probably be different. To find out your network interfaces, run
$ ip a. Notate the interface with your computer's local IP next to it. Chances are, it'll be something like
Once you have your network interface, you need to edit a configuration file to tell Ubuntu that your connection is going to be bridged. This process won't negatively impact your connection at all. It'll just allow that connection to be shared with the VMs.
/etc/network/interfaces. The default file is pretty plain. It really only concerns the loopback interface. You're obviously going to change that.
In order to bring your new bridge interface up by default, add
br0at the end of the
autoauto lo br0 Below the loopback information, add the following line for your current interface.
iface eth0 inet manualNext, you can add the bridge information. These lines tell Ubuntu that your bridge will use DHCP for automatic IP address assignment, and your bridge will manage your current interface.
iface br0 inet dhcp bridge_ports eth0
Add Your User To The GroupsNext, you're going to need to add your user to the appropriate groups so you don't need root privileges to manage your virtual machines. There are two groups that you need.
When you're done there, restart your system. That's the best way to ensure that both the networking and user changes take effect.
$ sudo adduser username libvirt $ sudo adduser username libvirt-qemu
Creating A VM
+icon at the bottom of the left side to add it.