bhyve No network connection from guest with vm-bhyve

I am having some difficulty getting vm-bhyve working. Actually, I am having difficulty getting bhyve to work at all, but I opted to try vm-bhyve because it seems easier to use and manage compared to the native tools.

I am trying to run a Linux guest (I have tried Ubuntu and Fedora) using vm-bhyve. I followed along with the quickstart guide on the vm-bhyve GitHub:

Code:
pkg install vm-bhyve grub2-bhyve uefi-edk2-bhyve
zfs create pool/vm
sysrc vm_enable="YES"
sysrc vm_dir="zroot/vm"
vm init
cp /usr/local/share/examples/vm-bhyve/* /mountpoint/for/pool/vm/.templates/
vm switch create public
vm switch add public em0
vm iso "www.download.com/fedora.iso"
vm create fedora
vm install fedora fedora.iso
vm console fedora

The virtual machine runs, but the console does nothing (although I think this is because Fedora doesn't have a text/terminal installer. Ubuntu does and I was able to get into the VM and go through the installation). But the bigger issue is that there's no network from the virtual machine.

Code:
root@server:/zroot/vm # vm list
NAME    DATASTORE  LOADER  CPU  MEMORY  VNC  AUTOSTART  STATE
fedora  default    grub    2    4096M   -    No         Bootloader (14361)
root@server:/zroot/vm # vm switch list
NAME    TYPE      IFACE      ADDRESS  PRIVATE  MTU  VLAN  PORTS
public  standard  vm-public  -        no       -    -     em0
root@server:/zroot/vm # vm switch info
------------------------
Virtual Switch: public
------------------------
  type: standard
  ident: vm-public
  vlan: -
  physical-ports: em0
  bytes-in: 772438 (754.333K)
  bytes-out: 94887323 (90.491M)

  virtual-port
    device: tap0
    vm: fedora
root@server:/zroot/vm # ifconfig
em0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=812099<RXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC,VLAN_HWFILTER>
    ether 44:39:c4:39:99:f8
    inet 192.168.1.19 netmask 0xffffff00 broadcast 192.168.1.255
    inet 192.168.1.101 netmask 0xffffffff broadcast 192.168.1.101
    inet 192.168.1.100 netmask 0xffffffff broadcast 192.168.1.100
    inet 192.168.1.102 netmask 0xffffffff broadcast 192.168.1.102
    inet6 fe80::4639:c4ff:fe39:99f8%em0 prefixlen 64 scopeid 0x1
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
    nd6 options=23<PERFORMNUD,ACCEPT_RTADV,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>
lo1: flags=8008<LOOPBACK,MULTICAST> metric 0 mtu 16384
    options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
    groups: lo
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
pflog0: flags=141<UP,RUNNING,PROMISC> metric 0 mtu 33160
    groups: pflog
vm-public: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    ether aa:ec:55:b9:82:1f
    id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
    maxage 20 holdcnt 6 proto stp-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 6 priority 128 path cost 2000000
    member: em0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
            ifmaxaddr 0 port 1 priority 128 path cost 20000
    groups: bridge vm-switch viid-4c918@
    nd6 options=1<PERFORMNUD>
tap0: flags=8903<UP,BROADCAST,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
    description: vmnet-fedora-0-public
    options=80000<LINKSTATE>
    ether 58:9c:fc:10:ff:89
    groups: tap vm-port
    media: Ethernet autoselect
    status: no carrier
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

I'm not sure where I'm going wrong. I can't find anything on how to get vm-bhyve to work other than the handful of wiki pages on the GitHub. Is there a reason my VM's don't have any networking? I am running PF but disabling it does nothing.
 
Can you show the VM's configuration? Is there a network0_type and network0_switch defined? When you booted the VM is there an eth0 or other interface showing up within the guest?
 
This is my fedora.conf file. It's just whatever defaults that vm-bhyve creates with the exception of graphics, and changing the bootloader to grub. I wanted to have a VNC connection to the VM.

Code:
root@server:/zroot/vm # cat fedora/fedora.conf
loader="grub"
cpu=2
memory=4096M
network0_type="virtio-net"
network0_switch="public"
disk0_type="virtio-blk"
disk0_name="fedora.img"
graphics="yes"
graphics_res="1600x900"
uuid="8d0069d2-7169-11eb-bf07-4439c43999f8"
network0_mac="58:9c:fc:08:35:a7"

I can't get into the VM to see if there is any network. When I run vm console fedora it gets 'stuck' and I have to kill my SSH session, so I'm not able to see if there is any sort of interface available from within the guest.
 
When I run vm console fedora it gets 'stuck' and I have to kill my SSH session,
You can exit the console session with ~. or ~^D (See cu(1)). Then you're back and use vm poweroff to force the VM off.

But this doesn't sound like an issue with the network, it's a boot issue. You can try setting loader="uefi" that seems to work better with modern Linux distributions. Also have a look at the Supported Guest Examples. Some distributions require some additional grub settings. But try the "uefi" boot first, maybe even add graphics="YES", then you can use VNC to connect to the VM (graphics only works in combination with uefi).
 
UEFI gets bast the bootloader issue, but when I try to get to a console it drops me into the UEFI shell of the VM.

Code:
root@server:~ # vm list
NAME    DATASTORE  LOADER  CPU  MEMORY  VNC           AUTOSTART  STATE
fedora  default    uefi    2    4096M   0.0.0.0:5900  No         Running (42675)
ubuntu  default    uefi    1    2048M   -             No         Running (73264)
root@server:~ # vm switch list
NAME    TYPE      IFACE      ADDRESS  PRIVATE  MTU  VLAN  PORTS
public  standard  vm-public  -        no       -    -     em0
root@server:~ #

Sorry, not sure if this should now be posted as separate issues, this is turning into a general support thread.
 
I decided to just delete any VMs I had created and try again using the example configs from here: https://github.com/churchers/vm-bhyve/wiki/Supported-Guest-Examples

I managed to get a Fedora 33 VM up and running by basically copy/pasting the example for a Debian UEFI guest from the link above.

Here is my fedora.conf file.

Code:
root@server:/zroot/vm # cat fedora/fedora.conf
loader="uefi"
cpu=2
memory=2G
network0_type="virtio-net"
network0_switch="public"
disk0_type="virtio-blk"
disk0_name="disk0.img"
disk0_size="25G"
graphics="yes"
xhci_mouse="yes"
graphics_res="1024x768"
uuid="312765ae-721d-11eb-bf07-4439c43999f8"
network0_mac="58:9c:fc:08:1d:ec"

Everything seems to be working for now.
 
Back
Top