ubuntu:kvm:install_and_configure_kvm
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ubuntu:kvm:install_and_configure_kvm [2020/08/10 23:00] – 192.168.1.1 | ubuntu:kvm:install_and_configure_kvm [2020/08/10 23:33] (current) – 192.168.1.1 | ||
---|---|---|---|
Line 172: | Line 172: | ||
link/ether 52: | link/ether 52: | ||
</ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Remove the default KVM network ===== | ||
+ | |||
+ | <code bash> | ||
+ | virsh net-destroy default | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | Network default destroyed | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Undefine the default network ===== | ||
+ | |||
+ | <code bash> | ||
+ | virsh net-undefine default | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | Network default has been undefined | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | <code bash> | ||
+ | sudo ip link delete virbr0 type bridge | ||
+ | sudo ip link delete virbr0-nic | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Verify that the virbr0 and virbr0-nic interfaces are actually deleted ===== | ||
+ | |||
+ | |||
+ | <code bash> | ||
+ | ip link | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | 1: lo: < | ||
+ | link/ | ||
+ | 2: enp4s0: < | ||
+ | link/ether b4: | ||
+ | 3: enp3s0: < | ||
+ | link/ether b4: | ||
+ | 4: br0: < | ||
+ | link/ether b4: | ||
+ | 5: wlp5s0: < | ||
+ | link/ether d0: | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Setup the KVM public bridge to use when creating a new VM ===== | ||
+ | |||
+ | <WRAP important> | ||
+ | **WARNING: | ||
+ | |||
+ | Most wireless interlaces do not support bridging. | ||
+ | |||
+ | Always use wired network interfaces for seamless connectivity! | ||
+ | |||
+ | </ | ||
+ | |||
+ | To create a network bridge in host, edit **01-network-manager-all.yaml** file and add the bridge details. | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE:** Before editing this file, back it up. | ||
+ | |||
+ | <code bash> | ||
+ | sudo cp / | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | Now edit similar to the following. | ||
+ | |||
+ | <file bash 01-network-manager-all.yaml> | ||
+ | Let NetworkManager manage all devices on this system | ||
+ | #network: | ||
+ | # version: 2 | ||
+ | # renderer: NetworkManager | ||
+ | |||
+ | # 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/ | ||
+ | #gateway4: 192.168.1.1 | ||
+ | # | ||
+ | #addresses: [192.168.1.1] | ||
+ | dhcp6: no | ||
+ | |||
+ | # add configuration for bridge interface | ||
+ | bridges: | ||
+ | br0: | ||
+ | interfaces: [enp3s0] | ||
+ | dhcp4: no | ||
+ | addresses: [192.168.1.69/ | ||
+ | gateway4: 192.168.1.1 | ||
+ | nameservers: | ||
+ | addresses: [192.168.1.1, | ||
+ | parameters: | ||
+ | # stp: false | ||
+ | stp: true | ||
+ | forward-delay: | ||
+ | dhcp6: no | ||
+ | </ | ||
+ | |||
+ | After modifying the network config file, save and close it. | ||
+ | |||
+ | Apply the changes by running the following command: | ||
+ | |||
+ | <code bash> | ||
+ | sudo netplan --debug | ||
+ | </ | ||
+ | |||
+ | Now check if the IP address has been assigned to the bridge interface: | ||
+ | |||
+ | <code bash> | ||
+ | ip a | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | 1: lo: < | ||
+ | link/ | ||
+ | inet 127.0.0.1/8 scope host lo | ||
+ | | ||
+ | inet6 ::1/128 scope host | ||
+ | | ||
+ | 2: enp4s0: < | ||
+ | link/ether b4: | ||
+ | 3: enp3s0: < | ||
+ | link/ether b4: | ||
+ | 4: br0: < | ||
+ | link/ether b4: | ||
+ | inet 192.168.1.69/ | ||
+ | | ||
+ | inet6 fe80:: | ||
+ | | ||
+ | 5: wlp5s0: < | ||
+ | link/ether d0: | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Show the Bridge Status ===== | ||
+ | |||
+ | <code bash> | ||
+ | brctl show br0 | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | bridge name bridge id STP enabled interfaces | ||
+ | br0 8000.b42e993ee522 yes enp3s0 | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Configure KVM to use the bridge ===== | ||
+ | |||
+ | Create a an XML file called **bridge.xml**. | ||
+ | |||
+ | Add the following lines: | ||
+ | |||
+ | <file bash bridge.xml> | ||
+ | < | ||
+ | < | ||
+ | <forward mode=" | ||
+ | <bridge name=" | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | |||
+ | Start the newly created bridge and make it as default bridge for VMs. | ||
+ | |||
+ | <code bash> | ||
+ | virsh net-define bridge.xml | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | Network br0 defined from bridge.xml | ||
+ | </ | ||
+ | |||
+ | |||
+ | Start the bridge. | ||
+ | |||
+ | <code bash> | ||
+ | virsh net-start br0 | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | Network br0 started | ||
+ | </ | ||
+ | |||
+ | Configure the bridge to autostart each time the system reboots. | ||
+ | |||
+ | < | ||
+ | virsh net-autostart br0 | ||
+ | </ | ||
+ | |||
+ | returns | ||
+ | |||
+ | <code bash> | ||
+ | Network br0 marked as autostarted | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Verify that the bridge is active and started ===== | ||
+ | |||
+ | <code bash> | ||
+ | virsh net-list --all | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | | ||
+ | ----------------------------------------- | ||
+ | | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
ubuntu/kvm/install_and_configure_kvm.1597100450.txt.gz · Last modified: 2020/08/10 23:00 by 192.168.1.1