> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/handbook/di-18-zhang-oci-rong-qi/18.17.-gu-zhang-pai-chu.md).

# 18.17.故障排除

## 18.17.1. 软件包升级与挂载的文件

Podman 使用 [mount\_nullfs(8)](https://man.freebsd.org/cgi/man.cgi?query=mount_nullfs\&sektion=8\&format=html) 将 **/etc/resolv.conf** 和 **/etc/hosts** 挂载到容器中。在 [pkg(8)](https://man.freebsd.org/cgi/man.cgi?query=pkg\&sektion=8\&format=html) 操作期间，这些挂载可能导致错误，并出现类似 `Cross-device link` 的消息：

```sh
pkg: Fail to rename /etc/.pkgtemp.hosts.VeIDrHM0sKN5 -> /etc/hosts:Cross-device link
```

要避免此问题，请使用 `--no-hosts` 与 `--dns` 选项：

```sh
# podman run --no-hosts --dns 1.1.1.1 -it --rm \
    ghcr.io/freebsd/freebsd-runtime:15.1 /bin/sh
```

## 18.17.2. 检查网络

从 **/usr/local/etc/containers/pf.conf.sample** 中的防火墙规则开始。在容器内逐步测试连通性：

```sh
# podman run --no-hosts --dns 1.1.1.1 \
    --env ASSUME_ALWAYS_YES=1 \
    -it --rm \
    ghcr.io/freebsd/freebsd-runtime:15.1 \
    /bin/sh

# route show 1.1.1.1
   route to: 1.1.1.1
destination: default
    gateway: 10.88.0.1
  interface: eth0

# ping -c 3 10.88.0.1
PING 10.88.0.1 (10.88.0.1): 56 data bytes
64 bytes from 10.88.0.1: icmp_seq=0 ttl=64 time=0.083 ms
...

# ping -c 3 1.1.1.1
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: icmp_seq=0 ttl=60 time=0.920 ms
...

# fetch -v http://1.1.1.1/
...

# pkg -dd bootstrap -r FreeBSD
```

如果 [ping(8)](https://man.freebsd.org/cgi/man.cgi?query=ping\&sektion=8\&format=html) 失败，请检查防火墙规则是否阻止了 ICMP。如果 [fetch(1)](https://man.freebsd.org/cgi/man.cgi?query=fetch\&sektion=1\&format=html) 失败，请检查防火墙规则是否阻止了端口 80 和 443 上的 TCP。如果 [pkg(8)](https://man.freebsd.org/cgi/man.cgi?query=pkg\&sektion=8\&format=html) 失败而 ICMP 和 TCP 正常，则可能是分片或 MTU 问题。将 `set reassemble yes no-df` 添加到 **/etc/pf.conf** 并重启防火墙。

要调试被阻止的数据包，请在 **/etc/pf.conf** 的所有 block 规则上启用 `log`，并在 [pflog(4)](https://man.freebsd.org/cgi/man.cgi?query=pflog\&sektion=4\&format=html) 设备上使用 [tcpdump(1)](https://man.freebsd.org/cgi/man.cgi?query=tcpdump\&sektion=1\&format=html)：

```sh
# service pflog onerestart
# tcpdump -vvveni pflog0 icmp or net 10.88.0.0/16
```

## 18.17.3. MTU 一致性

确保主网络接口、容器网桥和容器自身的 MTU 值保持一致。MTU 值不匹配可能导致数据包分片和连接故障。

下例中，`vtnet0` 的 MTU 为 9000，而网桥和容器的 MTU 为 1500。一般应调整内部布局以与外部网络保持一致：

```sh
# ifconfig vtnet0 mtu 9000
# ifconfig cni-podman0 mtu 9000
```

在容器内：

```sh
# ifconfig eth0 mtu 9000
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://book.bsdcn.org/handbook/di-18-zhang-oci-rong-qi/18.17.-gu-zhang-pai-chu.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
