PPP設(shè)置之pppd撥號(hào)
前面的內(nèi)容,我們都講解了PPP協(xié)議的一些基本應(yīng)用,以及一些相關(guān)的配置。那么這里我們就主要講解一下實(shí)現(xiàn)Linux下pppd通過GPRS撥號(hào)上網(wǎng)的過程。昨天把開發(fā)板的bootloader刪了,沒辦法,只得在PC上調(diào)GPRS撥號(hào)了.先在windows下?lián)芴?hào)成功,然后用工具看撥號(hào)時(shí)具體使用了哪些AT命令,再使用這些命令到linux下使用pppd來撥號(hào),最后終于成功了,之前開發(fā)板上不能成功撥號(hào)極有可就是AT指令有問題,現(xiàn)在只有等開發(fā)板回來后再到ARM7上調(diào)了.
下面貼一下?lián)芴?hào)使用的幾個(gè)腳本,GPRS模塊是使用的華為的GTM900-B:
1, /etc/ppp/peers/gprs: 復(fù)制內(nèi)容到剪貼板
代碼:
- #/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: 復(fù)制內(nèi)容到剪貼板
代碼:
- #/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認(rèn)證的密碼文件:chap-secrets,由于移動(dòng)的GPRS服務(wù)不需要用戶名和密碼,所以剛開始沒設(shè)用戶名和密碼,結(jié)果在chap認(rèn)證的時(shí)候總不能通過.后來在gprs里添加user "cmnet"和這個(gè)密碼文件后就OK了. 復(fù)制內(nèi)容到剪貼板
代碼:
- #/etc/ppp/chap-secrets
- #client server secret IP address
- "cmnet" * "cmnet" * 4
- 另外還有個(gè)可選的,斷開連接的腳本如下: 復(fù)制內(nèi)容到剪貼板
代碼:
- 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刪掉后運(yùn)行如下:
- [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或作個(gè)連接到/etc/ppp/resolf.conf應(yīng)該就OK了.