通过 GSM 模块 + PPP 的互联网连接

通过 GSM 模块 + PPP 的互联网连接

我正在尝试使用 GSM (SIM900a) 模块在我的树莓派 3 (Raspbian) 中建立互联网连接,将其连接到 RXD/TXD 串行端口 (/dev/ttyS0),我已经获得了 IP 地址和 DNS,但我可以甚至无法 ping 通任何主机,所以我认为这一定是路由问题。

我认为我缺少的可能是 iptables 规则...与 POSTROUTING MASQUERADE 相关的东西?我不知道...

/var/log/messages 中的 ppp 输出:

Oct 18 22:09:35 NULL chat[1277]: abort on (BUSY)
Oct 18 22:09:35 NULL chat[1277]: abort on (NO CARRIER)
Oct 18 22:09:35 NULL chat[1277]: abort on (VOICE)
Oct 18 22:09:35 NULL chat[1277]: abort on (NO DIALTONE)
Oct 18 22:09:35 NULL chat[1277]: abort on (NO DIAL TONE)
Oct 18 22:09:35 NULL chat[1277]: abort on (NO ANSWER)
Oct 18 22:09:35 NULL chat[1277]: abort on (DELAYED)
Oct 18 22:09:35 NULL chat[1277]: report (CONNECT)
Oct 18 22:09:35 NULL chat[1277]: timeout set to 6 seconds
Oct 18 22:09:35 NULL chat[1277]: send (ATQ0^M)
Oct 18 22:09:35 NULL chat[1277]: expect (OK)
Oct 18 22:09:35 NULL chat[1277]: ATQ0^M^M
Oct 18 22:09:35 NULL chat[1277]: OK
Oct 18 22:09:35 NULL chat[1277]:  -- got it
Oct 18 22:09:35 NULL chat[1277]: send (ATZ^M)
Oct 18 22:09:35 NULL chat[1277]: timeout set to 3 seconds
Oct 18 22:09:35 NULL chat[1277]: expect (OK)
Oct 18 22:09:35 NULL chat[1277]: ^M
Oct 18 22:09:35 NULL chat[1277]: ATZ^M^M
Oct 18 22:09:35 NULL chat[1277]: OK
Oct 18 22:09:35 NULL chat[1277]:  -- got it
Oct 18 22:09:35 NULL chat[1277]: send (AT+CPIN=5503^M)
Oct 18 22:09:35 NULL chat[1277]: expect (OKd)
Oct 18 22:09:35 NULL chat[1277]: ^M
Oct 18 22:09:35 NULL chat[1277]: AT+CPIN=5503^M^M
Oct 18 22:09:35 NULL chat[1277]: ERROR^M
Oct 18 22:09:38 NULL chat[1277]: alarm
Oct 18 22:09:38 NULL chat[1277]: send (AT^M)
Oct 18 22:09:38 NULL chat[1277]: expect (OK)
Oct 18 22:09:38 NULL chat[1277]: AT^M^M
Oct 18 22:09:38 NULL chat[1277]: OK
Oct 18 22:09:38 NULL chat[1277]:  -- got it
Oct 18 22:09:38 NULL chat[1277]: send (ATI^M)
Oct 18 22:09:38 NULL chat[1277]: expect (OK)
Oct 18 22:09:38 NULL chat[1277]: ^M
Oct 18 22:09:38 NULL chat[1277]: ATI^M^M
Oct 18 22:09:38 NULL chat[1277]: SIM900 R11.0^M
Oct 18 22:09:38 NULL chat[1277]: ^M
Oct 18 22:09:38 NULL chat[1277]: OK
Oct 18 22:09:38 NULL chat[1277]:  -- got it
Oct 18 22:09:38 NULL chat[1277]: send (ATZ^M)
Oct 18 22:09:38 NULL chat[1277]: expect (OK)
Oct 18 22:09:38 NULL chat[1277]: ^M
Oct 18 22:09:38 NULL chat[1277]: ATZ^M^M
Oct 18 22:09:38 NULL chat[1277]: OK
Oct 18 22:09:38 NULL chat[1277]:  -- got it
Oct 18 22:09:38 NULL chat[1277]: send (ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0^M)
Oct 18 22:09:39 NULL chat[1277]: expect (OK)
Oct 18 22:09:39 NULL chat[1277]: ^M
Oct 18 22:09:39 NULL chat[1277]: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0^M^M
Oct 18 22:09:39 NULL chat[1277]: OK
Oct 18 22:09:39 NULL chat[1277]:  -- got it
Oct 18 22:09:39 NULL chat[1277]: send (AT^M)
Oct 18 22:09:39 NULL chat[1277]: expect (OK)
Oct 18 22:09:39 NULL chat[1277]: ^M
Oct 18 22:09:39 NULL chat[1277]: AT^M^M
Oct 18 22:09:39 NULL chat[1277]: OK
Oct 18 22:09:39 NULL chat[1277]:  -- got it
Oct 18 22:09:39 NULL chat[1277]: send (AT+CGDCONT=1,"IP","lowi.private.omv.es"^M)
Oct 18 22:09:39 NULL chat[1277]: expect (OK)
Oct 18 22:09:39 NULL chat[1277]: ^M
Oct 18 22:09:39 NULL chat[1277]: AT+CGDCONT=1,"IP","lowi.private.omv.es"^M^M
Oct 18 22:09:39 NULL chat[1277]: OK
Oct 18 22:09:39 NULL chat[1277]:  -- got it
Oct 18 22:09:39 NULL chat[1277]: send (ATDT*99***1#^M)
Oct 18 22:09:39 NULL chat[1277]: timeout set to 30 seconds
Oct 18 22:09:39 NULL chat[1277]: expect (CONNECT)
Oct 18 22:09:39 NULL chat[1277]: ^M
Oct 18 22:09:39 NULL chat[1277]: ATDT*99***1#^M^M
Oct 18 22:09:39 NULL chat[1277]: CONNECT
Oct 18 22:09:39 NULL chat[1277]:  -- got it
Oct 18 22:09:39 NULL chat[1277]: send (^M)
Oct 18 22:09:39 NULL pppd[1270]: Script /usr/sbin/chat -v -t15 -f /etc/ppp/chatscripts/mobile-modem.chat finished (pid 1276), status = 0x0
Oct 18 22:09:39 NULL pppd[1270]: Serial connection established.
Oct 18 22:09:39 NULL pppd[1270]: using channel 1
Oct 18 22:09:39 NULL pppd[1270]: Using interface ppp0
Oct 18 22:09:39 NULL pppd[1270]: Connect: ppp0 <--> /dev/ttyS0
Oct 18 22:09:40 NULL pppd[1270]: sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic0x16c75854> <pcomp> <accomp>]
Oct 18 22:09:41 NULL pppd[1270]: rcvd [LCP ConfReq id=0x1 <asyncmap 0xa0000> <auth pap>]
Oct 18 22:09:41 NULL pppd[1270]: sent [LCP ConfAck id=0x1 <asyncmap 0xa0000> <auth pap>]
Oct 18 22:09:41 NULL pppd[1270]: rcvd [LCP ConfRej id=0x1 <magic 0x16c75854> <pcomp> <accomp>]
Oct 18 22:09:41 NULL pppd[1270]: sent [LCP ConfReq id=0x2 <asyncmap 0x0>]
Oct 18 22:09:41 NULL pppd[1270]: rcvd [LCP ConfAck id=0x2 <asyncmap 0x0>]
Oct 18 22:09:41 NULL pppd[1270]: sent [LCP EchoReq id=0x0 magic=0x0]
Oct 18 22:09:41 NULL pppd[1270]: sent [PAP AuthReq id=0x1 user="NULL" password=<hidden>]
Oct 18 22:09:41 NULL pppd[1270]: rcvd [LCP EchoRep id=0x0 magic=0x0]
Oct 18 22:09:41 NULL pppd[1270]: rcvd [PAP AuthAck id=0x1 "Login OK"]
Oct 18 22:09:41 NULL pppd[1270]: Remote message: Login OK
Oct 18 22:09:41 NULL pppd[1270]: PAP authentication succeeded
Oct 18 22:09:41 NULL pppd[1270]: sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
Oct 18 22:09:41 NULL pppd[1270]: sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
Oct 18 22:09:41 NULL pppd[1270]: rcvd [LCP ProtRej id=0x2 80 fd 01 01 00 0f 1a 04 78 00 18 04 78 00 15 03 2f]
Oct 18 22:09:41 NULL pppd[1270]: Protocol-Reject for 'Compression Control Protocol' (0x80fd) received
Oct 18 22:09:44 NULL pppd[1270]: sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
Oct 18 22:09:44 NULL pppd[1270]: rcvd [IPCP ConfReq id=0x1 <addr 192.200.1.21>]
Oct 18 22:09:44 NULL pppd[1270]: sent [IPCP ConfAck id=0x1 <addr 192.200.1.21>]
Oct 18 22:09:44 NULL pppd[1270]: rcvd [IPCP ConfNak id=0x1 <addr 10.242.68.43> <ms-dns1 195.219.66.42> <ms-dns2 87.119.194.34>]
Oct 18 22:09:44 NULL pppd[1270]: sent [IPCP ConfReq id=0x2 <addr 10.242.68.43> <ms-dns1 195.219.66.42> <ms-dns2 87.119.194.34>]
Oct 18 22:09:44 NULL pppd[1270]: rcvd [IPCP ConfAck id=0x2 <addr 10.242.68.43> <ms-dns1 195.219.66.42> <ms-dns2 87.119.194.34>]
Oct 18 22:09:44 NULL pppd[1270]: not replacing default route to wlan0 [192.168.1.1]
Oct 18 22:09:44 NULL pppd[1270]: local  IP address 10.242.68.43
Oct 18 22:09:44 NULL pppd[1270]: remote IP address 192.200.1.21
Oct 18 22:09:44 NULL pppd[1270]: primary   DNS address 195.219.66.42
Oct 18 22:09:44 NULL pppd[1270]: secondary DNS address 87.119.194.34
Oct 18 22:09:44 NULL pppd[1270]: Script /etc/ppp/ip-up started (pid 1286)
Oct 18 22:09:44 NULL pppd[1270]: Script /etc/ppp/ip-up finished (pid 1286), status = 0x0

ifconfig 输出:

pi@NULL:~ $ ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:34:7a:5e
          inet6 addr: fe80::e8a7:c560:2f66:73a2/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:200 errors:0 dropped:0 overruns:0 frame:0
          TX packets:200 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:16656 (16.2 KiB)  TX bytes:16656 (16.2 KiB)

ppp0      Link encap:Point-to-Point Protocol
          inet addr:10.242.68.43  P-t-P:192.200.1.21  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:54 (54.0 B)  TX bytes:91 (91.0 B)

wlan0     Link encap:Ethernet  HWaddr b8:27:eb:61:2f:0b
          inet addr:192.168.1.5  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::509e:723a:2fb:453/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7937 errors:0 dropped:759 overruns:0 frame:0
          TX packets:1040 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1477582 (1.4 MiB)  TX bytes:199477 (194.8 KiB)

PD:我已将主机名设置为“NULL”,这可能会在日志的某些点上造成混淆,抱歉

相关内容