ubuntu:kvm:setup_kvm_with_bridged_networking_and_virt-manager
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ubuntu:kvm:setup_kvm_with_bridged_networking_and_virt-manager [2019/12/26 17:19] – peter | ubuntu: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 14: | Line 14: | ||
</ | </ | ||
+ | ---- | ||
+ | |||
+ | |||
+ | ===== Verify the status of the libvirtd status ===== | ||
+ | |||
+ | The **libvirtd** service should be started automatically. Check this: | ||
+ | |||
+ | <code bash> | ||
+ | sudo systemctl status libvirtd.service | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Start default network ===== | ||
+ | |||
+ | List available networks: | ||
+ | |||
+ | <code bash> | ||
+ | sudo virsh net-list --all | ||
+ | </ | ||
+ | |||
+ | To make it active and auto-start across boots: | ||
+ | |||
+ | <code bash> | ||
+ | sudo virsh net-start default | ||
+ | sudo virsh net-autostart default | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== 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 " | ||
+ | |||
+ | lsmod | grep vhost | ||
+ | </ | ||
---- | ---- | ||
Line 56: | Line 97: | ||
bridge_ports eth0 | bridge_ports eth0 | ||
</ | </ | ||
+ | |||
+ | or for a static IP address. | ||
+ | |||
+ | <file bash / | ||
+ | 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 | ||
+ | ... | ||
+ | </ | ||
+ | |||
If netplan is used: | If netplan is used: | ||
Line 128: | 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, | ||
+ | |||
+ | <code bash> | ||
+ | newgrp libvirt | ||
+ | newgrp libvirt-qemu | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Verify that the bridge has come up ===== | ||
+ | |||
+ | <code bash> | ||
+ | ip a s br0 | ||
+ | </ | ||
---- | ---- | ||
- | ====== | + | ====== |
Use **virt-manager** to create VMs. | Use **virt-manager** to create VMs. | ||
Line 164: | 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=/ | ||
+ | --graphics vnc, | ||
+ | --noautoconsole \ | ||
+ | --hvm \ | ||
+ | --cdrom / | ||
+ | --boot cdrom,hd | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Find VNC display port for ubuntu-vm ===== | ||
+ | |||
+ | <code bash> | ||
+ | sudo virsh list --all | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | Id Name State | ||
+ | ------------------------------ | ||
+ | 1 | ||
+ | 2 | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | or | ||
+ | |||
+ | <code bash> | ||
+ | sudo virsh vncdisplay ubuntu-vm | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | :0 | ||
+ | </ | ||
+ | |||
+ | Connect using Remote Desktop Viewer using IP address and VNC port as " | ||
+ | |||
+ | ---- | ||
+ | |||
====== Closing Thoughts ====== | ====== Closing Thoughts ====== |
ubuntu/kvm/setup_kvm_with_bridged_networking_and_virt-manager.1577380796.txt.gz · Last modified: 2020/07/15 09:30 (external edit)