> For the complete documentation index, see [llms.txt](https://handbook.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://handbook.bsdcn.org/di-35-zhang-gao-ji-wang-luo/35.6.-usb-wang-luo-gong-xiang.md).

# 35.6.USB 网络共享

许多手机提供通过 USB 分享数据连接的选项（通常称为“网络共享”）。此功能使用 RNDIS、CDC 或自定义的 Apple® iPhone®/iPad® 协议。

* Android™ 设备通常使用 [urndis(4)](https://man.freebsd.org/cgi/man.cgi?query=urndis\&sektion=4\&format=html) 驱动程序。
* Apple® 设备使用 [ipheth(4)](https://man.freebsd.org/cgi/man.cgi?query=ipheth\&sektion=4\&format=html) 驱动程序。
* 较旧的设备通常使用 [cdce(4)](https://man.freebsd.org/cgi/man.cgi?query=cdce\&sektion=4\&format=html) 驱动程序。

在连接设备之前，将适当的驱动程序加载到内核中：

```sh
# kldload if_urndis
# kldload if_cdce
# kldload if_ipheth
```

设备连接后，`ue0` 将作为正常的网络设备可用。确保在设备上启用了“USB 网络共享”选项。

为使此更改永久生效，并在引导时作为模块加载驱动程序，将适当的行添加到 **/boot/loader.conf** 文件中：

```sh
if_urndis_load="YES"
if_cdce_load="YES"
if_ipheth_load="YES"
```
