User Tools

Site Tools


kvm:setup_kvm_with_bridged_networking_and_virt-manager

This is an old revision of the document!


KVM - Setup KVM with bridged networking and virt-manager

KVM is the Linux kernel's virtualization tool.

Install The Packages

Even 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 Bridge

Before 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.

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. Note the interface with your computer's local IP next to it. Chances are, it'll be something like enp5s0.

ip a

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.

Edit /etc/network/interfaces.

/etc/network/interfaces
auto lo br0
iface lo inet loopback
 
iface eth0 inet manual
 
iface br0 inet dhcp
    bridge_ports eth0

In order to bring your new bridge interface up by default, br0 is added at the end of the auto lo.

The bridge information lines tell Ubuntu that your bridge will use DHCP for automatic IP address assignment, and your bridge will manage your current interface.

Ubuntu 18.04 moves to using Netplan to handle Networking, and this therefore requires a different configuration to support bridging.

See:

https://bugs.launchpad.net/ubuntu/+source/nplan/+bug/1736975 https://djanotes.blogspot.com/2018/04/anonymous-bridges-in-netplan.html

That's it for your bridge. Save and exit.

Add Your User To The Groups

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.

sudo adduser username libvirt
sudo adduser username libvirt-qemu

Restart your system. That's the best way to ensure that both the networking and user changes take effect.

Creating A VM

Use virt-manager to create VMs. The window that opens up is fairly plain, but it has everything that you need to manage your VMs. To start making a new one, click on the icon that looks like a shining screen. It's the first one in the icon row.

A new window will pop open to walk you through the process. The first thing that it will ask you to do is select a source. In most cases, you're going to use a regular install ISO to make your VMs, so leave the first option selected and keep going.

The next screen asks you to select your image. Browse to the location of your image. If the folder with your image isn't available, use the + icon at the bottom of the left side to add it.

On the following screen, you can allocate memory and cpu cores to the VM. Don't give it all of your system's resources. That obviously won't go well.

The next screen lets you determine the hard drive size of your VM. It's just a VM, so it doesn't need a huge hard drive. Just make sure to give it enough to install and run what you need.

Finally, you can see an overview of your VM before you finalize it. On this screen, you can also name it. Once you finalize your VM, a new window will open and boot up the VM. In that window, you will see the installer for the image that you selected. Everything from here is exactly the same as installing on a regular computer.

Closing Thoughts

KVM provides a great amount of flexibility and power to your computer. It lets you easily run and manage multiple VMs from a convenient interface when paired with virt-manager. With KVM set up, you'll have access to just about any operating system in a virtualized form, directly from your Ubuntu desktop.

kvm/setup_kvm_with_bridged_networking_and_virt-manager.1529317127.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki