免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1711 | 回复: 0
打印 上一主题 下一主题

成功实现Linux下pppd通过GPRS拨号上网 [复制链接]

论坛徽章:
1
技术图书徽章
日期:2013-10-29 15:46:41
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-21 08:41 |只看该作者 |倒序浏览
昨天把开发板的bootloader删了,没办法,只得在PC上调GPRS拨号了.先在windows下拨号成功,然后用工具看拨号时具体使用了哪些AT命令,再使用这些命令到linux下使用pppd来拨号,最后终于成功了,之前开发板上不能成功拨号极有可就是AT指令有问题,现在只有等开发板回来后再到ARM7上调了.
   下面贴一下拨号使用的几个脚本,GPRS模块是使用的华为的GTM900-B:
1,  /etc/ppp/peers/gprs:
复制内容到剪贴板 代码:#/etc/ppp/peers/gprs
# This is pppd script for China Mobile, used Huawei GTM900-B GPRS Module
# Usage:   root>pppd call gprs
/dev/ttyS0
19200
crtscts
modem
#noauth
debug
nodetach
#hide-password
usepeerdns
noipdefault
defaultroute
user "cmnet"
0.0.0.0:0.0.0.0
#ipcp-accept-local
#ipcp-accept-remote
#lcp-echo-failure  12
#lcp-echo-interval 3
#noccp
#novj
#novjccomp
#persist
connect '/usr/sbin/chat -s -v -f /etc/ppp/gprs-connect-chat'
#connect '/bin/chat -v -s -f /etc/ppp/gprs-connect-chat'
#disconnect '/bin/chat -v -f /etc/ppp/gprs-disconnect-chat'
2,  gprs-connect-chat:
复制内容到剪贴板 代码:#/etc/ppp/gprs-connect-chat
# chat script for China Mobile, used HuaWei GTM900-B GPRS module.
TIMEOUT         15
ABORT           "DELAYED"
ABORT           "BUSY"
ABORT           "ERROR"
ABORT           "NO DIALTONE"
ABORT           "NO CARRIER"
TIMEOUT         40
''              \rAT
OK                ATS0=0
OK              ATE0V1
OK              AT+CGDCONT=1,"IP","CMNET"
OK              ATDT*99***1#
CONNECT         ''
3, 用于chap认证的密码文件:chap-secrets,由于移动的GPRS服务不需要用户名和密码,所以刚开始没设用户名和密码,结果在chap认证的时候总不能通过.后来在gprs里添加user "cmnet"和这个密码文件后就OK了.
复制内容到剪贴板 代码:#/etc/ppp/chap-secrets
#client    server secret IP address
"cmnet"    *     "cmnet"    *
4, 另外还有个可选的,断开连接的脚本如下:
复制内容到剪贴板 代码:ABORT        OK
ABORT        BUSY
ABORT        DELAYED
ABORT        "NO ANSWER"
ABORT        "NO CARRIER"
ABORT        "NO DIALTONE"
ABORT        VOICE
ABORT        ERROR
ABORT        RINGING
TIMEOUT        12
""        \\k\\k\\k\\d+++ATH
"
使用: 将PC上的DNS删掉后运行如下:
[root@localhost ppp]# pppd call gprs
timeout set to 15 seconds
abort on (DELAYED)
abort on (BUSY)
abort on (ERROR)
abort on (NO DIALTONE)
abort on (NO CARRIER)
timeout set to 40 seconds
send (^MAT^M)
expect (OK)
^M^M
OK
-- got it

send (ATS0=0^M)
expect (OK)
^M
AT^M
OK
-- got it

send (ATE0V1^M)
expect (OK)
^M
ATS0=0^M^M
OK
-- got it

send (AT+CGDCONT=1,"IP","CMNET"^M)
expect (OK)
^M
ATE0V1^M^M
OK
-- got it

send (ATDT*99***1#^M)
expect (CONNECT)
^M
^M
OK^M
^M
CONNECT
-- got it

send (^M)
Serial connection established.
using channel 42
Using interface ppp0
Connect: ppp0 <--> /dev/ttyS0
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x8c5e3d45> <pcomp> <accomp>]
rcvd [LCP ConfRej id=0x1 <magic 0x8c5e3d45>]
sent [LCP ConfReq id=0x2 <asyncmap 0x0> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x2 <asyncmap 0x0> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MD5> <pcomp> <accomp>]
sent [LCP ConfAck id=0x1 <asyncmap 0x0> <auth chap MD5> <pcomp> <accomp>]
rcvd [CHAP Challenge id=0x1 <fb17db52a81bc14997f72e2932ab0b342bab961d49c611>, name = ""]
sent [CHAP Response id=0x1 <2c757eac52b8d9a7d80ca7a77c419ad9>, name = "cmnet"]
rcvd [CHAP Success id=0x1 ""]
CHAP authentication succeeded
sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15>]
sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [LCP ProtRej id=0x1 80 fd 01 01 00 0c 1a 04 78 00 18 04 78 00]
rcvd [IPCP ConfReq id=0x1 <addr 221.177.160.163>]
sent [IPCP ConfAck id=0x1 <addr 221.177.160.163>]
rcvd [IPCP ConfRej id=0x1 <compress VJ 0f 01>]
sent [IPCP ConfReq id=0x2 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [IPCP ConfNak id=0x2 <addr 10.165.226.25> <ms-dns1 211.137.64.163> <ms-dns3 211.136.20.203>]
sent [IPCP ConfReq id=0x3 <addr 10.165.226.25> <ms-dns1 211.137.64.163> <ms-dns3 211.136.20.203>]
rcvd [IPCP ConfAck id=0x3 <addr 10.165.226.25> <ms-dns1 211.137.64.163> <ms-dns3 211.136.20.203>]
local  IP address 10.165.226.25
remote IP address 221.177.160.163
primary   DNS address 211.137.64.163
secondary DNS address 211.136.20.203

再将这里的DNS给PC或作个连接到/etc/ppp/resolf.conf应该就OK了.
有IP,网关,DNS之后就能上www.mcuos.com了....
 
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP