Solved Using bhyve to run Kali

Greeting! I am considering taking a class locally in Cyber Security. This class will make use of the Kali distribution. I see a good opportunity to explore bhyve here, and I am hoping to install bhyve on my 14.4-RELEASE system, and then install a Kali Linux distribution as the guest software on that VM. It's pretty much all new to me, so I would like to know if anyone has done this, and if you have any tips for a novice. Any help and suggestion would be really appreciated.

I have never used Kali, but I suspect that it makes use of a graphic environment. I don't mind a command line interface at all -- that is how I do most of my FreeBSD work. But if a remote graphics setup can be made, that's icing on the cake. Note: By "remote" I mean something like what I presently do for some work: I write VHDL code from time to time, and use ghdl to compile and gtkwave to view simulations. I view those simulations on my MacBook air by running a (Quartz) xterm window with a command line like: xterm -e ssh -X foo@bar gtkwave design.ghw design.gtkw. I don't know if that could be done with Kali, and if not, I can cope with the CLI.

I do the remote viewing on the Mac because my FreeBSD systems are "headless", and I don't often need graphics. I run gimp this same way and it gets the job done.

Any pointers or suggestions are welcome. Thank you.
 
Long time ago, I set a Kali VM under bhyve. It worked and it's likely to still work.

I advise you to use sysutils/vm-bhyve even if I don't use it myself. It's a good and efficent wrapper around bhyve that will easier your life.

Use UEFI booting and don't forget to set uefi_vars=yes in its config file. You connect to the VM with a vnc client.
 
Kali is just another distribution of Linux. It does have some tools to make your life easier (venom generator). Not sure if pwntools is installed there by default. I personally never used it, I stayed true to my favorite Linux distribution. But Kali does make sense if you are starting to learn, you'll easily google information you need. I guess AI will be able to assist you easier too.

I can't personally advise on bhyve, The setup you've described should work though, there's no reason why not.
If you hit a problem with bhyve you still have /accelerated/ option - VirtualBox (though you can't mix two on a same host, they both use vmm).
Personally I'd run Kali on osx with VMware or UTM (qemu).

As always the best way to start tinkering with it is to go through handbook.
 
I am hoping to install bhyve on my 14.4-RELEASE system
No need to install it, it's included with the base OS.

Also highly recommend sysutils/vm-bhyve, it's a nice collection of wrapper scripts that make creating, configuring and running bhyve(8) VMs a breeze.

I have never used Kali, but I suspect that it makes use of a graphic environment.
Enable EFI boot and graphics for the VM. Then you can use a VNC viewer to connect to the VM's graphical console. Other than that, ssh X-forwarding could certainly be a viable option. If Kali supports that, not sure what it uses for graphics (Wayland or X11?).
 
I had installed kali under bhyve in 2024. Yesterday I did "apt update; apt full-upgrade" and it upgraded to kali 2026.3 from 2024.2 & kernel from 6.16.8 to 7.0.12 painlessly. startx brought up Xorg and Xfce (in a vnc window).
 
it of course depends what software you will be using, however, for anything graphical I do NOT recommend x-forwarding or vnc, use xrdp instead - simply install xrdp server on kali and use your remote desktop protocol client software.
 
Thanks to everyone for your input.

I followed the Handbook's instructions today for setting up a FreeBSD Host with bhyve and the section for Creating a Linux Guest. I am stuck in the process. The Handbook says that after I run grub-bhyve, the Linux kernel should be loaded and I can proceed with starting bhyve. This is where I am hung up. When I run grub-bhyve, the grub.cfg file is found and I get a menu for installing Kali. ( This is all done via sshd into the target machine. ) I select the Install option rather than the Graphical install option. The menu exits immediately. The host where I am installing happens to have a monitor attached at the moment, so I tried this at the monitor, with the exact same results. It also exits immediately with the Graphical Install option.

Here is what I did to set this up. Note the directory where I have the VM disk image also contains a copy of the installation .iso file.
( I omitted the network configuration steps from the listing below. )

Code:
root@dagobah:/home/matt # pkg install vm-bhyve
root@dagobah:/home/matt # kldload vmm
root@dagobah:/home/matt # mkdir /mnt/vm/kali
root@dagobah:/home/matt # cd /mnt/vm/kali
root@dagobah:/mnt/vm/kali # truncate -s 25G kali.img
root@dagobah:/mnt/vm/kali # pkg install grub2-bhyve
[matt@dagobah /mnt/vm/kali]$ cat device.map 
(hd0) ./kail.img
(cd0) ./kali-linux-2026.2-installer-amd64.iso

[matt@dagobah /mnt/vm/kali]$ lal
total 4691276
-rw-r--r--  1 matt wheel  4802531328 Aug  4 14:26 kali-linux-2026.2-installer-amd64.iso
drwxr-xr-x  3 root wheel         512 Aug  5 13:32 ..
-rw-r--r--  1 root wheel 26843545600 Aug  5 13:34 kali.img
drwxrwxrwx  2 root wheel         512 Aug  5 14:00 .
-rw-r--r--  1 matt wheel          63 Aug  5 14:01 device.map

root@dagobah:/mnt/vm/kali # grub-bhyve -m device.map -r cd0 -M 4096M kalivm

Again, I am looking for a suggestion to allow me to proceed. I don't see what I am doing wrong.

One other thing - the Handbook suggests that after running grub-bhyve, the Linux kernel
should be running, and the virtual machine can then be started. That seems odd to me -- I would think the
Linux kernel boots when the virtual machine starts.

But in any case the Kali distribution is not being installed. Their web page installation instructions did not give me any insight, unless having the .iso image on disk, and NOT on a CD-ROM is the issue.

Thanks for any help.
 
You don't need grub-bhyve. I did a fresh install just to check. This is what I used:
Code:
bhyve -c 1 \
        -s 0,hostbridge \
        -s 4,ahci-cd,kali-linux-2026.2-installer-amd64.iso \
        -s 5,nvme,kali.img \
        -s 10,virtio-net,tap1,mac=11:22:33:44:55:66 \
        -s 20,xhci,tablet \
        -s 31,lpc \
        -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
        -s 11,fbuf,tcp=0.0.0.0:5901,w=1920,h=1080 \
        -l com1,/dev/nmdm1B \
        -m 2G -H \
        kali
I chose the graphical install via a vnc window and basically chose all defaults. After installation, on restart it came up fine. I didn't even have to remove the .iso arg from the command line. Hope you can map these args for vm-bhyve (or someone here will help you). [I did this on a 15-stable system, should work on 14.4]
 
You don't need grub-bhyve. I did a fresh install just to check. This is what I used:
Code:
bhyve -c 1 \
        -s 0,hostbridge \
        -s 4,ahci-cd,kali-linux-2026.2-installer-amd64.iso.iso \
        -s 5,nvme,kali.img \
        -s 10,virtio-net,tap1,mac=11:22:33:44:55:66 \
        -s 20,xhci,tablet \
        -s 31,lpc \
        -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
        -s 11,fbuf,tcp=0.0.0.0:5901,w=1920,h=1080 \
        -l com1,/dev/nmdm1B \
        -m 2G -H \
        kali
I chose the graphical install via a vnc window and basically chose all defaults. After installation, on restart it came up fine. I didn't even have to remove the .iso arg from the command line. Hope you can map these args for vm-bhyve (or someone here will help you). [I did this on a 15-stable system, should work on 14.4]
bakul, thanks for the note. You have given me a few things to try: I will attempt to map this to vm-bhyve after I study its man page for a while. I will also give the VNC connection a try right from the start rather than doing the install via sshd. I'll give this a try tomorrow. The host machine does not have UEFI, so I will need to get that figured out. The curse of old hardware I suppose.

Thanks!
 
You just need to have edk2-bhyve installed.

Some people advised you to install vm-bhyve because it simplifies the first contact with bhyve, it's not without reason. And again, some people told you to use UEFI, because only UEFI make vnc connection to the VM possible.
 
here is my vm-bhyve configuration file:

loader="uefi
cpu=2
memory=8192M
network0_type="virtio-net"
network0_switch="public"
disk0_type="virtio-blk"
disk0_name="disk0.img"
uuid="f67252bf-79f0-41a3-952d-d3d78579b304"
network0_mac="58:9c:fc:0f:4c:b3"

graphics="yes"
graphics_listen="192.168.1.11"
graphics_port="5966"
graphics_vga=io

After installing that, "vm install kali /isos/kali-install.iso" should start the installation, and with a vncviewer you can connect (in my case to the LAN interface 192.168.1.11 port 5966") and install or use the kali live image.
 
I had a question for bakul - in your post you indicated you had success just doing an install, and you kindly provided the bhyve command line that you used. Another poster, Emrion stated that UEFI was required to make a VNC connection to the virtual machine. Can I assume that the line -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd gives the VM access to an emulated UEFI interface inside the VM? If that is the case, then all I need to do is get a copy of that file, load it up on the host and give it a try. Thank you both for your help.
 
I could not wait so I decided to try. I ran bhyve, the exact command line is below. It did start, and reported the following: fbuf frame buffer base: 0x104701800000 [sz 16777216]

I then tried to connect a VNC viewer to it - this is the VNC viewer built-in to MacOS. It asked for a password, and then hangs trying to connect to the VNC server. I specified the IP address of the host running the virtual machine.

Here is the command:
Code:
root@dagobah:/mnt/vm/kali # bhyve -H -P -s 0,hostbridge \
-s 1,lpc \
-s 2,virtio-net,tap0 \
-s 3,virtio-blk,./kali.img \
-s 4,ahci-cd,./kali-linux-2026.2-installer-amd64.iso \
-s 5,fbuf,tcp=0.0.0.0:5900,w=1920,h=1080 \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
-c 2 -m 4G kalivm

On the fbuf option line, I also tried the explicit IP address of the host. It did not work either. I checked with sockstat and verified that bhyve was indeed bound to socket 5900 and listening. So I am at a loss to explain why I cannot connect a VNC viewer to the virtual machine. Both the MacOS machine the host are on the same side of the firewall.

I notice when I run ifconfig that the tap0 and the bridge0 have no IP associated with them, but the bridge does connect tap0 to the hardware igb0 interface. It looks like when the bridge and tap were created, they were assigned random MAC addresses - certainly not any MAC address associated with hardware on the machine. Could that be an issue?

I feel like I am getting closer....
 
Can I assume that the line -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd gives the VM access to an emulated UEFI interface inside the VM? If that is the case, then all I need to do is get a copy of that file, load it up on the host and give it a try.
Correct. pkg install edk2-bhyve
To debug nvc conn issues, run “netstat -na -4 | grep 5900” on the bhyve host to see if something is actually listening at that port. If you are using x windows on the bhyve, it will use 5900. Try some other port like 5901 etc.
 
Correct. pkg install edk2-bhyve
To debug nvc conn issues, run “netstat -na -4 | grep 5900” on the bhyve host to see if something is actually listening at that port. If you are using x windows on the bhyve, it will use 5900. Try some other port like 5901 etc.
Thanks. I did run sockstat -4 -l -p 5900 and it reported that bhyve was listening on that port. I haven't gotten to the point where X is running on bhyve -- still trying to install kali there.

Looking at the vm-bhyve script - it looks like I may try that for the next go at installation.

Should my bridge have an IP assigned to it? Or will the IP of the interface igb0 which the bridge connects to be sufficient?
 
Note that any host bridge has nothing to do with a vnc connection. bhyve itself will accept a vnc connection from another machine. Even if you emulate no ethernet port in the vm, you should be able to get a vnc connection. if bhyve is listening on port 5900, the issue may be on the vnc client on the mac. may be checked options on that program?
 
Ok, marking this as solved, as I can now see the Kali installation menu on a vnc window. Note, the "built-in" VNC client on the MacOS, accessible from its "Finder" is pure S&*t, i.e., if the server is not another Mac, it is not likely to work. I downloaded TigerVNC on the Mac and it works like a champ. Thanks to everyone for the patience and help.
 
here is my vm-bhyve configuration file:



After installing that, "vm install kali /isos/kali-install.iso" should start the installation, and with a vncviewer you can connect (in my case to the LAN interface 192.168.1.11 port 5966") and install or use the kali live image.

I just wanted to say that I tried to get a current kali live image, but that is only available by bit-torrent. No thanks, that was a painful exercise.
 
Back
Top