Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
KVM Bridged with NetworkManager
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
marcelvs
n00b
n00b


Joined: 10 Sep 2005
Posts: 24

PostPosted: Mon Jul 18, 2011 11:52 pm    Post subject: KVM Bridged with NetworkManager Reply with quote

Hello, is there a way to create a virtual machine that is visible in a network with KVM and the host uses NetworkManager ?
Why that ? Because I want to create kvm guests in my notebook using the wlan0 interface. I noticed NetworkManager does not work with the TUN/TAP bridge ( because NM does not deal with the br0 interface ).
A nat solution was possible but I could not connect my guest from outside.
I tried a VDE network but VDE promisses a lot and it deliveres a little ( I read a lot of howtos and VDE makes everything I was already able to do easier but there is no plus, no way of tell to connect my host and guests in the outside network).
If some one have any idea I would be glad.

Thanks in advance,

Marcelo.
Back to top
View user's profile Send private message
Mad Merlin
Veteran
Veteran


Joined: 09 May 2005
Posts: 1155

PostPosted: Tue Jul 19, 2011 2:18 am    Post subject: Reply with quote

Most wireless cards don't work with bridging anyways. However, you can do a 1:1 static NAT (SNAT and DNAT the full range of ports for a private IP address to a regular IP alias on your LAN), something like this: http://forums.novell.com/suse/suse-product-discussion-forums/suse-linux-enterprise/suse-linux-enterprise-server-sles/sles-networking/412357-iptables-static-nat.html

Alternatively, you could try a routing approach to have guests communicate both ways, possibly something like this: http://tjworld.net/wiki/Linux/KvmQemuEasyRoutedNetwork
_________________
Game! - Where the stick is mightier than the sword!
Back to top
View user's profile Send private message
marcelvs
n00b
n00b


Joined: 10 Sep 2005
Posts: 24

PostPosted: Fri Jul 22, 2011 1:12 am    Post subject: Reply with quote

Mad Merlin wrote:
Most wireless cards don't work with bridging anyways. However, you can do a 1:1 static NAT (SNAT and DNAT the full range of ports for a private IP address to a regular IP alias on your LAN), something like this: http://forums.novell.com/suse/suse-product-discussion-forums/suse-linux-enterprise/suse-linux-enterprise-server-sles/sles-networking/412357-iptables-static-nat.html


Alternatively, you could try a routing approach to have guests communicate both ways, possibly something like this: http://tjworld.net/wiki/Linux/KvmQemuEasyRoutedNetwork

This one works partially, I could communicate between the VM and the host, but the routing did not work (no communication with my gateway ) . I think it might be something wrong with my configuration, kernel options, etc.


The nat stuff I did not try because I think the routing solution is the best solution. I think would be more clever to know why I cannot route packets. If there is some gentoo howto about routing ( not how to do a router ). I found some but it did not work. I am probably missing something.
The second step is to learn how to use wisely KVM ( with libvirt and virt-manager ) in order to be free of the ugly command line of KVM. I know RedHat works out-of-the-box with virt-manager, so I must be able to discover how with Gentoo.

Anyway, thanks for your help.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 14582

PostPosted: Fri Jul 22, 2011 2:16 am    Post subject: Reply with quote

How did you determine that the guest was not communicating with the gateway?
Back to top
View user's profile Send private message
marcelvs
n00b
n00b


Joined: 10 Sep 2005
Posts: 24

PostPosted: Fri Jul 22, 2011 11:07 am    Post subject: Reply with quote

Hu wrote:
How did you determine that the guest was not communicating with the gateway?

Because the guest was able to ping the host, but could not ping the gateway ( my router ) nor my other computer in the network. One other strange thing that happened was I could ssh to the guest but I could not mount a windows xp samba share from the guest in my host ( I tested with debian and Windows XP VMs). So locally I could do everything between host and guest, except samba shares and outside the host nothing worked.
Back to top
View user's profile Send private message
Mad Merlin
Veteran
Veteran


Joined: 09 May 2005
Posts: 1155

PostPosted: Sun Jul 24, 2011 2:55 am    Post subject: Reply with quote

That doesn't indicate that your wireless card bridged successfully. Assuming you gave the bridge itself an IP, your host can talk to the guest directly through it when the guest's tap is bridged into the bridge.
_________________
Game! - Where the stick is mightier than the sword!
Back to top
View user's profile Send private message
radzior
n00b
n00b


Joined: 19 May 2007
Posts: 12
Location: Katowice, PL

PostPosted: Mon Jun 10, 2013 8:45 am    Post subject: Reply with quote

networkmanager as of version 0.9.8 (not in the portage yet?) is now supposed to have support for bridging
Back to top
View user's profile Send private message
alinefr
Tux's lil' helper
Tux's lil' helper


Joined: 05 Jul 2009
Posts: 112
Location: São Paulo, Brasil

PostPosted: Mon Jun 10, 2013 8:48 pm    Post subject: Reply with quote

I did it with a tap interface in a laptop with wicd, but it didn't involve wicd at all (and it shouldn't involve network-manager, of course!)

My /etc/conf.d/net
Code:

preup() {
        if [ ${IFACE} = tap0 ]; then
                /usr/bin/tunctl -u aline -t ${IFACE} > /dev/null 2>&1
        fi
        return 0
}

postdown() {
        if [ ${IFACE} = tap0 ]; then
                /usr/bin/tunctl -d ${IFACE} > /dev/null 2>&1
        fi
        return 0
}
config_tap0="10.0.0.1 netmask 255.255.255.0 broadcast 192.168.254.255"


My iptables rules:

Code:

#!/bin/bash

IPTABLES='/sbin/iptables'
WLANIF=wlp2s0
ETHIF=eno1
TAPIF=tap0

$IPTABLES -t nat -A POSTROUTING -o $WLANIF -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -o $ETHIF -j MASQUERADE
$IPTABLES -I FORWARD 1 -i $TAPIF -j ACCEPT
$IPTABLES -I FORWARD 1 -o $TAPIF -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT


WLANIF and ETHIF are my wifi and wired interfaces, respectively.

Then, in the guest (Windows 7, my one) I did configure a static IP:
IP address: 10.0.0.2
netmask: 255.255.255.0
Gateway: 10.0.0.1

And started qemu-kvm with:
-net tap,ifname=tap0,script=no
Back to top
View user's profile Send private message
_______0
Guru
Guru


Joined: 15 Oct 2012
Posts: 521

PostPosted: Wed Jun 12, 2013 11:05 am    Post subject: Reply with quote

Mad Merlin wrote:
Most wireless cards don't work with bridging anyways. However, you can do a 1:1 static NAT (SNAT and DNAT the full range of ports for a private IP address to a regular IP alias on your LAN), something like this: http://forums.novell.com/suse/suse-product-discussion-forums/suse-linux-enterprise/suse-linux-enterprise-server-sles/sles-networking/412357-iptables-static-nat.html

Alternatively, you could try a routing approach to have guests communicate both ways, possibly something like this: http://tjworld.net/wiki/Linux/KvmQemuEasyRoutedNetwork



First link broken.

And question about the second one. Same procedure for ipv6? When a system has two nics for them to talk to each other and forgoing bridging solutions routing is the only way?

How to do this with ipv6?

thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum