下面我们主要讲解一下在Linux系统下PPP的有关配置。重点讲解的是pppd通过GPRS上网的内容。希望对大家有所帮助。

前面的内容,我们都讲解了PPP协议的一些基本应用,以及一些相关的配置。那么这里我们就主要讲解一下实现Linux下pppd通过GPRS拨号上网的过程。昨天把开发板的bootloader删了,没办法,只得在PC上调GPRS拨号了.先在windows下拨号成功,然后用工具看拨号时具体使用了哪些AT命令,再使用这些命令到linux下使用pppd来拨号,最后终于成功了,之前开发板上不能成功拨号极有可就是AT指令有问题,现在只有等开发板回来后再到ARM7上调了.

PPP设置之pppd拨号(PPP拨号)  pppd ppp 第1张

下面贴一下拨号使用的几个脚本,GPRS模块是使用的华为的GTM900-B:

1, /etc/ppp/peers/gprs: 复制内容到剪贴板

代码:

  1. #/etc/ppp/peers/gprs
  2. #ThisispppdscriptforChinaMobile,usedHuaweiGTM900-BGPRSModule
  3. #Usage:root>pppdcallgprs
  4. /dev/ttyS0
  5. 19200
  6. crtscts
  7. modem
  8. #noauth
  9. debug
  10. nodetach
  11. #hide-password
  12. usepeerdns
  13. noipdefault
  14. defaultroute
  15. user"cmnet"
  16. 0.0.0.0:0.0.0.0
  17. #ipcp-accept-local
  18. #ipcp-accept-remote
  19. #lcp-echo-failure12
  20. #lcp-echo-interval3
  21. #noccp
  22. #novj
  23. #novjccomp
  24. #persist
  25. connect'/usr/sbin/chat-s-v-f/etc/ppp/gprs-connect-chat'
  26. #connect'/bin/chat-v-s-f/etc/ppp/gprs-connect-chat'
  27. #disconnect'/bin/chat-v-f/etc/ppp/gprs-disconnect-chat'2

gprs-connect-chat: 复制内容到剪贴板

代码:

  1. #/etc/ppp/gprs-connect-chat
  2. #chatscriptforChinaMobile,usedHuaWeiGTM900-BGPRSmodule.
  3. TIMEOUT15
  4. ABORT"DELAYED"
  5. ABORT"BUSY"
  6. ABORT"ERROR"
  7. ABORT"NODIALTONE"
  8. ABORT"NOCARRIER"
  9. TIMEOUT40
  10. ''\rAT
  11. OKATS0=0
  12. OKATE0V1
  13. OKAT+CGDCONT=1,"IP","CMNET"
  14. OKATDT*99***1#
  15. CONNECT''3

用于chap认证的密码文件:chap-secrets,由于移动的GPRS服务不需要用户名和密码,所以刚开始没设用户名和密码,结果在chap认证的时候总不能通过.后来在gprs里添加user "cmnet"和这个密码文件后就OK了. 复制内容到剪贴板

代码:

  1. #/etc/ppp/chap-secrets
  2. #clientserversecretIPaddress
  3. "cmnet"*"cmnet"*4
  4. 另外还有个可选的,断开连接的脚本如下:复制内容到剪贴板

代码:

  1. ABORTOK
  2. ABORTBUSY
  3. ABORTDELAYED
  4. ABORT"NOANSWER"
  5. ABORT"NOCARRIER"
  6. ABORT"NODIALTONE"
  7. ABORTVOICE
  8. ABORTERROR
  9. ABORTRINGING
  10. TIMEOUT12
  11. ""\\k\\k\\k\\d+++ATH
  12. "使用:将PC上的DNS删掉后运行如下:
  13. [root@localhostppp]#pppdcallgprs
  14. timeoutsetto15seconds
  15. aborton(DELAYED)
  16. aborton(BUSY)
  17. aborton(ERROR)
  18. aborton(NODIALTONE)
  19. aborton(NOCARRIER)
  20. timeoutsetto40seconds
  21. send(^MAT^M)
  22. expect(OK)
  23. ^M^M
  24. OK
  25. --gotit
  26. send(ATS0=0^M)
  27. expect(OK)
  28. ^M
  29. AT^M
  30. OK
  31. --gotit
  32. send(ATE0V1^M)
  33. expect(OK)
  34. ^M
  35. ATS0=0^M^M
  36. OK
  37. --gotit
  38. send(AT+CGDCONT=1,"IP","CMNET"^M)
  39. expect(OK)
  40. ^M
  41. ATE0V1^M^M
  42. OK
  43. --gotit
  44. send(ATDT*99***1#^M)
  45. expect(CONNECT)
  46. ^M
  47. ^M
  48. OK^M
  49. ^M
  50. CONNECT
  51. --gotit
  52. send(^M)
  53. Serialconnectionestablished.
  54. usingchannel42
  55. Usinginterfaceppp0
  56. Connect:ppp0<-->/dev/ttyS0
  57. sent[LCPConfReqid=0x1<asyncmap0x0><magic0x8c5e3d45><pcomp><accomp>]
  58. rcvd[LCPConfRejid=0x1<magic0x8c5e3d45>]
  59. sent[LCPConfReqid=0x2<asyncmap0x0><pcomp><accomp>]
  60. rcvd[LCPConfAckid=0x2<asyncmap0x0><pcomp><accomp>]
  61. rcvd[LCPConfReqid=0x1<asyncmap0x0><authchapMD5><pcomp><accomp>]
  62. sent[LCPConfAckid=0x1<asyncmap0x0><authchapMD5><pcomp><accomp>]
  63. rcvd[CHAPChallengeid=0x1<fb17db52a81bc14997f72e2932ab0b342bab961d49c611>,name=""]
  64. sent[CHAPResponseid=0x1<2c757eac52b8d9a7d80ca7a77c419ad9>,name="cmnet"]
  65. rcvd[CHAPSuccessid=0x1""]
  66. CHAPauthenticationsucceeded
  67. sent[CCPConfReqid=0x1<deflate15><deflate(old#)15>]
  68. sent[IPCPConfReqid=0x1<compressVJ0f01><addr0.0.0.0><ms-dns10.0.0.0><ms-dns30.0.0.0>]
  69. rcvd[LCPProtRejid=0x180fd0101000c1a04780018047800]
  70. rcvd[IPCPConfReqid=0x1<addr221.177.160.163>]
  71. sent[IPCPConfAckid=0x1<addr221.177.160.163>]
  72. rcvd[IPCPConfRejid=0x1<compressVJ0f01>]
  73. sent[IPCPConfReqid=0x2<addr0.0.0.0><ms-dns10.0.0.0><ms-dns30.0.0.0>]
  74. rcvd[IPCPConfNakid=0x2<addr10.165.226.25><ms-dns1211.137.64.163><ms-dns3211.136.20.203>]
  75. sent[IPCPConfReqid=0x3<addr10.165.226.25><ms-dns1211.137.64.163><ms-dns3211.136.20.203>]
  76. rcvd[IPCPConfAckid=0x3<addr10.165.226.25><ms-dns1211.137.64.163><ms-dns3211.136.20.203>]
  77. localIPaddress10.165.226.25
  78. remoteIPaddress221.177.160.163
  79. primaryDNSaddress211.137.64.163
  80. secondaryDNSaddress211.136.20.203

再将这里的DNS给PC或作个连接到/etc/ppp/resolf.conf应该就OK了.

转载请说明出处
知优网 » PPP设置之pppd拨号(PPP拨号)

发表评论

您需要后才能发表评论