ppp拨号脚本配置
其他的参数具体含义可以参照参考PPPD2.4.4 中options.c中注释:
int debug = 0;
int kdebugflag = 0;
int default_device = 1;
char devnam[MAXPATHLEN];
bool nodetach = 0;
bool updetach = 0;
int maxconnect = 0;
char user[MAXNAMELEN];
char passwd[MAXSECRETLEN];
bool persist = 0;
char our_name[MAXNAMELEN];
bool demand = 0;
char *ipparam = NULL;
int idle_time_limit = 0;
int holdoff = 30;
bool holdoff_specified;
int log_to_fd = 1;
bool log_default = 1;
int maxfail = 10;
char linkname[MAXPATHLEN];
bool tune_kernel;
int connect_delay = 1000;
int req_unit = -1;
bool multilink = 0;
char *bundle_name = NULL;
bool dump_options;
bool dryrun;
char *domain;
int child_wait = 5;
3. 鉴权脚本
一般情况下,PPP连接是需要进行身份认证的。签权方式有两种,一种是PAP鉴权,另一种是CHAP鉴权。鉴权需要的用户名和密码是存放在PAP-secrets和chap-secrets脚本中,以如下方式存放:
Username * password
需要进行鉴权时,通过在options脚本中指定鉴权方式为PAP或CHAP,PPP模块就会从PAP-secrets和chap-secrets脚本中读出用户名和密码,附加到PPP的鉴权包中,发送到服务器端进行身份认证。
4. PPP拨号过程与脚本之间的关系
脚本设置成功以后,怎么和pppd2.4.4一起工作呢?这个需要从pppd程序的主函数入手。
这个过程是这样的:
Pppd程序启动以后,就会按照pathname.h中所指定的文家位置去寻找options脚本文件。这个可以按照需要指定文件的位置,确保pppd能够准确找到该文件。
Pppd找到options文件后,按顺序读入参数行。在这里,就可以获取系统要使用的是哪个设备来进行联网、设备的速率是多少。
Pppd 将配置的参数解析为程序当中的全局变量标识符,进行pppd连接控制。
三.实践情况
下面是FT282 上的PPP连接使用的OPTIONS、 CHAT和PAP-SECRETS脚本。
OPTIONS:
connect "/usr/bin/chat -v -t6 -f /var/ppp/td-scdma_chat"
ttyUSB0
115200
debug
logfile /var/log/ppplog
mtu 1500
-detach
noauth
noipdefault
defaultroute
usepeerdns
crtscts
lock
lcp-echo-failure 4
-ccp
-vj
-chap
-mschap-v2
user
hide-password
CHAT:
"" AT
OK ATDT*98*1#
CONNECT ""
PAP-SECRETS:
wap *wap
经过在FT282上进行测试,发现能够顺利进行PPP连接。
常见问题:
1、3G/GSM connection returning "Connect script failed"
Q. I am running into an error when enabling the 3G dongle. I run this command -----> pppd nodetach call e160. And the output is:
Script /usr/sbin/chat -vf /etc/ppp/peers/e160_chat finished (pid 1843), status = 0x3
Connect script failed
A. "Connect script failed" is a generic error and can mean several things:
1. SIM card not detected, not attached to an active cell plan, or attached to a cell plan without 3G data service activated.
2. Weak cell signal - try moving the plug to another location, such as closer to a window. With a weaker signal you may need to run the "pppd nodetach..." command several times before it can lock onto a signal. If your 3G/GSM adapter has an external antenna port, consider attaching a GSM antenna to boost the signal.
3. Adapter not ready. Try waiting 1 minute after connecting the adapter before attempting to connect. Check dmesg to confirm the adapter is detected as a GSM device (Look for "usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0")
4. The GSM modem device on the adapter may be showing up as something besides /dev/ttyUSB0. Try changing to /dev/ttyUSB1 or /dev/ttyUSB2 in the config file /etc/ppp/peers/e160 (Look for the line "# Serial device to which the modem is connected").