AM400P Linux 拨号指南
## 1. 内核添加 PPP 支持
````
Device Drivers --->
[*]Network device support (NETDEVICES [=y]) --->
{*} PPP(point-to-point protocol) support
````
## 2. 添加拨号脚本
为了建立 PPP 拨号连接,需要通过脚本连接,包括“Amaziot-pppdial”、“ Amaziot -chat-connect”、“ Amaziot -chat-disconnect”。 Amaziot -pppdial 脚本内容如下:
````
#/etc/ppp/peers/Neoway-pppdial
#Usage:root@neoway:~# pppd call Neoway-pppdial
#Hide password in debug messages
hide-password
#The phone is not required to authenticate
noauth
#The chat script (be sure to edit that file,too!)
connect '/usr/sbin/chat -s -v -f /etc/ppp/peers/Neoway-chat-connect'
#The close script(be sure to edit that file,too!)
disconnect '/usr/sbin/chat -s -v -f /etc/ppp/peers/Neoway-chat-disconnect'
#Debug info from pppd
debug
#Modem path, like /dev/ttyUSB0, /dev/ttyACM0
/dev/<modem port>
#Serial port line speed
115200
#If you want to use the link as your gateway
defaultroute
#pppd must not propose any IP address to the peer
noipdefault
#No ppp compression
novj
novjccomp
noccp
ipcp-accept-local
ipcp-accept-remote
local
#For sanity, keep a lock on the serial line
lock
dump
#Keep pppd attached to the terminal
#Comment this to get daemon mode pppd
nodetach
#insert here the correct username and password for authentication
user "3gnet"
password "1234"
#Hardware flow control
crtscts
remotename 3gppp
ipparam 3gppp
#Ask the peer for up to 2 DNS server addresses
usepeerdns
````
### Amaziot -chat-connect 脚本内容如下:
````
#/etc/ppp/peers/Neoway-chat-connect
TIMEOUT 5
ABORT "BUSY"
ABORT "DELAYED"
ABORT "ERROR"
ABORT "NO DIALTONE"
ABORT "NO CARRIER"
‘’ AT
OK AT+CPIN?
OK AT+CSQ
OK AT+CGREG?
OK AT+CGDCONT=1,"IP","<输入卡对应的 APN>"
OK ATDT*99#
CONNECT ''
Amaziot -chat-disconnect 脚本内容如下:
ABORT "ERROR"
ABORT "NO DIALTONE"
SAY "\NSending break to the modem\n"
"" +++ATH
SAY "\nGood bye\n"
````
## 3.执行拨号
将上面三个脚本拷贝到“/etc/ppp/peers”路径下,然后可以进入步骤三 执行拨号。
````
root@support:/etc/ppp/peers# pppd call Neoway-pppdial
pppd options in effect:
debug # (from /etc/ppp/peers/Neoway-pppdial)
nodetach # (from /etc/ppp/peers/Neoway-pppdial)
dump # (from /etc/ppp/peers/Neoway-pppdial)
noauth # (from /etc/ppp/peers/Neoway-pppdial)
user card # (from /etc/ppp/peers/Neoway-pppdial)
password ?????? # (from /etc/ppp/peers/Neoway-pppdial)
remotename 3gppp # (from /etc/ppp/peers/Neoway-pppdial)
/dev/ttyACM2 # (from /etc/ppp/peers/Neoway-pppdial)
115200 # (from /etc/ppp/peers/Neoway-pppdial)
lock # (from /etc/ppp/peers/Neoway-pppdial)
connect /usr/sbin/chat -s -v -f /etc/ppp/peers/Neoway-chat-connect # (from
/etc/ppp/peers/Neoway-pppdial)
disconnect /usr/sbin/chat -s -v -f /etc/ppp/peers/Neoway-chat-disconnect # (from
/etc/ppp/peers/Neoway-pppdial)
crtscts # (from /etc/ppp/peers/Neoway-pppdial)
local # (from /etc/ppp/peers/Neoway-pppdial)
asyncmap 0 # (from /etc/ppp/options)
lcp-echo-failure 4 # (from /etc/ppp/options)N720V5
lcp-echo-interval 30 # (from /etc/ppp/options)
hide-password # (from /etc/ppp/peers/Neoway-pppdial)
novj # (from /etc/ppp/peers/Neoway-pppdial)
novjccomp # (from /etc/ppp/peers/Neoway-pppdial)
ipcp-accept-local # (from /etc/ppp/peers/Neoway-pppdial)
ipcp-accept-remote # (from /etc/ppp/peers/Neoway-pppdial)
ipparam 3gppp # (from /etc/ppp/peers/Neoway-pppdial)
noipdefault # (from /etc/ppp/peers/Neoway-pppdial)
defaultroute # (from /etc/ppp/peers/Neoway-pppdial)
usepeerdns # (from /etc/ppp/peers/Neoway-pppdial)
noccp # (from /etc/ppp/peers/Neoway-pppdial)
noipx # (from /etc/ppp/options)
timeout set to 5 seconds
abort on (BUSY)
abort on (DELAYED)
abort on (ERROR)
abort on (NO DIALTONE)
abort on (NO CARRIER)
send (AT^M)
expect (OK)
AT^M^M
OK
-- got it
send (AT+CPIN?^M)
expect (OK)
^M
AT+CPIN?^M^M
+CPIN: READY^M
OK
-- got it
send (AT+CSQ^M)
expect (OK)
^M
AT+CSQ^M^M
+CSQ: 22,99^M
OK
-- got it
send (AT+CGREG?^M)
expect (OK)
^M
AT+CGREG?^M^M
+CGREG: 0,1^M
OK
-- got itN720V5
send (AT+CGDCONT=1,"IP","ctlte"^M)
expect (OK)
^M
AT+CGDCONT=1,"IP","ctlte"^M^M
OK
-- got it
send (ATDT*99#^M)
expect (CONNECT)
^M
ATDT*99#^M^M
CONNECT
-- got it
send (^M)
Script /usr/sbin/chat -s -v -f /etc/ppp/peers/Neoway-chat-connect finished (pid 2525), status =
0x0
Serial connection established.
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/ttyUSB2
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xd4e474a1> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x0 <asyncmap 0x0> <auth pap> <magic 0x329eafc8> <pcomp> <accomp>]
sent [LCP ConfAck id=0x0 <asyncmap 0x0> <auth pap> <magic 0x329eafc8> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xd4e474a1> <pcomp> <accomp>]
sent [LCP EchoReq id=0x0 magic=0xd4e474a1]
sent [PAP AuthReq id=0x1 user="card" password=<hidden>]
rcvd [LCP DiscReq id=0x1 magic=0x329eafc8]
rcvd [LCP EchoRep id=0x0 magic=0x329eafc8 d4 e4 74 a1]
rcvd [PAP AuthAck id=0x1 ""]
PAP authentication succeeded
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
rcvd [IPCP ConfReq id=0x0]
sent [IPCP ConfNak id=0x0 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1 <addr 10.17.124.103> <ms-dns1 202.96.128.86> <ms-dns2 202.96.134.133>]
sent [IPCP ConfReq id=0x2 <addr 10.17.124.103> <ms-dns1 202.96.128.86> <ms-dns2 202.96.134.133>]
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfAck id=0x1]
rcvd [IPCP ConfAck id=0x2 <addr 10.17.124.103> <ms-dns1 202.96.128.86> <ms-dns2 202.96.134.133>]
Could not determine remote IP address: defaulting to 10.64.64.64
not replacing existing default route via 192.168.12.1
local IP address 10.17.124.103
remote IP address 10.64.64.64
primary DNS address 202.96.128.86
secondary DNS address 202.96.134.133
Script /etc/ppp/ip-up started (pid 2531)
Script /etc/ppp/ip-up finished (pid 2531), status = 0x0
````