PPP设置之pppd拨号

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

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

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

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

代码:

  1. #/etc/ppp/peers/gprs  
  2. # This is pppd script for China Mobile, used Huawei GTM900-B GPRS Module  
  3. # Usage: root>pppd call gprs  
  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-failure   12  
  20. #lcp-echo-interval 3  
  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. # chat script for China Mobile, used HuaWei GTM900-B GPRS module.  
  3. TIMEOUT       15  
  4. ABORT           "DELAYED"  
  5. ABORT           "BUSY"  
  6. ABORT           "ERROR"  
  7. ABORT           "NO DIALTONE"  
  8. ABORT           "NO CARRIER"  
  9. TIMEOUT       40  
  10. ''              \rAT  
  11. OK             ATS0=0  
  12. OK              ATE0V1  
  13. OK              AT+CGDCONT=1,"IP","CMNET"  
  14. OK              ATDT*99***1#  
  15. CONNECT       ''3 

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

代码:

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

代码:

  1. ABORT        OK  
  2. ABORT        BUSY  
  3. ABORT        DELAYED  
  4. ABORT        "NO ANSWER"  
  5. ABORT        "NO CARRIER"  
  6. ABORT        "NO DIALTONE"  
  7. ABORT        VOICE  
  8. ABORT        ERROR  
  9. ABORT        RINGING  
  10. TIMEOUT        12  
  11. ""        \\k\\k\\k\\d+++ATH  
  12. "使用: 将PC上的DNS删掉后运行如下:  
  13. [root@localhost ppp]# pppd call gprs  
  14. timeout set to 15 seconds  
  15. abort on (DELAYED)  
  16. abort on (BUSY)  
  17. abort on (ERROR)  
  18. abort on (NO DIALTONE)  
  19. abort on (NO CARRIER)  
  20. timeout set to 40 seconds  
  21. send (^MAT^M)  
  22. expect (OK)  
  23. ^M^M  
  24. OK  
  25. -- got it  
  26.  
  27. send (ATS0=0^M)  
  28. expect (OK)  
  29. ^M  
  30. AT^M  
  31. OK  
  32. -- got it  
  33.  
  34. send (ATE0V1^M)  
  35. expect (OK)  
  36. ^M  
  37. ATS0=0^M^M  
  38. OK  
  39. -- got it  
  40.  
  41. send (AT+CGDCONT=1,"IP","CMNET"^M)  
  42. expect (OK)  
  43. ^M  
  44. ATE0V1^M^M  
  45. OK  
  46. -- got it  
  47.  
  48. send (ATDT*99***1#^M)  
  49. expect (CONNECT)  
  50. ^M  
  51. ^M  
  52. OK^M  
  53. ^M  
  54. CONNECT  
  55. -- got it  
  56.  
  57. send (^M)  
  58. Serial connection established.  
  59. using channel 42  
  60. Using interface ppp0  
  61. Connect: ppp0 <--> /dev/ttyS0  
  62. sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x8c5e3d45> <pcomp> <accomp>]  
  63. rcvd [LCP ConfRej id=0x1 <magic 0x8c5e3d45>]  
  64. sent [LCP ConfReq id=0x2 <asyncmap 0x0> <pcomp> <accomp>]  
  65. rcvd [LCP ConfAck id=0x2 <asyncmap 0x0> <pcomp> <accomp>]  
  66. rcvd [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MD5> <pcomp> <accomp>]  
  67. sent [LCP ConfAck id=0x1 <asyncmap 0x0> <auth chap MD5> <pcomp> <accomp>]  
  68. rcvd [CHAP Challenge id=0x1 <fb17db52a81bc14997f72e2932ab0b342bab961d49c611>name = ""]  
  69. sent [CHAP Response id=0x1 <2c757eac52b8d9a7d80ca7a77c419ad9>name = "cmnet"]  
  70. rcvd [CHAP Success id=0x1 ""]  
  71. CHAP authentication succeeded  
  72. sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15>]  
  73. 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>]  
  74. rcvd [LCP ProtRej id=0x1 80 fd 01 01 00 0c 1a 04 78 00 18 04 78 00]  
  75. rcvd [IPCP ConfReq id=0x1 <addr 221.177.160.163>]  
  76. sent [IPCP ConfAck id=0x1 <addr 221.177.160.163>]  
  77. rcvd [IPCP ConfRej id=0x1 <compress VJ 0f 01>]  
  78. sent [IPCP ConfReq id=0x2 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]  
  79. rcvd [IPCP ConfNak id=0x2 <addr 10.165.226.25> <ms-dns1 211.137.64.163> <ms-dns3 211.136.20.203>]  
  80. sent [IPCP ConfReq id=0x3 <addr 10.165.226.25> <ms-dns1 211.137.64.163> <ms-dns3 211.136.20.203>]  
  81. rcvd [IPCP ConfAck id=0x3 <addr 10.165.226.25> <ms-dns1 211.137.64.163> <ms-dns3 211.136.20.203>]  
  82. local   IP address 10.165.226.25  
  83. remote IP address 221.177.160.163  
  84. primary DNS address 211.137.64.163  
  85. secondary DNS address 211.136.20.203 

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

责任编辑:佟健 来源: hi.baidu.com
相关推荐

2010-09-03 09:57:08

PPPDGPRS

2010-09-03 09:50:19

armPPP

2010-09-06 11:58:39

ppp拨号Linux

2010-09-09 17:27:43

PPP Multili

2010-09-09 17:31:15

ppp authent

2010-09-06 13:41:43

PPPPPTP

2010-09-03 10:23:49

PPP Multili

2011-03-31 11:22:20

CACTI交换设备

2010-09-06 14:07:07

PPP Multili

2010-09-03 09:43:37

Linux内核PPP

2011-03-31 11:12:37

CACTINet-SNMP

2011-11-01 13:25:29

2011-03-31 11:50:31

CACTI安全

2010-09-28 09:20:28

Linux PPP设置

2010-09-06 09:18:08

PPP Options

2010-09-09 17:21:16

2009-12-18 16:00:48

2011-03-31 11:29:24

CACTISNMP服务

2011-03-03 16:47:32

2011-03-03 17:02:50

Vsftpd
点赞
收藏

51CTO技术栈公众号