Host-only-like interface in KVM

2

1

I just migrated from Virtualbox to KVM, everything is very good. But I've a little bit confused in network adapter type.

In Virtualbox I have host-only adapter, which are virtual nic (no bridge), and I can allocate this NIC to some virtual machine(s), so they can communicate each other, also NAT is easy (using iptables).

In KVM at this time I've using bridges, but is there host-only-like interface in KVM?

loadaverage

Posted 2013-02-11T03:06:09.877

Reputation: 325

Is this a bare metal hypervisor or do you use it as a workstation as well? – kobaltz – 2013-02-11T03:37:58.383

At this time is a "hybrid" using. – loadaverage – 2013-02-11T16:11:40.840

Answers

3

You can create another bridge interface, the same as you did for the one to connect to your main network, but don't attach any outside interfaces to it. Then assign your computer an IP on the bridge and the VMs and the host should be able to talk to it. i.e. exactly what the VirtualBox host-only adapter does.

Justin

Posted 2013-02-11T03:06:09.877

Reputation: 1 087

Thanks for reply, I can create bridge, but how I can create virtual iface to attach to it? With libvirt created network I can see this: brctl show bridge name bridge id STP enabled interfaces virbr1 8000.525400fd3bac yes virbr1-ni – loadaverage – 2013-02-11T18:44:16.220

Ah, are you using virt-manager or are you just editing the XML to create the VMs?

If you are using virt-manager, you should be able to click on add device and add a new network device, and select the virbr1 interface. If you are using XML, see the below code snippet, you should add this somewhere under the devices node; don't forget to set a MAC address/change source bridge to something for your environment. Also if you aren't using a linux VM you will want something other than virtio, unless you install the windows virtio drivers. http://pastie.org/6121088

– Justin – 2013-02-11T23:01:53.397

I use virsh, and then editing vm config (edit vmname). Thank you for reply. – loadaverage – 2013-02-12T00:27:11.370

2

Expanding on Justin's idea

I'm no genius, but this worked for me and you somewhat need to know what you are doing. host:Ubuntu 12.04. guest: Debian Testing (Jessie)

For Debian based systems configure the network interface by adding or editing the following in the host /etc/network/interfaces file (ifconfig -a is your friend):

auto br0
iface br0 inet static
        address 192.168.12.100
        netmask 255.255.255.0
        network 192.168.12.0
        broadcast 192.168.12.255
        bridge_ports none
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0

Restart networking on the host machine or just restart the computer. Then using virt-manager added the unbridged network device br0 to the network interface of the guest.

Then on the guest system you will have to assign a static IP address since there is no DHCP running on the br0 device. Setting a static IP address will depend on the OS.

For a Debian based guest you would edit /etc/network/interfaces and add:

auto eth0
iface eth0 inet static
            address 192.168.12.101
            netmask 255.255.255.0
            broadcast 192.168.12.255

I very much needed this setup and spent a couple of nights trying to find this through trial and error. You might need to change the numbers on the devices (br1 instead of br0, or eth1 instead of eth0). If your guest needs Internet access, then more setup will be needed.

The Sage Marmot

Posted 2013-02-11T03:06:09.877

Reputation: 21

1

To easily create virtual networks, you can install "virt-manager" by using the following command in Terminal

sudo apt-get install virt-manager

Once you install virt-manager, you can bring up the gui by running it from the command prompt or using the super key to bring up the search and searching for "virt-manager"

To create an interface, select localhost, and right-click and select "Details". From there, click on the "VIrtual Networks" tab and create a new interface. Everything is self-explanatory from there. Insure you select isolated network to keep the vm from using an external network.

Petronilla Escarabajo

Posted 2013-02-11T03:06:09.877

Reputation: 111

0

Read the Red Hat documentation in regards of creating bridges: https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-networkscripts-interfaces_network-bridge.html Even if you're not using something RHEL like it shows you basically what you have to do. After you created the bridge it should appear in your list of network interfaces in virt-manager. (don't forget to restart your network service and your libvirtd)

SKull

Posted 2013-02-11T03:06:09.877

Reputation: 11

Thanks for reply, but I'm not using any GUI for kvm (like virt-manager). I'm using Debian, but that article from redhat is good for me, thank you. Also at this time I focused to tap devices (using uml-utilities) instead bridge and this is very flexible thing. – loadaverage – 2013-02-13T23:57:30.770