User Tools

Site Tools


ubuntu:kvm:setup_kvm_with_bridged_networking_and_virt-manager

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ubuntu:kvm:setup_kvm_with_bridged_networking_and_virt-manager [2019/11/30 13:26] – created peterubuntu:kvm:setup_kvm_with_bridged_networking_and_virt-manager [2020/07/15 09:30] (current) – external edit 127.0.0.1
Line 4: Line 4:
  
  
-====== Install The Packages ======+===== 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. 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.
Line 11: Line 11:
  
 <code bash> <code bash>
-sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager+sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon virt-manager
 </code> </code>
  
 +----
 +
 +
 +===== Verify the status of the libvirtd status =====
 +
 +The **libvirtd** service should be started automatically. Check this:
 +
 +<code bash>
 +sudo systemctl status libvirtd.service
 +</code>
 +
 +----
 +
 +===== Start default network =====
 +
 +List available networks:
 +
 +<code bash>
 +sudo virsh net-list --all
 +</code>
 +
 +To make it active and auto-start across boots:
 +
 +<code bash>
 +sudo virsh net-start default
 +sudo virsh net-autostart default
 +</code>
 +
 +----
 +
 +===== Add vhost_net module =====
 +
 +To offload the mechanism of **virtio-net** and to improve performance of KVM VMs add the **vhost_net** kernel module.
 +
 +<code bash>
 +sudo modprobe vhost_net
 +
 +echo "vhost_net" | sudo tee -a /etc/modules vhost_net
 +
 +lsmod | grep vhost
 +</code>
  
 ---- ----
Line 56: Line 97:
     bridge_ports eth0     bridge_ports eth0
 </file> </file>
 +
 +or for a static IP address.
 +
 +<file bash /etc/network/interfaces>
 +auto lo br0
 +iface lo inet loopback
 +
 +auto ens33
 +iface ens33 inet manual
 +
 +auto br0
 +iface br0 inet static
 +        address 192.168.1.69
 +        netmask 255.255.255.0
 +        network 192.168.1.1
 +        broadcast 192.168.1.255
 +        gateway 192.168.1.1
 +        bridge_ports ens33
 +        bridge_stp off
 +        bridge_fd 0
 +        bridge_maxwait 0
 +        dns-nameservers 1.1.1.1
 +...
 +</file>
 +
 +
 +If netplan is used:
 +
 +<file bash /etc/netplan/01-network-manager-all.yaml>
 +# Let NetworkManager manage all devices on this system
 +network:
 +  version: 2
 +#  renderer: NetworkManager
 +  renderer: networkd
 +  ethernets:
 +    enp3s0:
 +      dhcp4: no
 +      # disable existing configuration for ethernet
 +      #addresses: [192.168.1.69/24]
 +      #gateway4: 192.168.1.1
 +      #nameservers:
 +        #addresses: [192.168.1.1]
 +      dhcp6: no
 +
 +  # add configuration for bridge interface
 +  bridges:
 +    br0:
 +      interfaces: [enp3s0]
 +      dhcp4: no
 +      addresses: [192.168.1.69/24]
 +      gateway4: 192.168.1.1
 +      nameservers:
 +        addresses: [192.168.1.2,192.168.1.1,1.1.1.1]
 +      parameters:
 +        stp: false
 +      dhcp6: no
 +</file>
 +
  
 <WRAP center round info> <WRAP center round info>
Line 95: Line 194:
  
 That's the best way to ensure that both the networking and user changes take effect. That's the best way to ensure that both the networking and user changes take effect.
 +
 +Alternatively, to refresh or reload group membership:
 +
 +<code bash>
 +newgrp libvirt
 +newgrp libvirt-qemu
 +</code>
 +
 +----
 +
 +===== Verify that the bridge has come up =====
 +
 +<code bash>
 +ip a s br0
 +</code>
  
 ---- ----
  
-====== Creating a VM ======+====== Create a VM using Virt-Manager (GUI) ======
  
 Use **virt-manager** to create VMs. Use **virt-manager** to create VMs.
Line 131: Line 245:
  
 ---- ----
 +
 +====== Create a VM from command line ======
 +
 +<code bash>
 +sudo virt-install \
 +  --name ubuntu-vm \
 +  --os-type linux \
 +  --os-variant ubuntu18.04 \
 +  --ram 2048 \
 +  --vcpu 1 \
 +  --disk path=/var/lib/libvirt/images/ubuntu-vm.qcow2,size=10 \
 +  --graphics vnc,listen=0.0.0.0 \
 +  --noautoconsole \
 +  --hvm \
 +  --cdrom /home/peter/vm/ubuntu-18.04-live-server-amd64.iso \
 +  --boot cdrom,hd
 +</code>
 +
 +----
 +
 +===== Find VNC display port for ubuntu-vm =====
 +
 +<code bash>
 +sudo virsh list --all
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Id    Name          State
 +------------------------------
 +1     ubuntu-vm     running
 +2     debian-vm     running
 +...
 +</code>
 +
 +----
 +or
 +
 +<code bash>
 +sudo virsh vncdisplay ubuntu-vm
 +</code>
 +
 +returns:
 +
 +<code bash>
 +:0
 +</code>
 +
 +Connect using Remote Desktop Viewer using IP address and VNC port as "0".
 +
 +----
 +
  
 ====== Closing Thoughts ====== ====== Closing Thoughts ======
ubuntu/kvm/setup_kvm_with_bridged_networking_and_virt-manager.1575120417.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki