linux下用wvdial实现gprs拨号上网

运维 系统运维
本文讲述了linux下用wvdial实现gprs拨号上网的方法......

1. 安装wvdial

sudo apt-get install wvdial

2. 在/etc/wvdial.conf中写入wvdial的配置信息: femacs /etc/wvdial.conf

Init1 = ATZ

Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0

Init3 = AT+CGDCONT=1,"IP","CMNET"  ##important! 否则无法使用DNS

Modem Type = Analog Modem

Baud = 115200  ##根据你的gprs modem来设定

New PPPD = yes

Modem = /dev/ttyS0 ##你所连接的串口

ISDN = 0

Phone = *99***1#  ##中国移动的拨号号码

Password = ***    ##其实没什么用

Username = itlanger

这一步,可以首先运行wvdial,这时会出现找不到modem,然后修改/etc/wvdial.conf, 增加

Baud = 115200  ##根据你的gprs modem来设定

Modem = /dev/ttyS0 ##你所连接的串口

然后再次运行wvdial, 再手动加入一下内容到/etc/wvdial.conf:

Init3 = AT+CGDCONT=1,"IP","CMNET"

Phone = *99***1#  ##中国移动的拨号号码

Password = ***    ##其实没什么用

Username = itlanger

这里Init3 = AT+CGDCONT=1,"IP","CMNET" 一定要加,否则wvdial拨号时会出现:

warning, can't find address for `www.suse.de`

--> warning, address lookup does not work

--> Nameserver (DNS) failure, the connection may not work.

导致只能ping通IP,不能ping通域名

3. 配置ppp参数: femacs /etc/ppp/options

noipdefault

ipcp-accept-local

ipcp-accept-remote

defaultroute

noauth

crtscts

debug

4.拨号上网: sudo wvdial

--> WvDial: Internet dialer version 1.60

--> 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

--> Sending: AT+CGDCONT=1,"IP","CMNET"

AT+CGDCONT=1,"IP","CMNET"

OK

--> Modem initialized.

--> Sending: ATDT*99***1#

--> Waiting for carrier.

ATDT*99***1#

CONNECT

~[7f]}#@!}!}#} }9}"}&} }*} } }'}"}(}"}%}&K_{}$}#}%B#}%<e~

--> Carrier detected.  Waiting for prompt.

~[7f]}#@!}!}#} }9}"}&} }*} } }'}"}(}"}%}&K_{}$}#}%B#}%<e~

--> PPP negotiation detected.

--> Starting pppd at Tue Dec 15 11:19:14 2009

--> Pid of pppd: 6666

--> Using interface ppp0

--> Authentication (CHAP) started

--> Authentication (CHAP) successful

--> local  IP address 10.24.229.233

--> remote IP address 192.168.254.254

--> primary   DNS address 211.137.160.5

--> secondary DNS address 211.136.17.107

--> Script /etc/ppp/ip-up run successful

--> Default route Ok.

--> Nameserver (DNS) Ok.

--> Connected... Press Ctrl-C to disconnect

4. 断开以太网连接:

sudo ifconfig eth0 down

sudo route add default gw 10.24.229.233 ##这里是ppp0的IP

5. 测试网络:

ping 60.28.166.84

ping www.chinaunix.net

如果ping不通域名,可以cat /etc/resolv.conf

然后写入拨号获得的DNS
 

【编辑推荐】

  1. Linux环境下双网卡主机路由配置
  2. linux下如何破解windows密码
  3. Linux下配置JDK和Tomcat
责任编辑:赵宁宁 来源: chinaitlab
相关推荐

2009-01-12 17:00:40

服务器虚拟化Linux

2010-04-26 14:22:03

Unix配置

2009-12-28 11:04:29

ADSL拨号上网

2009-01-07 09:19:00

2009-06-26 11:43:00

2015-05-14 14:27:39

拨号上网

2010-01-08 15:21:06

Ubuntu ADSL

2009-12-29 11:11:19

2009-09-10 11:01:51

如何路由器设置自动拨号

2011-11-04 10:39:31

AOL拨号上网

2013-10-16 13:55:03

wi-fi无线网络

2010-05-14 11:46:53

Windows 7拨号设置

2009-11-10 10:43:42

2009-11-16 09:50:59

2009-12-09 11:45:51

SUSELinuxADSL

2011-03-14 16:46:40

Linuxiptables上网

2009-06-25 09:49:00

Windows XPADSL拨号

2010-09-03 09:57:08

PPPDGPRS

2009-06-22 10:09:18

LinuxADSL拨号

2010-01-06 17:36:40

Ubuntu 9.10
点赞
收藏

51CTO技术栈公众号