Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Is this a bare metal hypervisor or do you use it as a workstation as well? –  kobaltz Feb 11 '13 at 3:37
    
At this time is a "hybrid" using. –  Sloan Feb 11 '13 at 16:11

3 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.

share|improve this answer
    
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 –  Sloan Feb 11 '13 at 18:44
    
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. pastie.org/6121088 –  Justin Feb 11 '13 at 23:01
    
I use virsh, and then editing vm config (edit vmname). Thank you for reply. –  Sloan Feb 12 '13 at 0:27

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)

share|improve this answer
    
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. –  Sloan Feb 13 '13 at 23:57

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.