四步完成Linux ppp拨号


在一些系统中,我们可以进行一下ppp拨号设置的实验。那么这里我们就重点讲解一下Liod平台的ppp拨号linux)的内容和过程。硬件平台:亿道Liod平台基于PXA270),操作系统:嵌入式Linux。下面主要介绍一下如何在Liod平台上进行ppp拨号,实现GPRS上网.

第一步:如果内核不支持ppp拨号,则要重新编译内核,添加对ppp的支持,

  1. <*> PPP (point-to-point protocol) support  
  2. [*]    PPP multilink support (EXPERIMENTAL)  
  3. <*>    PPP support for async serial ports  
  4. <*>    PPP support for sync tty ports  
  5. <*>    PPP Deflate compression  
  6. <*>    PPP BSD-Compress compression 

然后重新烧写新生成的内核映象!

第二步:下载ppp-2.4.1源码包,交叉编译生成拨号所需的pppd和chat这两个程序.

源代码下载网址:http://samba.org/ftp/ppp/旧的站点,目前好像不能用了 ftp://ftp.samba.org/pub/ppp/)

解压源代码包,进入目录,进行交叉编译,这里所用的交叉编译器是arm-linux-gcc(version 3.3.2)

  1. #cd /root/gprs/ppp-2.4.1这里假设ppp解压在/root/gprs/目录下)  
  2. #./configure  
  3. #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这两个程序拷贝到此目录下! 开发板上储存空间有限,因此这里我用CF卡扩充储存容量)

第三步:配置拨号脚本

将 /root/gprs/ppp-2.4.1/scripts/下的ppp-on,ppp-on-dialer,ppp-off这三个脚本修改后拷贝到/mnt/cf/pppdial/下,修改后的脚本如下:

1.ppp-on脚本具体要修改的内容:

  1. TELEPHONE=*99***1#      # The telephone number for the connection  
  2. ACCOUNT=                       # The account name for logon (as in 'George Burns')  
  3. PASSWORD=                    # The password for this account (and 'Gracie Allen')  
  4. LOCAL_IP=0.0.0.0             # Local IP address if known. Dynamic = 0.0.0.0  
  5. REMOTE_IP=0.0.0.0          # Remote IP address if desired. Normally 0.0.0.0  
  6. NETMASK=255.255.255.0 # The proper netmask if needed  
  7.  
  8. # Export them so that they will be available at 'ppp-on-dialer' time.  
  9. export TELEPHONE ACCOUNT  
  10. DIALER_SCRIPT=/mnt/cf/pppdial/ppp-on-dialer  
  11.  
  12. # Initiate the connection  
  13.  
  14. exec /mnt/cf/pppdial/pppd debug lock nocrtscts   /dev/ttyS1 19200 \  
  15. asyncmap 20A0000 escape FF kdebug 0 $LOCAL_IP:$REMOTE_IP \  
  16. noipdefault netmask $NETMASK defaultroute connect $DIALER_SCRIPT usepeerdns 

2.修改ppp-on-dialer脚本:

  1. #!/bin/sh  
  2. #  
  3. # This is part 2 of the ppp-on script. It will perform the connection  
  4. # protocol for the desired connection.  
  5. #  
  6. exec /sbin/chat -v       \  
  7. TIMEOUT   5     \  
  8. ABORT   '\nBUSY\r'    \  
  9. ABORT   '\nNO ANSWER\r'    \  
  10. ABORT   '\nRINGING\r\n\r\nRINGING\r' \  
  11. ''   AT+CGDCONT=1,IP,CMNET          \  
  12. 'OK'             AT     \  
  13. 'OK-+++\c-OK' ATH0     \  
  14. TIMEOUT   30     \  
  15. OK   ATDT$TELEPHONE    \  
  16. CONNECT 

3.在Liod板上/etc/ppp/resolv.conf文件中加上

  1. nameserver 211.136.20.203  
  2. nameserver 211.136.18.171 

第四步:连接gprs

gprs模块通过串口连接到板子上的蓝牙串口(/dev/ttyS1),因为Liod板的FFUART用来做调试串口了,即使通过telnet登录Liod,而将串口0腾出来用来连接GPRS模块,拨号也会失败.因为从串口0会输出调试信息,对拨号过程造成干扰.

关闭默认网络设备: ifconfig eth0 down

在Liod平台上挂载CF卡,并切换到/mnt/cf/pppdial/下,下面就可以ppp拨号了!

pppd拨号:   ./ppp-on

(注意:一定要先关闭闭eth0再拨号,否则即使拨号能得到IP地址,也会因为路由错误而访问不了外网)

相关内容