四步完成Linux ppp撥號
在一些系統(tǒng)中,我們可以進行一下ppp撥號設置的實驗。那么這里我們就重點講解一下Liod平臺的ppp撥號(linux)的內容和過程。硬件平臺:億道Liod平臺(基于PXA270),操作系統(tǒng):嵌入式Linux。下面主要介紹一下如何在Liod平臺上進行ppp撥號,實現(xiàn)GPRS上網(wǎng).
第一步:如果內核不支持ppp撥號,則要重新編譯內核,添加對ppp的支持,
- <*> PPP (point-to-point protocol) support
- [*] PPP multilink support (EXPERIMENTAL)
- <*> PPP support for async serial ports
- <*> PPP support for sync tty ports
- <*> PPP Deflate compression
- <*> PPP BSD-Compress compression
然后重新燒寫新生成的內核映象!
第二步:下載ppp-2.4.1源碼包,交叉編譯生成撥號所需的pppd和chat這兩個程序.
源代碼下載網(wǎng)址:http://samba.org/ftp/ppp/(舊的站點,目前好像不能用了 ftp://ftp.samba.org/pub/ppp/)
解壓源代碼包,進入目錄,進行交叉編譯,這里所用的交叉編譯器是arm-linux-gcc(version 3.3.2)
- #cd /root/gprs/ppp-2.4.1(這里假設ppp解壓在/root/gprs/目錄下)
- #./configure
- #make CC=arm-linux-gcc
撥號所用到的程序就是/root/gprs/ppp-2.4.1/pppd/下的pppd,和/root/gprs/ppp-2.4.1/chat/下的chat程序為了調試方便,我在CF卡上新建一個目錄pppdial,將pppd和chat這兩個程序拷貝到此目錄下! (開發(fā)板上儲存空間有限,因此這里我用CF卡擴充儲存容量)
第三步:配置撥號腳本
將 /root/gprs/ppp-2.4.1/scripts/下的ppp-on,ppp-on-dialer,ppp-off這三個腳本修改后拷貝到/mnt/cf/pppdial/下,修改后的腳本如下:
1.ppp-on腳本具體要修改的內容:
- TELEPHONE=*99***1# # The telephone number for the connection
- ACCOUNT= # The account name for logon (as in 'George Burns')
- PASSWORD= # The password for this account (and 'Gracie Allen')
- LOCAL_IP=0.0.0.0 # Local IP address if known. Dynamic = 0.0.0.0
- REMOTE_IP=0.0.0.0 # Remote IP address if desired. Normally 0.0.0.0
- NETMASK=255.255.255.0 # The proper netmask if needed
- # Export them so that they will be available at 'ppp-on-dialer' time.
- export TELEPHONE ACCOUNT
- DIALER_SCRIPT=/mnt/cf/pppdial/ppp-on-dialer
- # Initiate the connection
- exec /mnt/cf/pppdial/pppd debug lock nocrtscts /dev/ttyS1 19200 \
- asyncmap 20A0000 escape FF kdebug 0 $LOCAL_IP:$REMOTE_IP \
- noipdefault netmask $NETMASK defaultroute connect $DIALER_SCRIPT usepeerdns
2.修改ppp-on-dialer腳本:
- #!/bin/sh
- #
- # This is part 2 of the ppp-on script. It will perform the connection
- # protocol for the desired connection.
- #
- exec /sbin/chat -v \
- TIMEOUT 5 \
- ABORT '\nBUSY\r' \
- ABORT '\nNO ANSWER\r' \
- ABORT '\nRINGING\r\n\r\nRINGING\r' \
- '' AT+CGDCONT=1,IP,CMNET \
- 'OK' AT \
- 'OK-+++\c-OK' ATH0 \
- TIMEOUT 30 \
- OK ATDT$TELEPHONE \
- CONNECT
3.在Liod板上/etc/ppp/resolv.conf文件中加上
- nameserver 211.136.20.203
- nameserver 211.136.18.171
第四步:連接gprs
gprs模塊通過串口連接到板子上的藍牙串口(/dev/ttyS1),因為Liod板的FFUART用來做調試串口了,即使通過telnet登錄Liod,而將串口0騰出來用來連接GPRS模塊,撥號也會失敗.因為從串口0會輸出調試信息,對撥號過程造成干擾.
關閉默認網(wǎng)絡設備: ifconfig eth0 down
在Liod平臺上掛載CF卡,并切換到/mnt/cf/pppdial/下,下面就可以ppp撥號了!
pppd撥號: ./ppp-on
(注意:一定要先關閉閉eth0再撥號,否則即使撥號能得到IP地址,也會因為路由錯誤而訪問不了外網(wǎng))