PPP拨号设置,在很多平台上都有相关的操作。那么这里我们则重点讲解一下平台: L350和N300平台上测试均通过的PPP脚本内容。那么现在就让我们看下具体内容吧。希望对大家有所应用。
- /apps/etc/ppp >: uname -a
- Linux netaccess 2.6.22.1 #17 Thu Jan 7 18:03:30 EST 2010 armv5tejl unknown
pppd会从/etc/ppp下读取相关配置文件,由于调试时会经常修改这些配置文件,所以建立了一个符号链接到我们的Nandflash分区上:
- /apps/etc/ppp >: ls -l /etc/ppp
- lrwxrwxrwx 1 root root 13 Nov 20 2009 /etc/ppp -> /apps/etc/ppp
当使用pppd作ppp server时,主要有以下配置文件。在下面的文档中,将详细介绍他们:
- /apps/etc/ppp >: ls
- chap-secrets gprs-start-chat options options.ttyS1 pap-secrets
pppd运行参数文件/etc/ppp/options
该文件指定pppd运行的参数,若运行pppd时通过命令行指定的参数同时出现在该配置文件里时,pppd将使用/etc/ppp/options中的配置。关于pppd支持的一些参数,可以在我们PC的linux上使用man命令查询(man pppd)
[guowenxue@localhost ~]$ man 8 pppd
PPPD(8) PPPD(8)NAME
pppd - Point-to-Point Protocol DaemonSYNOPSIS
pppd [ options ]/apps/etc/ppp >: cat options
#tty Options
/dev/ttyS1 #例如,这里可以将/dev/ttyS1注释,然后使用命令行#pppd /dev/ttyS1 运行来指定;
115200
#lock
modem
nocrtscts #无硬件流控#login
nodetach #若指定updetach则拨号成功后放入后台运行,若为nodetach,则在前台执行debug
#Auth options
auth #使能Authentication
+pap #使用pap认证
-chap #不要支持chap认证# 源码ppp-2.4.3/pppd/tty.c中的函数connect_tty()将会执行这个脚本。主要是对客户端的拨号的应答。
connect "/usr/sbin/chat -v -E -V -f /etc/ppp/gprs-start-chat"#lcp options
#passive
asyncmap 0
lcp-echo-failure 3
lcp-echo-interval 5
ipcp-accept-local
ipcp-accept-remote
#proxyarp
netmask 255.255.255.0
ms-dns 10.78.28.10
ms-dns 10.78.28.11
nodefaultroute
gprs-start-chat chat脚本
关于chat的用法,可以在Linux PC上使用man命令查询:$ man 8 chat
- /apps/etc/ppp >: cat gprs-start-chat
- ABORT 'BUSY'
- ABORT 'NO CARRIER'
- ABORT 'NO DIALTONE'
- ABORT 'ERROR'
- TIMEOUT 0
- '' 'ATZ' //首先发送ATZ重置modem
- 'OK' 'ATE0' //收到OK后,使用ATE0消除回显
- 'RING' 'ATA' //等待客户端拨号,若客户端开始拨号,Modem收到RING后,发送应答信号ATA
- 'CONNECT' '' //收到CONNECT信号后,将进入下一阶段LCP的过程。
#p#options.ttyS1 IP地址分配
配置PPP服务器端(本地)IP地址和客户端(远端)的IP地址
- /apps/etc/ppp >: cat options.ttyS1
- #Server_IP_address:Client_IP_address
- 10.78.28.194:10.78.28.224
- chap和pap认证的帐号文件:
- /apps/etc/ppp >: cat pap-secrets
- # Secrets for authentication using PAP
- #User Server Secret IP Address
- na_admin * 123 *
- /apps/etc/ppp >: cat chap-secrets
- # Secrets for authentication using CHAP
- #User Server Secret IP Address
- na_admin * 123 *
pppd启动拨号过程:
- /apps/etc/ppp >: pppd /dev/ttyS1
- OK
- ATE0 //chat脚本的调试输出
- OK
- RING
- CONNECTSerial connection established.
- using channel 1
- Using interface ppp0
- Connect: ppp0 <--> /dev/ttyS1
- rcvd [LCP ConfReq id=0x0 <asyncmap 0x0> <magic 0x58452c14> <pcomp> <accomp> <callback CBCP>]
- Warning - secret file /etc/ppp/pap-secrets has world and/or group access
- sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth pap> <magic 0xb701c04a> <pcomp> <accomp>]
- sent [LCP ConfRej id=0x0 <callback CBCP>]
- rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <auth pap> <magic 0xb701c04a> <pcomp> <accomp>]
- rcvd [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x58452c14> <pcomp> <accomp>]
- sent [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x58452c14> <pcomp> <accomp>]
- sent [LCP EchoReq id=0x0 magic=0xb701c04a]
- rcvd [LCP code=0xc id=0x2 58 45 2c 14 4d 53 52 41 53 56 35 2e 31 30]
- sent [LCP CodeRej id=0x2 0c 02 00 12 58 45 2c 14 4d 53 52 41 53 56 35 2e 31 30]
- rcvd [LCP code=0xc id=0x3 58 45 2c 14 4d 53 52 41 53 2d 30 2d 4d 45 49 51 49 4e 50 43 30 31]
- sent [LCP CodeRej id=0x3 0c 03 00 1a 58 45 2c 14 4d 53 52 41 53 2d 30 2d 4d 45 49 51 49 4e 50 43 30 31]
- rcvd [PAP AuthReq id=0xc user="na_admin" password=<hidden>]
- Warning - secret file /etc/ppp/pap-secrets has world and/or group access
- sent [PAP AuthAck id=0xc "Login ok"]
- PAP peer authentication succeeded for na_admin
- sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
- sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 10.78.28.194>]
- rcvd [LCP EchoRep id=0x0 magic=0x58452c14]
- rcvd [CCP ConfReq id=0x4 < 12 06 00 00 00 01>]
- sent [CCP ConfRej id=0x4 < 12 06 00 00 00 01>]
- rcvd [IPCP ConfReq id=0x5 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-wins 0.0.0.0> <ms-
- dns3 0.0.0.0> <ms-wins 0.0.0.0>]
- sent [IPCP ConfRej id=0x5 <ms-wins 0.0.0.0> <ms-wins 0.0.0.0>]
- rcvd [CCP ConfRej id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
- sent [CCP ConfReq id=0x2]
- rcvd [IPCP ConfAck id=0x1 <compress VJ 0f 01> <addr 10.78.28.194>]
- rcvd [CCP TermReq id=0x6"XE,\024\000<\315t\000\000\002\334"]
- sent [CCP TermAck id=0x6]
- rcvd [IPCP ConfReq id=0x7 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
- sent [IPCP ConfNak id=0x7 <addr 10.78.28.224> <ms-dns1 10.78.28.10> <ms-dns3 10.78.28.11>]
- rcvd [IPCP ConfReq id=0x8 <compress VJ 0f 01> <addr 10.78.28.224> <ms-dns1 10.78.28.10> <ms-dns3
- 10.78.28.11>]
- sent [IPCP ConfAck id=0x8 <compress VJ 0f 01> <addr 10.78.28.224> <ms-dns1 10.78.28.10> <ms-dns3
- 10.78.28.11>]
- local IP address 10.78.28.194
- remote IP address 10.78.28.224
测试
/apps/etc/ppp >: ping 10.78.28.224
PING 10.78.28.224 (10.78.28.224): 56 data bytes
64 bytes from 10.78.28.224: seq=0 ttl=64 time=194.570 ms
64 bytes from 10.78.28.224: seq=1 ttl=64 time=190.331 ms