Академический Документы
Профессиональный Документы
Культура Документы
There are many choices for network con gurations in the KVM host. In this post, I’ll guide you
through two main choices to con gure KVM networking. We’ll consider internal networking and
external networking for Guest operating systems running on KVM.
The other available ways to con gure KVM networking that we won’t cover on this post are:
Using this method to con gure KVM networking is simple and straightforward.
The quickest way to get started is by utilizing existing default network con guration. Dump
default network xml con guration using below command.
You can edit this le accordingly and use it to de ne new network interface
Have a look at below le for general overview of how the le should look like:
<network>
<name>br1</name>
https://computingforgeeks.com/managing-kvm-network-interfaces-in-linux/ 1/6
10/19/2019 Configure KVM Networking With virsh, nmcli and brctl in Linux - Computing for Geeks
<forward mode='nat'>
<nat>
<port start='1024' end='65535'/>
</nat>
</forward>
<bridge name='br1' stp='on' delay='0'/>
<ip address='192.168.10.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.10.10' end='192.168.10.100'/>
</dhcp>
</ip>
</network>
Check to Con rm if autostart ag is turned to yes – Persistent should read yes as well.
https://computingforgeeks.com/managing-kvm-network-interfaces-in-linux/ 2/6
10/19/2019 Configure KVM Networking With virsh, nmcli and brctl in Linux - Computing for Geeks
You can use brctl command provided by bridge-utils package to check available bridges on
your Linux system
Attaching an interface to a VM
In this example, I’ll attach br1 interface to the vm pxe that will be con gured as Preboot
eXecution Environment server.
This takes e ect immediately, and the NIC will be persistent on further reboots.
Attach the interface as below:
Removing a network
https://computingforgeeks.com/managing-kvm-network-interfaces-in-linux/ 3/6
10/19/2019 Configure KVM Networking With virsh, nmcli and brctl in Linux - Computing for Geeks
A network bridge is a Link Layer device which forwards tra c between networks based on MAC
addresses and is therefore also referred to as a Layer 2 device. It makes forwarding decisions
based on tables of MAC addresses which it builds by learning what hosts are connected to each
network.
A software bridge can be used within a Linux host in order to emulate a hardware bridge, for
example in virtualization applications for sharing a NIC with one or more virtual NICs.
To create a Linux bridge called br0 using nmcli, run the following commands:
nmcli con add type bridge con-name br0 ifname br0 autoconnect yes
This example demonstrates adding a bridge master connection and one slave.
https://computingforgeeks.com/managing-kvm-network-interfaces-in-linux/ 4/6
10/19/2019 Configure KVM Networking With virsh, nmcli and brctl in Linux - Computing for Geeks
The rst command adds a master bridge connection, naming the bridge interface and the
pro le as br0 .
The second command add slaves pro le enslaved to br0 . The slave will be tied
to ens3 interface.
The last command will disable 802.1D STP for the br0 pro le.
Furthe modify the bridge to enable autoconnect, add ipv4 address and gateway:
If you don’t have networkmanager installed, you can use brctl command installed with the
installation of bridge-utils to con gure Linux bridge that we’ll use to con gure KVM
networking.
Assigning an IP address:
Show current bridges and what interfaces they are connected to:
$ brctl show
https://computingforgeeks.com/managing-kvm-network-interfaces-in-linux/ 5/6
10/19/2019 Configure KVM Networking With virsh, nmcli and brctl in Linux - Computing for Geeks
https://wiki.libvirt.org/page/VirtualNetworking
http://www.linux-kvm.org/page/Networking
IBM – KVM knowledgecenter
man 5 nmcli-examples
virsh commands cheatsheet to manage KVM guest virtual machines
Further reading:
Josphat Mutai
https://computingforgeeks.com/
https://computingforgeeks.com/managing-kvm-network-interfaces-in-linux/ 6/6