有一个 Raspberry PI 3B+ 设备,带有通过 UART 连接的 SIM7000E GSM 模块。目标是将 pppd 配置为从 Raspberry PI 访问 Internet。
问题定义: PPPD配置如下,成功建立移动网络连接,树莓可以上网,可以ping通互联网上的各种域名。但是,此连接仅工作 1-2 几十秒,然后 Internet 访问变得不可用。无论 Internet 访问是否不可用,连接仍然存在一段时间。
/etc/ppp/peers/gprs文件的内容:
user "congstar"
password "cs"
connect "/usr/sbin/chat -v -f /etc/chatscripts/pap -T *99#"
# Serial device to which the modem is connected.
/dev/ttyAMA0
# Baudrate
115200
nocrtscts
debug
nodetach
ipcp-accept-local
ipcp-accept-remote
# Assumes that your IP address is allocated dynamically by the ISP.
noipdefault
# Try to get the name server addresses from the ISP.
usepeerdns
# Use this connection as the default route.
defaultroute
# Replaces the default route
replacedefaultroute
# Makes pppd "dial again" when the connection is lost.
persist
# Do not ask the remote to authenticate.
noauth
/etc/chatscripts/pap文件的内容:
#REPORT CONNECT
ABORT BUSY
ABORT VOICE
ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT "NO DIAL TONE"
"" ATZ
OK AT+CGDCONT=1,"IP","internet.telekom","0.0.0.0",0,0
OK ATDT\T
CONNECT ""
我使用以下命令运行 pppd 进程:
pppd call gprs
它给出了以下输出:
Script /usr/sbin/chat -v -f /etc/chatscripts/pap -T *99# finished (pid 466), status = 0x0
Serial connection established.
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/ttyAMA0
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xfa266a86> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0xd0837b0a> <pcomp> <accomp>]
sent [LCP ConfAck id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0xd0837b0a> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xfa266a86> <pcomp> <accomp>]
sent [LCP EchoReq id=0x0 magic=0xfa266a86]
rcvd [LCP DiscReq id=0x1 magic=0xd0837b0a]
rcvd [CHAP Challenge id=0x1 <ed30b6a62ef9f9424e0827f63f5233c0>, name = "UMTS_CHAP_SRVR"]
sent [CHAP Response id=0x1 <e1b557afa30e21d98517993f053097de>, name = "congstar"]
rcvd [LCP EchoRep id=0x0 magic=0xd0837b0a fa 26 6a 86]
rcvd [CHAP Success id=0x1 ""]
CHAP authentication succeeded
CHAP authentication succeeded
sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
rcvd [LCP ProtRej id=0x2 80 fd 01 01 00 0f 1a 04 78 00 18 04 78 00 15 03 2f]
Protocol-Reject for 'Compression Control Protocol' (0x80fd) received
rcvd [IPCP ConfReq id=0x0]
sent [IPCP ConfNak id=0x0 <addr 0.0.0.0>]
rcvd [IPCP ConfRej id=0x1 <compress VJ 0f 01>]
sent [IPCP ConfReq id=0x2 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfAck id=0x1]
rcvd [IPCP ConfNak id=0x2 <addr 10.30.47.58> <ms-dns1 10.74.210.210> <ms-dns2 10.74.210.211>]
sent [IPCP ConfReq id=0x3 <addr 10.30.47.58> <ms-dns1 10.74.210.210> <ms-dns2 10.74.210.211>]
rcvd [IPCP ConfAck id=0x3 <addr 10.30.47.58> <ms-dns1 10.74.210.210> <ms-dns2 10.74.210.211>]
Could not determine remote IP address: defaulting to 10.64.64.64
local IP address 10.30.47.58
remote IP address 10.64.64.64
primary DNS address 10.74.210.210
secondary DNS address 10.74.210.211
Script /etc/ppp/ip-up started (pid 473)
Script /etc/ppp/ip-up finished (pid 473), status = 0x0
No response to 4 echo-requests
Serial link appears to be disconnected.
Connect time 1683.8 minutes.
Sent 11846 bytes, received 2597 bytes.
Script /etc/ppp/ip-down started (pid 644)
sent [LCP TermReq id=0x2 "Peer not responding"]
Script /etc/ppp/ip-down finished (pid 644), status = 0x0
sent [LCP TermReq id=0x3 "Peer not responding"]
Connection terminated.
Modem hangup
有必要提及:
- 只有当 GSM 模块通过 UART 连接到 Raspberry PI 时,才会发生上述行为!当 GSM 调制解调器通过 USB 连接到 Raspberry PI时,在相同的配置下一切正常(在这种情况下,使用 /dev/ttyUSB2 而不是 /dev/ttyAMA0 )并且没有观察到所描述的问题。
- Raspberry PI 使用主 UART /dev/ttyAMA0。它被配置为不使用自动波特率功能。
- 使用 Raspbian 10,它在内核中支持 PPP。