# 30.5.使用 ATM 上的 PPP (PPPoA)

以下内容介绍如何设置 PPPoA（ATM 上的 PPP）。PPPoA 在欧洲的许多 DSL 服务提供商中非常流行。

## 30.5.1. 使用 mpd

mpd 应用程序可用于连接多种服务，特别是 PPTP 服务。可以通过安装 [net/mpd5](https://cgit.freebsd.org/ports/tree/net/mpd5/) 软件软件包和 Ports 来安装。许多 ADSL 调制解调器要求在调制解调器和计算机之间建立一个 PPTP 隧道。

安装完成后，根据提供商的设置配置 mpd。该 Port 会在 **/usr/local/etc/mpd/** 目录下放置一组配置文件，这些文件有详细的文档说明。有关如何配置 mpd 的完整指南可在 **/usr/ports/shared/doc/mpd/** 中以 HTML 格式找到。以下是连接到 ADSL 服务的 mpd 示例配置。配置分为两个文件，第一个是 **mpd.conf**：

> **技巧**
>
> 此示例 **mpd.conf** 仅适用于 mpd 4.x 版本。

```ini
default:
    load adsl

adsl:
    new -i ng0 adsl adsl
    set bundle authname username ①
    set bundle password password ②
    set bundle disable multilink

    set link no pap acfcomp protocomp
    set link disable chap
    set link accept chap
    set link keep-alive 30 10

    set ipcp no vjcomp
    set ipcp ranges 0.0.0.0/0 0.0.0.0/0

    set iface route default
    set iface disable on-demand
    set iface enable proxy-arp
    set iface idle 0

    open
```

* ① 用于与 ISP 进行身份验证的用户名。
* ② 用于与 ISP 进行身份验证的密码。

有关要建立的连接的更多信息，请参阅 **mpd.links**。以下是与上面示例相配合的 **mpd.links** 示例：

```sh
adsl:
    set link type pptp
    set pptp mode active
    set pptp enable originate outcall
    set pptp self 10.0.0.1 ①
    set pptp peer 10.0.0.138 ②
```

* ① 运行 mpd 的 FreeBSD 计算机的 IP 地址。
* ② ADSL 调制解调器的 IP 地址。Alcatel SpeedTouch™ Home 的默认地址为 `10.0.0.138`。

通过以下命令以 `root` 身份轻松初始化连接：

```sh
# mpd -b adsl
```

要查看连接状态：

```sh
% ifconfig ng0
ng0: flags=88d1<UP,POINTOPOINT,RUNNING,NOARP,SIMPLEX,MULTICAST> mtu 1500
     inet 216.136.204.117 --> 204.152.186.171 netmask 0xffffffff
```

使用 mpd 是通过 FreeBSD 连接到 ADSL 服务的推荐方式。

## 30.5.2. 使用 pptpclient

也可以使用 FreeBSD 连接到其他 PPPoA 服务，方法是使用 [net/pptpclient](https://cgit.freebsd.org/ports/tree/net/pptpclient/)。

要使用 [net/pptpclient](https://cgit.freebsd.org/ports/tree/net/pptpclient/) 连接到 DSL 服务，首先安装该Port 或软件包，然后编辑 **/etc/ppp/ppp.conf**。以下是 **ppp.conf** 的一个示例部分。有关 **ppp.conf** 选项的更多信息，请参见 [ppp(8)](https://man.freebsd.org/cgi/man.cgi?query=ppp\&sektion=8\&format=html)。

```ini
adsl:
 set log phase chat lcp ipcp ccp tun command
 set timeout 0
 enable dns
 set authname username ①
 set authkey password  ②
 set ifaddr 0 0
 add default HISADDR
```

* ① DSL 提供商的用户名。
* ② 你的账户密码。

> **警告**
>
> 由于账户的密码以明文形式添加到 **ppp.conf** 中，请确保没有人能够读取该文件的内容：
>
> ```
> # chown root:wheel /etc/ppp/ppp.conf
> # chmod 600 /etc/ppp/ppp.conf
> ```

这将打开一个 PPP 会话的隧道连接到 DSL 路由器。以太网 DSL 调制解调器通常具有一个预配置的 LAN IP 地址用于连接。以 Alcatel SpeedTouch™ Home 为例，该地址为 `10.0.0.138`。路由器的文档应列出设备使用的地址。要打开隧道并启动 PPP 会话：

```sh
# pptp address adsl
```

> **技巧**
>
> 如果在命令末尾添加一个与号（"&"），pptp 将返回提示符。

将创建一个 **tun** 虚拟隧道设备，用于在 pptp 和 ppp 进程之间进行交互。返回提示符后，或者 pptp 进程确认连接后，检查隧道状态：

```sh
% ifconfig tun0
tun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1500
        inet 216.136.204.21 --> 204.152.186.171 netmask 0xffffff00
	Opened by PID 918
```

如果连接失败，请检查路由器的配置，通常可以通过 Web 浏览器访问。此外，还可以检查 `pptp` 的输出和 **/var/log/ppp.log** 日志文件的内容，以获得更多线索。


---

# 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://handbook.bsdcn.org/di-30-zhang-ppp/30.5.-shi-yong-atm-shang-de-ppp-pppoa.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.
