<< Back to man.ChinaUnix.net

8.15. 设置Modem拔号网络

Modem拔号网络的速度慢,但在一些环境下还是很有用。如传真和点对点连接。下面这篇有关Modem设置的文章就是我在配置Fax服务器时记录下来。

在配置拔号网络前,请先用上面介绍的Minicom工具与Modem通信,确定Modem在Linux下能正常工作。Modem拔号采用PPP协议与远程的拔号服务器建立连接。在Debian系统下,有一个叫pppconfig配置可帮助我们快速配置pppd拔号网络。运行pppconfig,按向导一步下配置下去就可以了。配置完成保存后,在/etc/ppp/peers目录下会生成一个配置文件,默认是provider。用以下命令启动拔号连接:

debian:~# pon provider       #如果你的连接名不是provider,请用你所起的连接名代替

用以下命令可查看连接日志:

debian:~# plog                 
Aug 29 09:54:01 debian pppd[1708]: sent [IPCP ConfReq id=0x3 <addr 218.20.81.4> <ms-dns1 61.144.56.101> <ms-dns3 202.96.128.86>]
Aug 29 09:54:01 debian pppd[1708]: rcvd [IPCP ConfAck id=0x3 <addr 218.20.81.4> <ms-dns1 61.144.56.101> <ms-dns3 202.96.128.86>]
Aug 29 09:54:01 debian pppd[1708]: Cannot determine ethernet address for proxy A RP
Aug 29 09:54:01 debian pppd[1708]: local  IP address 218.20.81.4
Aug 29 09:54:01 debian pppd[1708]: remote IP address 218.20.64.62
Aug 29 09:54:01 debian pppd[1708]: primary   DNS address 61.144.56.101
Aug 29 09:54:01 debian pppd[1708]: secondary DNS address 202.96.128.86
Aug 29 09:54:01 debian pppd[1708]: Script /etc/ppp/ip-up started (pid 1711)
Aug 29 09:54:02 debian pppd[1708]: Script /etc/ppp/ip-up finished (pid 1711), status = 0x0

用以下命令关闭连接:

debian:~# poff

用以下命令显示连接状态信息:

debian:~# pppstats
      IN   PACK VJCOMP  VJUNC  VJERR  |      OUT   PACK VJCOMP  VJUNC NON-VJ
    9532    145      0      0      0  |       97      5      0      0      5

另外一种方法是利用wvdial这个拔号工具实现Modem拔号上网。操作方法也很简单,先下载wvdial软件包:

debian:~# apt-get install wvdial

下载完软件后会自动运行wvdial的配置程序,要求输入电话号码、用户名和密码。配置程序会自动检测你的Modem并生成/etc/wvdial.conf文件。文件内容如下:

[Dialer Defaults]          #默认的拔号设置,可设置多个Dialer
Phone = 96169
Username = 1
Password = 1
New PPPD = yes
Modem = /dev/ttyS0
Baud = 115200
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ISDN = 0
Modem Type = Analog Modem

当然,我们也可手动运行wvdialconf这个配置程序,如:

debian:~# wvdialconf /etc/wvdial.conf
Scanning your serial ports for a modem.

ttyS0<*1>: ATQ0 V1 E1 -- OK
ttyS0<*1>: ATQ0 V1 E1 Z -- OK
ttyS0<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyS0<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyS0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyS0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyS0<*1>: Modem Identifier: ATI -- TP560 Data/Fax/Voice 56K Modem
ttyS0<*1>: Speed 4800: AT -- OK
ttyS0<*1>: Speed 9600: AT -- OK
ttyS0<*1>: Speed 19200: AT -- OK
ttyS0<*1>: Speed 38400: AT -- OK
ttyS0<*1>: Speed 57600: AT -- OK
ttyS0<*1>: Speed 115200: AT -- OK
ttyS0<*1>: Max speed is 115200; that should be safe.
ttyS0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK

Found a modem on /dev/ttyS0.
Modem configuration written to /etc/wvdial.conf.
ttyS0<Info>: Speed 115200; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"

配置完成后,用wvdial命令启动拔号:

debian:~# wvdial       #启动默认拔号器,如有多个拔号器,可用wvdial dialer格式指定
--> WvDial: Internet dialer version 1.53
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Modem initialized.
--> Sending: ATDT96169
--> Waiting for carrier.
ATDT96169
CONNECT 45333/V42BIS
--> Carrier detected.  Waiting for prompt.
*********************************
* Quidway A8010 Internet Server *
* welcome!!                     *
*********************************
please input username:
--> Looks like a login prompt.
--> Sending: 1
--> Don't know what to do!  Starting pppd and hoping for the best.
--> Starting pppd at Tue Aug 30 11:11:39 2005
--> pid of pppd: 1858

出现以上信息说明pppd连接成功,用ifconfig可以查看到一个ppp0的连接。