Understanding FreeBSD jails: OS-level containerization that isolates processes, filesystems, and networking. You will create jails with jail(8), configure /etc/jail.conf, use jexec and jls, and use ezjail and bastille for modern management including per-jail VNET networking.

In the previous episode 14, you secured communication with OpenSSL and SSH. Now we get to one of FreeBSD's most distinctive features: jails — native containerization that isolates processes, filesystems, and networking at the OS level. Each jail has its own root, users, and network yet shares the kernel with the host — FreeBSD's way of running many "virtual servers" without the overhead of full virtualization.
A jail confines processes within it to a defined environment:
Info
Jails are different from Docker. Docker wraps processes in namespaces and cgroups, while a jail isolates an entire operating system environment on the same kernel. Jails are closer to a "lightweight VM" than a Docker-style container — stable and bootable like a small system.
The simplest jail needs its own root filesystem. The common way to provide it: using the base system via bsdinstall or a template, or sharing read-only via mount:
mkdir -p /usr/jails/www
bsdinstall jail /usr/jails/wwwbsdinstall jail installs a new base system into the jail directory — much like installing a mini FreeBSD for that jail.
Jails are configured in /etc/jail.conf:
www {
host.hostname = "www.example.local";
ip4.addr = "192.168.1.20";
path = "/usr/jails/www";
exec.start = "/bin/sh /etc/rc";
exec.consolelog = "/var/log/jail_www_console.log";
}With jail.conf ready, run and inspect it:
service jail start www
jls
jexec www ps auxjls shows all active jails with their JID and IP. jexec runs a command inside the jail — the way to "get into" that environment.
To enter as root inside the jail:
jexec www /bin/shezjail simplifies creating many jails with templates:
pkg install ezjail
sysrc ezjail_enable="YES"
ezjail-admin installCreate a jail from a template:
ezjail-admin create web01 "192.168.1.21"
ezjail-admin start web01
ezjail-admin console web01ezjail handles base jail creation, cloning, and day-to-day management with short commands.
Bastille is the newest generation — a modern CLI, ZFS support, templates, and flexible networking:
pkg install bastille
sysrc bastille_enable="YES"
service bastille startDownload the base system and create a container:
bastille bootstrap 15.1-RELEASE
bastille create web02 15.1-RELEASE 192.168.1.22
bastille start web02
bastille console web02Success
Bastille brings jails to the modern level: automatic ZFS snapshots, templates for rolling out uniform environments, and easy VNET networking. Whether for a homelab or production, Bastille is a highly recommended starting point.
In the default mode, a jail shares the host's network stack and only has its own IP on the host interface. The ip4.addr configuration in jail.conf is this form — simple and sufficient for most cases.
VNET gives each jail its own network stack complete with virtual interfaces:
vnet;
vnet.interface = "epair0b";
exec.prestart = "ifconfig epair0a create";
exec.prestart += "ifconfig epair0a up";
exec.poststart = "ifconfig bridge0 addm epair0a";With VNET, a jail can have its own interfaces, its own routing, and even run its own firewall — truly full network isolation.
Warning
VNET gives great power but also complexity: epair interfaces need to be attached to a host bridge, and routing inside the jail must be configured on its own. Start with shared networking, then move to VNET when isolation needs grow.
| Mode | Advantages | Disadvantages |
|---|---|---|
| Shared (IP on host) | Simple, lightweight | Limited network isolation |
| VNET | Full isolation, own firewall | More complex configuration |
rctl when needed.jls
jexec www zfs listIn this episode 15, you understood FreeBSD jails: the concept of OS-level isolation, creating them with jail(8), configuring /etc/jail.conf, the jls and jexec commands, and modern management with ezjail and bastille, including shared and VNET networking.
Key takeaways:
/etc/jail.conf; manage with service jail.jls inspects active jails; jexec enters them.In the next episode, episode 16, we'll cover bhyve & virtualization — FreeBSD's built-in type-2 hypervisor, using bhyve and bhyvectl, the vm-bhyve frontend, and the practice of installing Linux and FreeBSD VMs with UEFI, virtio storage, and tap/bridge networking.