Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
QEMU+macvtap network problem
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
alnash
n00b
n00b


Joined: 20 Nov 2016
Posts: 10

PostPosted: Tue Jan 14, 2020 8:47 am    Post subject: QEMU+macvtap network problem Reply with quote

Hi,

I have a laptop wirelessly connected to a home router which has a DHCP-server leasing local IPs like 192.168.1.XXX
On the laptop I have a VM with Ubuntu-18.04
Default NAT network works Ok, the VM has internet connection.
I've expected that with macvtap the VM will talk to the router directly, get its own local IP 192.168.1.YYY and will be seen as yet another machine on the local net.
But then I switch to macvtap in virt-manager -- there's no connection to the internet, no matter macvtap being bridge, vepa or private (passthrough refuses to work too, but it's because "the device is busy")

However, with 'ip link' and 'ifconfig -a' I can see 'macvtap0@wlp3s0' interface is up. Strangely, it gets a 169.254.x.x IP
As far as I can understand the macvtap interface works, but the VM doesn't see the router at all.
I don't see any errors in the logs and can't understand what else it wants...
Maybe besides macvtap and tun/tap some other kernel options must be enabled too? (I have a custom kernel with the most options switched off)
Back to top
View user's profile Send private message
alamahant
Tux's lil' helper
Tux's lil' helper


Joined: 23 Mar 2019
Posts: 124

PostPosted: Tue Jan 14, 2020 7:20 pm    Post subject: Reply with quote

Hi,
You should instead create and use a bridge if you wish to share the Host's network with the VM

Macvtap's do not seem to work.
Even Virtual Manager advises you that they might not work.

BUT you can not easily bridge wifi.
So you will need an ethernet iface to achieve this.

If you do then use the following:

Code:

nmcli con add autoconnect yes type bridge con-name br0 ifname br0 ip4 <ip-of bridge> gw4 <your-router>
nmcli con mod  br0 ipv4.dns <router-or-prefered-dns-ip> ipv4.method manual
nmcli con add autoconnect yes type bridge-slave con-name br0-slave1 ifname <device-name> master br0


Of course you need iptables and ebtables installed and enabled in the kernel AND
ip forwarding ALSO ENABLED in
/etc/sysctl.d

:D
Back to top
View user's profile Send private message
Ionen
Guru
Guru


Joined: 06 Dec 2018
Posts: 384

PostPosted: Tue Jan 14, 2020 9:03 pm    Post subject: Reply with quote

alamahant wrote:
Of course you need iptables and ebtables installed and enabled in the kernel
I don' t know for network manager, but you can do this with nftables and neither of those nowadays, most guides haven't updated to it though (Gentoo wiki included, although it does give a short summary for bridge+NAT networking, you could also try to setup a bridge directly open to the outside but that can be messy, and also insecure).

Personally I prefer to use a host dhcp server (with dnsmasq which I also use for DNS caching anyway) to assign my VMs' an IP address (plus I want them to use dnsmasq for DNS queries). And I allow their internet connection only on-demand with a nftable rule I "nft replace" on/off. If you're using IP-based forwarding rules, forwarding to a outside dhcp may also be a problem because they won't have an IP assigned yet for the rule to work :) 169.254.0.0/16 range is a fallback when the dhcp client couldn't find a server.

But that aside I don't use macvtap, or any kind of virtual/network managers (nor know how they set things up), so I probably can't help with those.
Back to top
View user's profile Send private message
nvaert1986
n00b
n00b


Joined: 05 May 2019
Posts: 56

PostPosted: Thu Jan 16, 2020 5:10 pm    Post subject: Reply with quote

MAC VTAP in combination with bridge mode works (for IPv4) and virt-manager if you compiled the correct kernel modules (it'll warn you about missing items when compiling Qemu and libvirt. Re-emerge them and it'll perform the checks.
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