如何在KVM / QEMU中桥接无线适配器?

时间:2019-03-27 13:37:43

标签: qemu arp

我的笔记本电脑安装了qemu-kvm,我希望我的来宾系统可以ping google,因此我想将来宾桥接到主机的无线适配器。我尝试了(> _ <),但失败了。 我的系统是debain_amd64,访客是ubuntu_server_amd64。

我的网络状态


    host# ip a
    1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host 
           valid_lft forever preferred_lft forever
    2: enp109s0f1:  mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
        link/ether 80:fa:5b:48:15:df brd ff:ff:ff:ff:ff:ff
    3: wlp110s0:  mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether 88:b1:11:22:c7:c0 brd ff:ff:ff:ff:ff:ff
        inet 10.242.101.213/17 brd 10.242.127.255 scope global dynamic noprefixroute wlp110s0
           valid_lft 27145sec preferred_lft 27145sec
        inet6 2001:250:3007:2:7056:9b16:afa5:aa8d/64 scope global dynamic noprefixroute 
           valid_lft 2592000sec preferred_lft 604800sec
        inet6 fe80::89ec:15e6:aa6f:6ffa/64 scope link noprefixroute 
           valid_lft forever preferred_lft forever

    host# ip route 
    default via 10.242.0.1 dev wlp110s0 proto dhcp metric 600 
    10.242.0.0/17 dev wlp110s0 proto kernel scope link src 10.242.101.213 metric 600 
    169.254.0.0/16 dev wlp110s0 scope link metric 1000 

    host# cat /etc/resolv.conf
    # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
    #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
    nameserver 10.10.232.34
    nameserver 202.116.32.254

    guest# ip a
    1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group defaul
    t qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
            valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host
            valid_lft forever preferred_lft forever
    2: ens3:  mtu 1500 qdisc fq_codel state UP grou
    p default qlen 1000
        link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
        inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic ens3
            valid_lft 86385sec preferred_lft 86385sec
        inet6 fec0::5054:ff:fe12:3456/64 scope site dynamic mngtmpaddr noprefixroute

            valid_lft 86387sec preferred_lft 14387sec
        inet6 fe80::5054:ff:fe12:3456/64 scope link
            valid_lft forever preferred_lft forever

我尝试过


    sudo iw dev wlp110s0 set 4addr on
    sudo ip link set wlp110s0 down
    sudo ip link set wlp110s0 up promisc on
    sudo ip link add name br0 type bridge
    sudo ip addr add 10.242.101.213/17 dev br0
    sudo ip link set br0 up
    sudo dnsmasq --interface=br0 --bind-interfaces --dhcp-range=10.242.101.1,10.242.101.255

    sudo modprobe tun
    sudo ip tuntap add dev tap0 mode tap user xxx
    sudo ip link set tap0 up promisc on
    sudo ip link set tap0 master br0

    qemu-system-x86_64 ~/VM/UnbuntuServer_amd64.img -enable-kvm -m 2048 -net nic,model=virtio -net tap,ifname=tap0,script=no

期望结果


    host# ping 10.242.101.144 #guest ok
    guest# ping 10.242.101.213 #host ok
    guest# ping www.google.com #ethernet ok
    others# ping 10.242.101.213 #host ok

但是


    host# ping 10.242.101.144 #guest ok
    guest# ping 10.242.101.213 #host ok
    guest# ping www.google.com #ethernet failed
    others# ping 10.242.101.213 #host failed

0 个答案:

没有答案