Linux 系统 CDMA 无线上网卡拨号至少需要两个应用程序 ppp 和 chat。各发行版的源里面都有,如果还没有安装,就先安装上吧。读者最好先对这两个程序的功能和基本用法有一个初步的了解。
原来联通的 CDMA 网络现在已经移交给了电信,CDMA 上网卡的拨号号码是 #777,用户名和密码都是 card。
在 Linux 系统里,所有和 ppp 相关的配置文件都保存在 /etc/ppp/ 目录里,其中 /etc/ppp/pap-secrets 文件保存的是 PAP 认证协议需要的用户名和密码,而 /etc/ppp/chap-secrets 文件保存的是 CHAP 认证协议需要的用户名和密码。根据上面的说明,这两个文件的内容分别如下所示:
#
# /etc/ppp/pap-secrets
#
# Here you should add your userid password to connect to your providers via
# PAP. The * means that the password is to be used for ANY host you connect
# to. Thus you do not have to worry about the foreign machine name. Just
# replace password with your password.
# If you have different providers with different passwords then you better
# remove the following line.
# clientserversecretIP addresses
"card" * "card"
#
# /etc/ppp/pap-secrets
#
# Here you should add your userid password to connect to your providers via
# PAP. The * means that the password is to be used for ANY host you connect
# to. Thus you do not have to worry about the foreign machine name. Just
# replace password with your password.
# If you have different providers with different passwords then you better
# remove the following line.
# clientserversecretIP addresses
"card" * "card"
# Secrets for authentication using CHAP
# clientserversecretIP addresses
"card" * "card"
# Secrets for authentication using CHAP
# clientserversecretIP addresses
"card" * "card"
根据和服务器协商使用其中一个认证协议,则从对应的配置文件中读取认证所需的信息。
在 /etc/ppp/peers/ 目录里,存储着每个 pppd 连接所需的选项文件,每个文件对应一个连接。本文中,在 /etc/ppp/peers/ 目录里创建了一个 cdma 文件,其内容如下所示:
# /etc/ppp/peers/cdma
connect "/usr/sbin/chat -v -f /etc/chatscripts/ppp0"
defaultroute
persist
/dev/ttyUSB0
115200
user "CARD"
noauth
# /etc/ppp/peers/cdma
connect "/usr/sbin/chat -v -f /etc/chatscripts/ppp0"
defaultroute
persist
/dev/ttyUSB0
115200
user "CARD"
noauth
除了需要 /etc/ppp/peers/cdma 文件以外,我们还需要 /etc/chatscripts/ppp0 配置文件,如下所示:
# /etc/chatscripts/ppp0
ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT "ERROR"
ABORT "NO ANSWER"
ABORT "BUSY"
TIMEOUT 120
"" AT
OK ATDT#777
CONNECT
# /etc/chatscripts/ppp0
ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT "ERROR"
ABORT "NO ANSWER"
ABORT "BUSY"
TIMEOUT 120
"" AT
OK ATDT#777
CONNECT
最后通过下面的命令启动拨号,如果成功会建立一个 ppp0 的连接。
pppd call cdma
pppd call cdma
Over!