# 17.1.概述

由于系统管理是一项复杂的任务，已经开发出许多工具以简化管理员的工作。这些工具常常用于改进系统的安装、配置和维护方式。其中一个可以用来增强 FreeBSD 系统安全性的工具就是 *jail*。从 FreeBSD 4.X 开始，jail 功能就已提供，并且在其实用性、性能、可靠性和安全性方面不断得到增强。

jail 建立在 [chroot(2)](https://man.freebsd.org/cgi/man.cgi?query=chroot\&sektion=2\&format=html) 的概念之上，chroot 用于更改一组进程的根目录。这种方式创建了一个与系统其余部分隔离的安全环境。在 chroot 环境中创建的进程无法访问其外部的文件或资源。因此，若某个运行在 chroot 环境中的服务被攻破，攻击者通常无法攻破整个系统。

然而，chroot 存在若干限制。它只适合一些简单任务，不适用于需要较强灵活性或高级特性的复杂场景。随着时间推移，人们发现了多种从 chroot 环境中逃逸的方法，这使得它不再是保护服务安全的理想方案。

jail 在多个方面改进了传统 chroot 环境的概念。

在传统 chroot 环境中，进程只在文件系统的可访问范围内受到限制。而系统的其他资源、系统用户、运行中的进程以及网络子系统，则是 chroot 进程与宿主系统进程共享的。jail 扩展了这一模型，虚拟化了对文件系统、用户集合和网络子系统的访问。它提供了更细粒度的控制，用于调整 jail 环境的访问权限。jail 可以被视为一种操作系统层级的虚拟化技术。

本章内容包括：

* jail 是什么，以及它在 FreeBSD 安装中的用途；
* 不同类型的 jail；
* 配置 jail 网络的不同方法；
* jail 配置文件；
* 如何创建不同类型的 jail；
* 如何启动、停止和重启 jail；
* 从 jail 内部与外部进行管理的基础知识；
* 如何升级不同类型的 jail；
* FreeBSD jail 管理工具的不完全列表。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.bsdcn.org/hanbook/di-17-zhang-jail-yu-rong-qi/17.1.-gai-shu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
