How can i create virtual network adapter like a physical eth0 in KVM? As I lack physical NICs.
Also I need a Host-only adapter just like in VMware to connect two VMs in KVM. What is possible solution to do this in KVM?
Please reply.
Thanks
kvm-virtualizationlinux-networkingubuntu-14.04virtualization
How can i create virtual network adapter like a physical eth0 in KVM? As I lack physical NICs.
Also I need a Host-only adapter just like in VMware to connect two VMs in KVM. What is possible solution to do this in KVM?
Please reply.
Thanks
Best Answer
Public bridging
If you have only one NIC on the KVM host and you want to have access for the VMs to main network attached to
eth0
interface you have to setup a public network bridge on top of your physical network interface (eth0
in the example):Without bridging you have something similar in
/etc/network/interfaces
:To setup a bridge replace the
eth0
part by:and
sudo ifup br0
or reboot the machine. Note thebridge_ports eth0
part, it links the bridge on your physical nic and give access to the bridge at the main network.Host-Only (Private bridging)
By creating a public bridge you can have your virtual machines have access between them by the network attached to
eth0
. If you need to have only access between VMs on the same host, you can use a private bridge (so you mantain youreth0
configuration and you don't bind your network interface to the bridge,bridge_ports none
). In your interfaces configuration files you'll have:and
sudo ifup br0
or reboot the machine.You can use the new created bridge, public or private (
br0
) as network device for KVM virtual machines. This step changes if you use vanilla qemu/kvm cli or if you use some management tools (virsh, virt-manager, ovirt, proxmox, etc.)Guest configuration
In both case you can configure your virtual machine like a normal host with a network interface on network, and you can have in
/etc/network/interfaces
something similar to (example for network 192.168.0.0/24):Some useful documentation: