當前位置:首頁 » 幣種行情 » linuxethgprs

linuxethgprs

發布時間: 2024-11-03 00:26:02

㈠ linux有gprs也有線怎麼選擇


認情況在/etc/ppp/目錄下建立文件gprs-connect-chat,內容如下(每個參數解釋在ppp-howto中有詳細解釋。它是在ppp
底層會話的時候給chat進程的參數每行是一個「期望/發送」的組合序列。當出現一些經典的錯誤如: "LCP: timeout sending
Config-Requests" ,"serial line is not 8 bit clean...",「serial line is
looped
back」等,去參看方式2提到的兩個文檔,或者google。注意,為什麼不能確切地給出解決的方式,原因是列印出來的同一個錯誤信息,我稱之為現象,
同一現象可能是由很多種原因造成的,需要自己實地排查。)
#/etc/ppp/gprs-connect-chat
TIMEOUT 15
ABORT '\nBUSY\r'
ABORT '\nNO ANSWER\r'
ABORT '\nRINGING\r\n\r\nRINGING\r'
#'' AT
#'OK-+++\c-OK' ATH0
TIMEOUT 40
'' \rAT
OK ATS0=0 #這些都是標準的at命令,建議查看隨模塊的at命令手冊
OK ATE0V1
OK AT+CGDCONT=1,"IP","CMNET" #設置isp接入網關為中國移動的cmnet,如果你想 獲得更多訪問資源的話
OK ATDT*99***1# #中國移動gprs的接入號嗎
CONNECT ''
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
建立文件/etc/ppp/peers/gprs,它的作用是給pppd進程提供配置參數(詳見man 8 pppd的輸出內容,如果出現問題這個將是非常重要的參考頁),內容如下:
#/etc/ppp/peers/gprs
# Usage: root>pppd call gprs
/dev/s3c2410_serial1 #改成自己的埠名
115200 #改成自己串口波特率
nocrtscts
#可能你的串口是需要crtscts,硬體流控的,這是由你的串口決定的,一般嵌入式系統的串口沒有帶硬體流控,也不需要就加nocrtscts
modem #這個參數使得pppd進程將等待模塊發回的CD (Carrier Detect)信號,與local真好相反
#noauth
debug #把調試信息輸出到/var/log/messages,在調試成功後去掉它,以減少垃圾的產生。
nodetach
#hide-password
usepeerdns #以下的3個參數一般不可少
noipdefault
defaultroute
user smsong #設置接入的用戶名,在chap-secrets或者pap-secets中使用
0.0.0.0:0.0.0.0 #本地和遠端的ip都設為0使得接入的isp分配本地的ip地址
ipcp-accept-local #要求peer也就是isp給自己非配動態的IP地址
#ipcp-accept-remote
#lcp-echo-failure 12
#lcp-echo-interval 3
noccp #不需要壓縮控制協議,有可能對端不需要,根據自己的isp的情況
#novj
#novjccomp
persist #保證在連接斷開的情況下不退出,並嘗試重新打開連接
connect '/usr/sbin/chat -s -v -f /etc/ppp/gprs-connect-chat'
#pppd調用chat會話進程接入對端isp,啟動對端的pppd,然後本地pppd與對端的pppd一起進行協
#商網路參數和chap/pap認證,成功後,再進行ncp層的ip的分配。
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#/etc/ppp/chap-secets
# Secrets for authentication using CHAP
# client server secret IP addresses
####### redhat-config-network will overwrite this part!!! (begin) ##########
####### redhat-config-network will overwrite this part!!! (end) ############
smsong * 123456 *
有點地區的GPRS可能使用pap方式認證接入用戶,所以在同一級目錄下,創建pap-secets文件,內容與chap-secets類似有4項的內容第2和第4項一般不限制就用*(星號)代表。反正要你在/etc/ppp/下放著這兩個文件就好。
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
在建立了ppp0連接以後可以使用ctrl+c或者下面的腳本程序ppp-off斷開ppp連接
#/etc/ppp/ppp-off
#!/bin/sh
######################################################################
#
# Determine the device to be terminated.
#
if [ "$1" = "" ]; then
DEVICE=ppp0
else
DEVICE=$1
fi
######################################################################
#
# If the ppp0 pid file is present then the program is running. Stop it.
if [ -r /var/run/$DEVICE.pid ]; then
kill -INT `cat /var/run/$DEVICE.pid`
#
# If the kill did not work then there is no process running for this
# pid. It may also mean that the lock file will be left. You may wish
# to delete the lock file at the same time.
if [ ! "$?" = "0" ]; then
rm -f /var/run/$DEVICE.pid
echo "ERROR: Removed stale pid file"
exit 1
fi
#
# Success. Let pppd clean up its own junk.
echo "PPP link to $DEVICE terminated."
exit 0
fi
#
# The ppp process is not running for ppp0
echo "ERROR: PPP link is not active on $DEVICE"
exit 1
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
做好上面的配置以後,輸入pppd call gprs命令,注意如果你的gprs這個文件不在/etc/ppp/peers/目錄下,在給出標注路徑給pppd
[root@localhost ppp_scripts]# pppd call gprs
timeout set to 15 seconds
abort on (\nBUSY\r)
abort on (\nNO ANSWER\r)
abort on (\nRINGING\r\n\r\nRINGING\r)
timeout set to 40 seconds
send (^MAT^M^M)
expect (OK)
^M^M
OK
-- got it
send (ATS0=0^M^M)
expect (OK)
^M
AT^M
OK
-- got it
send (ATE0V1^M^M)
expect (OK)
^M
^M^M
OK
-- got it
send (AT+CGDCONT=1,"IP","CMNET"^M^M)
expect (OK)
^M
ATS0=0^M^M
OK
-- got it
send (ATDT*99***1#^M^M)
expect (CONNECT)
^M
^M^M
OK^M
ATE0V1^M^M
OK^M
^M
OK^M
^M
OK^M
^M
OK^M
^M
CONNECT
-- got it
send (^M)
Serial connection established.
using channel 20
Using interface ppp0
Connect: ppp0 /dev/ttyS0
Warning - secret file /etc/ppp/pap-secrets has world and/or group access
sent [LCP ConfReq id=0x1 ]
rcvd [LCP ConfRej id=0x1 ]
sent [LCP ConfReq id=0x2 ]
rcvd [LCP ConfAck id=0x2 ]
rcvd [LCP ConfReq id=0x1 ]
sent [LCP ConfAck id=0x1 ]
rcvd [CHAP Challenge id=0x1 , name = ""]
Warning - secret file /etc/ppp/chap-secrets has world and/or group access
sent [CHAP Response id=0x1 , name = "smsong"]
rcvd [CHAP Success id=0x1 ""]
CHAP authentication succeeded
CHAP authentication succeeded
sent [CCP ConfReq id=0x1 ]
sent [IPCP ConfReq id=0x1 ]
rcvd [LCP ProtRej id=0x1 80 fd 01 01 00 0c 1a 04 78 00 18 04 78 00]
Protocol-Reject for 'Compression Control Protocol' (0x80fd) received
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfNak id=0x1 ]
rcvd [IPCP ConfRej id=0x1 ]
sent [IPCP ConfReq id=0x2 ]
rcvd [IPCP ConfReq id=0x2]
sent [IPCP ConfAck id=0x2]
rcvd [IPCP ConfNak id=0x2 ]
sent [IPCP ConfReq id=0x3 ]
rcvd [IPCP ConfAck id=0x3 ]
Could not determine remote IP address: defaulting to 10.64.64.64
local IP address 10.144.202.159
remote IP address 10.64.64.64
primary DNS address 211.138.200.69
secondary DNS address 211.103.13.101
Script /etc/ppp/ip-up started (pid 4578)
Script /etc/ppp/ip-up finished (pid 4578), status = 0x0
使用ctrl+c可以斷開連接,這樣一般不太好測試是不是連接上了(遇有開發不上的控制台只有一個的原因),可以去掉/etc/ppp
/peers/gprs文件中的nodetach參數,要用ping,你需要將eth0即網口給禁用掉,這樣ping才會通過ppp0埠尋找路由連接外
網。
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
可以用命令tail -f /var/log/messages看到日誌:
Mar 20 20:55:55 localhost pppd[4557]: pppd 2.4.4 started by root, uid 0
Mar 20 20:55:56 localhost chat[4558]: timeout set to 15 seconds
Mar 20 20:55:56 localhost chat[4558]: abort on (\nBUSY\r)
Mar 20 20:55:56 localhost chat[4558]: abort on (\nNO ANSWER\r)
Mar 20 20:55:56 localhost chat[4558]: abort on (\nRINGING\r\n\r\nRINGING\r)
Mar 20 20:55:56 localhost chat[4558]: timeout set to 40 seconds
Mar 20 20:55:56 localhost chat[4558]: send (^MAT^M^M)
Mar 20 20:55:56 localhost chat[4558]: expect (OK)
Mar 20 20:55:56 localhost chat[4558]: ^M^M
Mar 20 20:55:56 localhost chat[4558]: OK
Mar 20 20:55:56 localhost chat[4558]: -- got it
Mar 20 20:55:56 localhost chat[4558]: send (ATS0=0^M^M)
Mar 20 20:55:56 localhost chat[4558]: expect (OK)
Mar 20 20:55:56 localhost chat[4558]: ^M
Mar 20 20:55:56 localhost chat[4558]: AT^M
Mar 20 20:55:56 localhost chat[4558]: OK
Mar 20 20:55:56 localhost chat[4558]: -- got it
Mar 20 20:55:56 localhost chat[4558]: send (ATE0V1^M^M)
Mar 20 20:55:56 localhost chat[4558]: expect (OK)
Mar 20 20:55:56 localhost chat[4558]: ^M
Mar 20 20:55:56 localhost chat[4558]: ^M^M
Mar 20 20:55:56 localhost chat[4558]: OK
Mar 20 20:55:56 localhost chat[4558]: -- got it
Mar 20 20:55:56 localhost chat[4558]: send (AT+CGDCONT=1,"IP","CMNET"^M^M)
Mar 20 20:55:57 localhost chat[4558]: expect (OK)
Mar 20 20:55:57 localhost chat[4558]: ^M
Mar 20 20:55:57 localhost chat[4558]: ATS0=0^M^M
Mar 20 20:55:57 localhost chat[4558]: OK
Mar 20 20:55:57 localhost chat[4558]: -- got it
Mar 20 20:55:57 localhost chat[4558]: send (ATDT*99***1#^M^M)
Mar 20 20:55:57 localhost chat[4558]: expect (CONNECT)
Mar 20 20:55:57 localhost chat[4558]: ^M
Mar 20 20:55:57 localhost chat[4558]: ^M^M
Mar 20 20:55:57 localhost chat[4558]: OK^M
Mar 20 20:55:57 localhost chat[4558]: ATE0V1^M^M
Mar 20 20:55:57 localhost chat[4558]: OK^M
Mar 20 20:55:57 localhost chat[4558]: ^M
Mar 20 20:55:57 localhost chat[4558]: OK^M
Mar 20 20:55:57 localhost chat[4558]: ^M
Mar 20 20:55:57 localhost chat[4558]: OK^M
Mar 20 20:55:57 localhost chat[4558]: ^M
Mar 20 20:55:57 localhost chat[4558]: OK^M
Mar 20 20:55:57 localhost chat[4558]: ^M
Mar 20 20:55:57 localhost chat[4558]: CONNECT
Mar 20 20:55:57 localhost chat[4558]: -- got it
Mar 20 20:55:57 localhost chat[4558]: send (^M)
Mar 20 20:55:57 localhost pppd[4557]: Serial connection established.
Mar 20 20:55:57 localhost pppd[4557]: Using interface ppp0
Mar 20 20:55:57 localhost pppd[4557]: Connect: ppp0 /dev/ttyS0
Mar 20 20:55:58 localhost pppd[4557]: Warning - secret file /etc/ppp/pap-secrets has world and/or group access
Mar 20 20:56:00 localhost pppd[4557]: Warning - secret file /etc/ppp/chap-secrets has world and/or group access
Mar 20 20:56:00 localhost pppd[4557]: CHAP authentication succeeded
Mar 20 20:56:00 localhost pppd[4557]: CHAP authentication succeeded
Mar 20 20:56:01 localhost kernel: PPP Deflate Compression mole registered
Mar 20 20:56:02 localhost pppd[4557]: Could not determine remote IP address: defaulting to 10.64.64.64
Mar 20 20:56:02 localhost pppd[4557]: local IP address 10.144.202.159
Mar 20 20:56:02 localhost pppd[4557]: remote IP address 10.64.64.64
Mar 20 20:56:02 localhost pppd[4557]: primary DNS address 211.138.200.69
Mar 20 20:56:02 localhost pppd[4557]: secondary DNS address 211.103.13.101

熱點內容
doge幣屬於哪個鏈 發布:2024-11-03 03:33:50 瀏覽:169
螞蟻dr3礦機官網 發布:2024-11-03 03:29:56 瀏覽:428
區塊鏈能不能賺到錢 發布:2024-11-03 03:15:08 瀏覽:82
王欣區塊鏈微博 發布:2024-11-03 03:06:30 瀏覽:610
幣圈季度合約交割有啥影響 發布:2024-11-03 03:03:36 瀏覽:400
比特幣詐騙圖片 發布:2024-11-03 03:01:51 瀏覽:846
比特幣蘋果交易平台 發布:2024-11-03 03:00:14 瀏覽:920
天涯現在還能挖礦嗎 發布:2024-11-03 02:45:04 瀏覽:688
幣圈公眾號排行榜 發布:2024-11-03 02:27:25 瀏覽:862
區塊鏈峰會議程 發布:2024-11-03 02:25:44 瀏覽:653