Bhyve on FreeBSD: From Basics to Advanced Networking
Introduction
Bhyve (pronounced "bee-hive") is the native hypervisor for FreeBSD. It offers a lean and efficient virtualization platform that is integrated into the base system. This post walks through its advantages, disadvantages, use cases, and practical setups, including advanced networking and routing scenarios.
Advantages
-
Native to FreeBSD
No need to install external hypervisors or depend on third-party vendors. -
Efficient resource usage
Runs with low overhead compared to many traditional hypervisors. -
Scalability
Capable of running lightweight services or large multi-VM environments. -
High customization
VM configuration can be fine-tuned at the command line or via automation tools. -
Learning opportunity
Excellent for practicing networking, routing, NAT, DHCP, and firewall rules. -
Stable integration
Part of the FreeBSD base, so updates and patches align with the system.
Disadvantages
-
Limited graphical management
Most tasks require command-line interaction unless using third-party tools. -
Hardware compatibility
Requires hardware with Intel VT-x or AMD-V support. -
No official Windows guest support pre-13.x
Later versions have improved this, but some limitations remain. -
Smaller community
While the FreeBSD community is strong, Bhyve-specific resources are fewer compared to something like KVM or VMware.
Potential Use Cases
-
Home lab environments
Simulate networks, run servers, and test configurations without dedicated hardware. -
Lightweight hosting
Host services such as web servers, DNS, or VPN endpoints. -
Learning platform
Practice FreeBSD system administration, routing, and firewalling. -
Isolated development
Test software in clean environments without affecting the host. -
Appliance hosting
Run pfSense, OPNsense, or other network appliances inside Bhyve.
Reasons to Avoid
- Need for polished GUI management
- Heavy reliance on Windows guest support in production
- Preference for hypervisors with larger enterprise adoption such as VMware or Hyper-V
Tooling
vm-bhyve
A popular management utility that simplifies Bhyve operations.
Features include:
- Template-based VM creation
- Simple network bridge management
- Autostart support
- CLI-based interface
Native CLI
FreeBSD includes bhyve and bhyvectl commands for manual configuration.
Ideal for advanced users who want full control over VM parameters.
Networking and Routing Learning Opportunities
With Bhyve, you can create tap interfaces, bridges, and VLANs to replicate real-world network setups. This is perfect for:
- Practicing NAT and firewall rules with
pf - Configuring DHCP servers for internal networks
- Building multi-subnet topologies
- Testing VLAN segmentation
Network Diagrams
1. Basic Bhyve VM with Bridge Networking
+----------------------+
| FreeBSD Host |
| +---------------+ |
Internet---em0 | |
| bridge0 |---tap0---- VM1 (FreeBSD/Linux)
+------------------+
- em0 = physical NIC
- tap0 = virtual NIC for VM1
- bridge0 connects the host NIC and VM NIC at Layer 2
2. Dual-NIC Router VM (WAN + LAN)
Internet
|
em0
|
+---------+
|bridge0 |---- tap0 (WAN) ------+
+---------+ |
|
Router VM
|
+---------+ |
|bridge1 |---- tap1 (LAN) ------+
+---------+
|
Other VMs (LAN Clients)
- tap0 (WAN) bridged to em0 for internet access
- tap1 (LAN) bridged to internal network (bridge1)
- Router VM can run pfSense, OPNsense, or FreeBSD with pf
3. VLAN Trunk to a VM
Physical Switch (VLAN 10, VLAN 20)
|
em0 (trunk port)
|
+--------+
|bridge0 |---- tap0 (VLAN trunk) --> Router/Firewall VM
+--------+
- VLAN tagging handled in host (ifconfig vlanXX) or inside VM
- Useful for simulating multi-VLAN environments
4. "Lab in a Box" Scenario
Internet
|
em0
|
+----------+
| bridge0 |---- tap0 (WAN) ---+
+----------+ |
Router VM
+----------+ |
| bridge1 |---- tap1 (LAN)+
+----------+
| |
| +--- tap2 --- VM2 (Client)
|
+--- tap3 --- VM3 (Client)
VLAN Trunk (Optional):
em0 --- vlan20 --- bridge2 --- tap4 --- Router VM (VLAN testing)
- Router VM handles NAT, DHCP, firewall rules
- Multiple clients on bridge1 simulate a LAN segment
- VLAN trunk (bridge2) for testing isolated networks
Example Quickstart with vm-bhyve
-
Install vm-bhyve:
pkg install vm-bhyve bhyve-firmware -
Load kernel modules:
kldload vmm kldload if_tap -
Create a mounpoint
zfs create -o mountpoint=/vm -o recordsize=64k zroot/vm -
Enable in
/etc/rc.conf:vm_enable="YES" vm_dir="zfs:zroot/vm" -
Initialize vm-bhyve:
vm init -
Create a switch:
vm switch create public vm switch add public em0 -
Create and start a VM:
vm create -t freebsd -s 10G testvm vm install -f testvm FreeBSD-13.2-RELEASE-amd64-disc1.iso
Scalability and Community Support
While the Bhyve community is smaller compared to KVM or VMware, it is dedicated and responsive. The FreeBSD mailing lists, forums, and IRC channels are great places to find help. For scaling, you can:
- Script VM creation and configuration
- Use ZFS for efficient storage management
- Combine with jail environments for mixed workloads
Final Thought
Bhyve is a powerful choice for those who value control, low overhead, and the opportunity to learn the internals of virtualization and networking. It is especially appealing for FreeBSD enthusiasts and self-hosters who prefer to avoid vendor lock-in.