在我的 FreeBSD 13 上使用 bhyve 模拟 Ubuntu 21.04 时无法连接到互联网

在我的 FreeBSD 13 上使用 bhyve 模拟 Ubuntu 21.04 时无法连接到互联网

我已经在 FreeBSD 13 上配置了 bhyve 的网络堆栈,如下所示,但 ubuntu VM 无法连接到互联网。

1) on /etc/rc.conf : gateway_enable="YES"
    
2) root@marietto:/home/marietto # sysctl net.inet.ip.forwarding=1
net.inet.ip.forwarding: 1 -> 1

3) root@marietto:/home/marietto # sysctl net.link.tap.up_on_open=1
net.link.tap.up_on_open: 1 -> 1

然后,在控制台上:

root@marietto:/home/marietto # kldload vmm

kldload: can't load vmm: module already loaded or in kernel

root@marietto:/home/marietto # ifconfig tap0 create up

root@marietto:/home/marietto # ifconfig bridge0 create up

root@marietto:/home/marietto # ifconfig bridge0 addm em0
ifconfig: BRDGADD em0: File exists

root@marietto:/home/marietto # ifconfig bridge0 addm tap0

root@marietto:/home/marietto/Desktop/Files/Bhyve/bhyve # ifconfig

em0: flags=8963<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=4810099<RXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,VLAN_HWFILTER,NOMAP>
ether e0:d5:5e:e2:1f:22
inet 192.168.1.6 netmask 0xffffff00 broadcast 192.168.1.255
media: Ethernet autoselect (1000baseT <full-duplex>)
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
inet 127.0.0.1 netmask 0xff000000
groups: lo
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 58:9c:fc:10:ff:b7
id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
member: tap0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
       ifmaxaddr 0 port 5 priority 128 path cost 2000000
member: em0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
       ifmaxaddr 0 port 1 priority 128 path cost 2000000
groups: bridge
nd6 options=9<PERFORMNUD,IFDISABLED>

vm-public: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether fe:40:5d:c8:de:75
id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
groups: bridge vm-switch viid-4c918@
nd6 options=9<PERFORMNUD,IFDISABLED>

tap0: flags=8903<UP,BROADCAST,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=80000<LINKSTATE>
ether 58:9c:fc:10:ff:8e
groups: tap
media: Ethernet autoselect
status: no carrier
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

我使用以下命令启动 ubuntu 21.04 VM:

bhyve -c 4 -m 8G -w -H \
        -s 0,hostbridge \
        -s 4,virtio-blk,/mnt/da1p1/vms/os/ubuntu-budgie-gpu/ubuntu-2104-gpu.img \
        -s 5,virtio-net,tap0 \
        -s 29,fbuf,tcp=0.0.0.0:5900,w=1440,h=900,wait \
        -s 30,xhci,tablet \
        -s 31,lpc -l com1,stdio \
        -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
        -s 6,hda,play=/dev/dsp8,rec=/dev/dsp8 \
        vm0

正如您从我所附的图片中看到的,Ubuntu VM 无法连接到互联网。你能帮我理解一下为什么吗?我确信Ubuntu有问题。

在此输入图像描述 在此输入图像描述 在此输入图像描述 在此输入图像描述

相关内容