That said, you can share your VM’s desktop over your network with VNC. That will allow you to access your VMs from anywhere on your local network. VNC is a desktop sharing protocol that allows a Linux system to output its graphical desktop over a network (much like the Remote Desktop Connections in Windows). This way you can open up the desktop on another computer and interact with it directly like you would if you were sitting in front of it. There are a bunch of ways to handle this. This guide will focus on Ubuntu and will use TigerVNC. If you have other preferences, you can definitely adjust accordingly.
Install the Packages
Before you get started, you’re going to need to install the required packages. Most virtualization is done through the kernel itself, so there isn’t much else that you need. On the Server The server, in this case, refers to the computer that is running the virtual machine. On the Client The client, in this case, refers to the computer that is remotely accessing the computer with the VM.
Set Up a Network Bridge
Network bridging isn’t strictly necessary for virtual machines, but it is very useful, and it makes them behave like physical machines on your network. This part isn’t too difficult, but you probably shouldn’t do it remotely over SSH since you will need to restart after the process. On the server machine, start by looking up the name of your network interface. Run ip a to see which network interface your computer is using. Once you have it, use your favorite text editor with sudo to open “/etc/network/interfaces.” Make it look similar to this: Replace “eth0” with the name of your interface. If you have multiple ones in use, you can list them separated by a single space. When your file is ready, save and exit. It’s best to restart your computer after this to apply the change.
Create a VM
There is a direct way to create your virtual machines from the command line. Of course, if you really don’t want to, you can use a tool like virt-manager to make the VMs, but you’ll need to modify them later. If you’re planning to go the command line route, it’s not that hard. There are a lot of options, but you certainly don’t need all of them. The command for creating your virtual machine is fairly complex. There are a lot of options, and that amount can increase with the complexity of the machine. Start with naming the machine. Set the amount of memory in megabytes and the number of CPU cores. Next, tell it how much hard drive space to allocate in gigabytes and where the “.iso” file is that it’ll be installing from. You’ll also need to tell it to make graphics available over VNC. Use the defaults and configure it like this: Finally, tell it to use your network bridge.
Put it all together, and you’ll get a command something like this one:
Connect Over VNC
On the client machine open up TigerVNC. It will probably be called “vncviewer” on your system. The window is very simple. Enter in the IP address of your server and connect.
A second window will open up to your VM. Use the controls on the side to resize your VM window to your liking. Then, finish the installation of your VM. When your install is done, you can use your VM like you would any other (or the native desktop). After you shut it down, you can restart it via virsh and connect again over VNC like you did here. That’s it! You can now create and run virtual machines with graphical desktops remotely over your network.