18.4. Troubleshooting PPP Connections

Contributed by Tom Rhodes.

本节将讲述通过modem连接使用PPP时可能出现的问题 . 例如,你可能需要确切地知道你拨入的系统会出现一个怎样的命令行提示符.有些ISP会提供 ssword提示符,而其它的可能会出现 password; 如果没有根据情况的不同相应地编写ppp 脚本,登录就会失败.诊断ppp最常用的方法是手动进行连接 . 以下的信息会一步一步地带你完成手动连接.

18.4.1. 检查设备节点

如果你的内核是经过重新配置的,那么就需要检查sio设备. 如果没有配置过内核, 就没什么可担心的了.只要查看 dmesg的输出以找到modem设备:

#dmesg | grep sio

你应该找到与sio设备有关的输出. 这些就是我们需要的COM端口. 如果你的modem按照标准串行端口工作,你能在sio1或COM2找到它. 如果是这样, 你只需创建serial设备,而不必重建内核. cd到/dev目录,然后运行 MAKEDEV脚本 :

# sh MAKEDEV cuaa0 cuaa1 cuaa2 cuaa3

它会为你的系统创建串行(serial)设备. 如果modem设备连接在sio1接口(在DOS中称为COM2),那么你的modem将会是 /dev/cuaa1.

18.4.2. 手动连接

通过手动控制ppp来连接Internet 是诊断连接及获知ISP处理PPP客户端方式的一个快速,简单的方法. .让我们从PPP 命令行开始.在所有的例子中我们使用 example作为运行PPP主机的主机名.键入ppp 命令打开ppp :

# ppp

现在我们已经打开了ppp.

ppp ON example> set device /dev/cuaa1

设置modem设备,在本例子中是 cuaa1.

ppp ON example> set speed 115200

设置连接速度,在本例中我们使用15,200 kbps.

ppp ON example> enable dns

使ppp配置域名服务, 在文件/etc/resolv.conf中添加域名服务器行. .如果 ppp不能确定我们的主机名,可以在稍后设置.

ppp ON example> term

切换到 ``终端''样我们就能手动地控制模式,这modem.

deflink: Entering terminal mode on /dev/cuaa1
type '~h' for help
at
    OK
    atdt123456789

使用命令at初始化modem, 然后使用atdtISP给你的号码进行拨号.

CONNECT

连接配置,如果我们遇到了与硬件无关的连接问题,可以在这里尝试解决.

ISP Login:myusername

这里提示你输入用户名,输入ISP提供的用户名然后按回车.

ISP Pass:mypassword

这时提示我们输入密码,输入 ISP提供的密码. 如同登录入FreeBSD,密码不会显示.

Shell or PPP:ppp

由于ISP的不同,这个提示符可能不会出现.这里我们被问及:是使用 一个运行于提供商端的Shell还是启动ppp. 这本例中,我们选择使用ppp因为我 们想得到Internet连接.

Ppp ON example>

注意在这个例子中,第一个 p已经大写. 这显示我们已经成功地连接上了ISP.

PPp ON example>

我们已经成功通过了 ISP的验证,正在等待分配IP地址.

PPP ON example>

我们得到了一个 IP 地址,成功地完成了连接.

PPP ON example>add default HISADDR

这里,我们添加默认路由.在能与外界通信之前我们需要这样做,因为现在我们 只与服务器端建立了连接.如果由于已存在的路由而导致操作失败, 你可以在add前加!号. 作为另外一种方式,你也可以在真正连接之前设置这些(指add default HISADDR),ppp会根据这项设定协商取 得一个新的路由.

如果一切顺利,现在我们应该能得到一个活动的Internet连接,可以使用CTRL+z使其转入后台.如果你发现 PPP重新变为 ppp,那代表我们失去了连接.. 大写的P表明我们有到ISP的连接 而小写的p表明由于某种原因我们失去了连接.这便于我们了解连接状态. ppp 只有这两个状态.

18.4.2.1. 诊断排错

如果你有一根直连线且似乎不能建立连接,要使用set ctsrts off以关闭字节流的CTS/RTS.这种情况一般发 生在连接兼容PPP的终端服务器时. 当它向通信连接写入数据时,PPP就会挂起, 一直等待一个CTS, 或者一个不可能出现的Clear to Send信号.如果使用了这个选项,你还应该使用 set accmap选项 , which may be required to defeat hardware dependent on passing certain characters from end to end, most of the time XON/XOFF. See the ppp(8) manual page for more information on this option, and how it is used.

如果你有一个比较旧的modem, 你要用 set parity even.Parity被默认地设置为 none , but is used for error checking (with a large increase in traffic) on older modems and some ISPs. You may need this option for the Compuserve ISP.

PPP may not return to the command mode, which is usually a negotiation error where the ISP is waiting for your side to start negotiating. At this point, using the ~p command will force ppp to start sending the configuration information.

If you never obtain a login prompt, then most likely you need to use PAP or CHAP authentication instead of the UNIX® style in the example above. To use PAP or CHAP just add the following options to PPP before going into terminal mode:

ppp ON example> set authname myusername

Where myusername should be replaced with the username that was assigned by the ISP.

ppp ON example> set authkey mypassword

Where mypassword should be replaced with the password that was assigned by the ISP.

If you connect fine, but cannot seem to find any domain name, try to use ping(8) with an IP address and see if you can get any return information. If you experience 100 percent (100%) packet loss, then it is most likely that you were not assigned a default route. Double check that the option add default HISADDR was set during the connection. If you can connect to a remote IP address then it is possible that a resolver address has not been added to the /etc/resolv.conf. This file should look like:

domain example.com
nameserver x.x.x.x
nameserver y.y.y.y

Where x.x.x.x and y.y.y.y should be replaced with the IP address of your ISP's DNS servers. This information may or may not have been provided when you signed up, but a quick call to your ISP should remedy that.

You could also have syslog(3) provide a logging function for your PPP connection. Just add:

!ppp
*.*     /var/log/ppp.log

to /etc/syslog.conf. In most cases, this functionality already exists.