User Tools

Site Tools


ubuntu:kvm:install_and_configure_kvm

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ubuntu:kvm:install_and_configure_kvm [2020/08/10 23:00] 192.168.1.1ubuntu:kvm:install_and_configure_kvm [2020/08/10 23:33] (current) 192.168.1.1
Line 172: Line 172:
     link/ether 52:54:00:99:38:bc brd ff:ff:ff:ff:ff:ff     link/ether 52:54:00:99:38:bc brd ff:ff:ff:ff:ff:ff
 </code> </code>
 +
 +<WRAP info>
 +**NOTE:**  The entries **virbr0** and **virbr0-nic** are the KVM networks.
 +</WRAP>
 +
 +
 +----
 +
 +===== Remove the default KVM network =====
 +
 +<code bash>
 +virsh net-destroy default
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Network default destroyed
 +</code>
 +
 +----
 +
 +===== Undefine the default network =====
 +
 +<code bash>
 +virsh net-undefine default
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Network default has been undefined
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  If the above commands do not work for any reason, you can use these commands to disable and undefine KVM default network:
 +
 +<code bash>
 +sudo ip link delete virbr0 type bridge
 +sudo ip link delete virbr0-nic
 +</code>
 +
 +</WRAP>
 +
 +----
 +
 +===== Verify that the virbr0 and virbr0-nic interfaces are actually deleted =====
 +
 +
 +<code bash>
 +ip link
 +</code>
 +
 +returns:
 +
 +<code bash>
 +1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
 +    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
 +2: enp4s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
 +    link/ether b4:2e:99:3e:e5:20 brd ff:ff:ff:ff:ff:ff
 +3: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP mode DEFAULT group default qlen 1000
 +    link/ether b4:2e:99:3e:e5:22 brd ff:ff:ff:ff:ff:ff
 +4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
 +    link/ether b4:2e:99:3e:e5:22 brd ff:ff:ff:ff:ff:ff
 +5: wlp5s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DORMANT group default qlen 1000
 +    link/ether d0:ab:d5:91:98:3f brd ff:ff:ff:ff:ff:ff
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  The KVM default networks should be gone.
 +</WRAP>
 +
 +----
 +
 +===== Setup the KVM public bridge to use when creating a new VM =====
 +
 +<WRAP important>
 +**WARNING:**  Do not use wireless network interface cards for bridges.
 +
 +Most wireless interlaces do not support bridging.
 +
 +Always use wired network interfaces for seamless connectivity!
 +
 +</WRAP>
 +
 +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 /etc/netplan/01-network-manager-all.yaml{,.backup}
 +</code>
 +
 +</WRAP>
 +
 +
 +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/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.1,192.168.1.25]
 +      parameters:
 +        # stp: false
 +        stp: true
 +        forward-delay: 4
 +      dhcp6: no
 +</file>
 +
 +After modifying the network config file, save and close it.
 +
 +Apply the changes by running the following command:
 +
 +<code bash>
 +sudo netplan --debug  apply
 +</code>
 +
 +Now check if the IP address has been assigned to the bridge interface:
 +
 +<code bash>
 +ip a
 +</code>
 +
 +returns:
 +
 +<code bash>
 +1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
 +    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
 +    inet 127.0.0.1/8 scope host lo
 +       valid_lft forever preferred_lft forever
 +    inet6 ::1/128 scope host 
 +       valid_lft forever preferred_lft forever
 +2: enp4s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
 +    link/ether b4:2e:99:3e:e5:20 brd ff:ff:ff:ff:ff:ff
 +3: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
 +    link/ether b4:2e:99:3e:e5:22 brd ff:ff:ff:ff:ff:ff
 +4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
 +    link/ether b4:2e:99:3e:e5:22 brd ff:ff:ff:ff:ff:ff
 +    inet 192.168.1.69/24 brd 192.168.1.255 scope global br0
 +       valid_lft forever preferred_lft forever
 +    inet6 fe80::b62e:99ff:fe3e:e522/64 scope link 
 +       valid_lft forever preferred_lft forever
 +5: wlp5s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
 +    link/ether d0:ab:d5:91:98:3f brd ff:ff:ff:ff:ff:ff
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  The bridged network interface **br0** is assigned with IP address 192.168.1.69 and the enp3s0 entry now has an **master br0** entry.  It means that enp3s0 belongs to the bridge.
 +</WRAP>
 +
 +----
 +
 +===== Show the Bridge Status =====
 +
 +<code bash>
 +brctl show br0
 +</code>
 +
 +returns:
 +
 +<code bash>
 +bridge name bridge id STP enabled interfaces
 +br0 8000.b42e993ee522 yes enp3s0
 +</code>
 +
 +----
 +
 +===== Configure KVM to use the bridge =====
 +
 +Create a an XML file called **bridge.xml**.
 +
 +Add the following lines:
 +
 +<file bash bridge.xml>
 +<network>
 +  <name>br0</name>
 +  <forward mode="bridge"/>
 +  <bridge name="br0"/>
 +</network>
 +</file>
 +
 +
 +Start the newly created bridge and make it as default bridge for VMs.
 +
 +<code bash>
 +virsh net-define bridge.xml
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Network br0 defined from bridge.xml
 +</code>
 +
 +
 +Start the bridge.
 +
 +<code bash>
 +virsh net-start br0
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Network br0 started
 +</code>
 +
 +Configure the bridge to autostart each time the system reboots.
 +
 +<code>
 +virsh net-autostart br0
 +</code>
 +
 +returns
 +
 +<code bash>
 +Network br0 marked as autostarted
 +</code>
 +
 +----
 +
 +===== Verify that the bridge is active and started =====
 +
 +<code bash>
 +virsh net-list --all
 +</code>
 +
 +returns:
 +
 +<code bash>
 + Name   State    Autostart   Persistent
 +-----------------------------------------
 + br0    active   yes         yes
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  Congratulations!  The KVM bridge is active now.
 +</WRAP>
 +
  
ubuntu/kvm/install_and_configure_kvm.1597100450.txt.gz · Last modified: 2020/08/10 23:00 by 192.168.1.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki