Linux嵌入式中PPP和PPP-ON脚本的编写

网络 网络管理
下面我们来对Linux嵌入式中PPP拨号设置和PPP-ON的应用来做一下讲解。那么我们已经将具体的脚本代码进行了总结。希望对大家有所帮助。

在Linux嵌入式中,我们可以来完成GPRS脚本的编写。其中涉及了PPP的内容。这篇文章中,我们就讲解了如何在Liod平台上进行ppp拨号,实现GPRS上网的知识。首先我们来看一下硬件平台:亿道Liod平台(基于PXA270)。操作系统:嵌入式Linux。

第一步:如果内核不支持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这两个程序.

源代码下载网址: ftp://ftp.samba.org/pub/ppp/ 解压源代码包,进入目录,进行交叉编译,这里所用的交叉编译器是arm-linux-gcc(version 3.3.2)

  1. #cd /root/gprs/ppp-2.4.1  
  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这两个程序拷贝到此目录下! 

第三步:配置拨号脚本:

将 /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   
  3. Burns')  
  4.      PASSWORD=                    # The password for this account (and 'Gracie A  
  5. llen')  
  6.      LOCAL_IP=0.0.0.0             # Local IP address if known. Dynamic = 0.0.0.0  
  7.  
  8.      REMOTE_IP=0.0.0.0          # Remote IP address if desired. Normally 0.0.0.0  
  9.  
  10.      NETMASK=255.255.255.0 # The proper netmask if needed  
  11.  
  12. # Export them so that they will be available at 'ppp-on-dialer' time.  
  13. export TELEPHONE ACCOUNT     
  14. DIALER_SCRIPT=/mnt/cf/pppdial/ppp-on-dialer  
  15.  
  16. # Initiate the connection  
  17.  
  18. exec /mnt/cf/pppdial/pppd debug lock nocrtscts   /dev/ttyS1 19200 \  
  19. asyncmap 20A0000 escape FF kdebug 0 $LOCAL_IP:$REMOTE_IP \  
  20. 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

pppd拨号:   ./ppp-on

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

责任编辑:佟健 来源: 百度空间
相关推荐

2010-09-03 10:42:02

ppp-on

2010-09-06 14:14:32

ppp-on

2010-09-03 14:18:32

ppp脚本

2010-09-06 13:41:43

PPPPPTP

2010-09-07 15:39:46

2010-09-06 12:37:11

pppLCP

2010-09-03 09:50:19

armPPP

2010-09-06 14:26:51

pppCHAP

2010-09-28 09:20:28

Linux PPP设置

2010-09-25 15:05:49

LINUXJVM

2010-09-03 10:16:07

PPPSLIP

2010-09-03 09:43:37

Linux内核PPP

2010-09-07 15:51:25

PPPPPPoE

2010-09-06 12:17:09

SLIPPPP协议

2010-09-03 11:10:04

ppp authent

2011-01-14 13:13:23

嵌入式Linux开发

2009-07-08 14:32:10

GTK+嵌入式Linux

2010-09-06 10:56:54

2010-09-06 14:36:17

PPP Multili

2010-09-09 17:24:11

点赞
收藏

51CTO技术栈公众号