当前位置:网站首页>移远EC20 4G模块拨号相关
移远EC20 4G模块拨号相关
2022-08-09 06:29:00 【qq_36412526】
1.ec20拨号方法
以下摘自移远的说明文档:
有2种方法启动ppp拨号
方式1: 拷贝 quectel-chat-connect quectel-chat-disconnect quectel-ppp 到 /etc/ppp/peers 目录下。
并在 quectel-ppp 里修改你的串口设备名,pppd 拨号使用的 username,password。
在 quectel-chat-connect 里修改你的 APN。APN/username/password 是从你的网络提供商那里获取的。
然后使用下面的命令启动 ppp 拨号, 命令最后的 & 可以让 pppd 后台运行
pppd call quectel-ppp &
方式2:使用quectel-pppd.sh 拨号,命令形式如下:
./quectel-pppd.sh 串口设备名(比如/dev/ttyUSB3) APN username password
ip-up:pppd 在获取 ip 和 dns 之后,会自动调用这个脚本文件来设置系统的 DNS
嵌入式系统一般需要拷贝这个文件到 /etc/ppp 目录下。
请确保该文件在你的系统里有可执行权限。
quectel-ppp-kill 用来挂断拨号的,pppd必须被正常的挂断,否则可能会导致你下次ppp拨号失败。
使用下面方式来调用这个脚本
./quectel-ppp-kill
2.ec20模块ppp拨号流程

3.拨号成功但不能ping通外网
拨号成功但是未将ppp0设置为静态路由。设置PPP0为默认路由:先删除原来路由,route del default 再将ppp0设置为默认路由,route add default dev ppp0
为了实现自动设置ppp0为默认路由,我的方法是在/etc/ppp/ip-up脚本里添加
[email protected]:/etc/ppp# cat ip-up
#!/bin/sh
if [ -f /etc/ppp/resolv.conf ]; then
cp /etc/ppp/resolv.conf /etc/resolv.conf
elif [ -f /var/run/ppp/resolv.conf ]; then
cp /var/run/ppp/resolv.conf /etc/resolv.conf
else
echo nameserver $DNS1 > /etc/resolv.conf
echo nameserver $DNS2 >> /etc/resolv.conf
fi
route del default #删除原来的路由
route add default dev ppp0 #设置ppp0为默认路由
拨号成功后查看路由信息:
n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 ppp0
10.5.112.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.64.64.64 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
可见,ppp0的路由信息已经添加成功,这时候再ping www.baidu.com,成功
64 bytes from 36.152.44.96 (36.152.44.96): icmp_seq=14 ttl=54 time=33.2 ms
64 bytes from 36.152.44.96 (36.152.44.96): icmp_seq=15 ttl=54 time=41.2 ms
4.关于ip-up和ip-up.d的说明
1. /etc/ppp/ip-up 由 ppp 套件 提供
1-1. sudo dpkg -S /etc/ppp/ip-up
ppp: /etc/ppp/ip-up
2. /etc/ppp/ip-up.d 可以由
ppp, resolvconf, pppconfig, pppoeconf, gogoc
任何一個套件提供
2-1. sudo dpkg -S /etc/ppp/ip-up.d
ppp, resolvconf, pppconfig, pppoeconf, gogoc: /etc/ppp/ip-up.d
3. /etc/ppp/ip-up 是 檔案; /etc/ppp/ip-up.d 是 目錄
3-1. sudo ls -Al /etc/ppp | grep ip-up
-rwxr-xr-x 1 root root 1892 2月 4 2011 ip-up
drwxr-xr-x 2 root root 4096 7月 24 12:53 ip-up.d
3-2. sudo ls -Al /etc/ppp/ip-up.d
-rwxr-xr-x 1 root root 902 2月 4 2011 0000usepeerdns
-rwxr-xr-x 1 root root 553 6月 4 2015 000resolvconf
-rwxr-xr-x 1 root root 4022 10月 24 2015 0dns-up
-rwxr-xr-x 1 root root 148 3月 30 2010 gogoc
4. 都是 可執行 script file
4-1. sudo cat /etc/ppp/ip-up
#!/bin/sh
以下省略
4-2. sudo cat /etc/ppp/ip-up.d/0000usepeerdns
#!/bin/sh -e
以下省略
5.关闭ppp0连接以后恢复以太网的默认路由,否则以太网不通(???)
我解决这个问题的办法是在ip-down脚本里增加service networking restart
修改后的ip-down脚本如下
[email protected]:/etc/ppp# cat ip-down
#!/bin/sh
#
# This script is run by the pppd _after_ the link is brought down.
# It uses run-parts to run scripts in /etc/ppp/ip-down.d, so to delete
# routes, unset IP addresses etc. you should create script(s) there.
#
# Be aware that other packages may include /etc/ppp/ip-down.d scripts (named
# after that package), so choose local script names with that in mind.
#
# This script is called with the following arguments:
# Arg Name Example
# $1 Interface name ppp0
# $2 The tty ttyS1
# $3 The link speed 38400
# $4 Local IP number 12.34.56.78
# $5 Peer IP number 12.34.56.99
# $6 Optional ``ipparam'' value foo
# The environment is cleared before executing this script
# so the path must be reset
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
export PATH
# These variables are for the use of the scripts run by run-parts
PPP_IFACE="$1"
PPP_TTY="$2"
PPP_SPEED="$3"
PPP_LOCAL="$4"
PPP_REMOTE="$5"
PPP_IPPARAM="$6"
export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM
# as an additional convenience, $PPP_TTYNAME is set to the tty name,
# stripped of /dev/ (if present) for easier matching.
PPP_TTYNAME=`/usr/bin/basename "$2"`
export PPP_TTYNAME
# If /var/log/ppp-ipupdown.log exists use it for logging.
if [ -e /var/log/ppp-ipupdown.log ]; then
exec >> /var/log/ppp-ipupdown.log 2>&1
echo $0 [email protected]
echo
fi
# This script can be used to override the .d files supplied by other packages.
if [ -x /etc/ppp/ip-down.local ]; then
exec /etc/ppp/ip-down.local "[email protected]"
fi
run-parts /etc/ppp/ip-down.d \
--arg="$1" --arg="$2" --arg="$3" --arg="$4" --arg="$5" --arg="$6"
service networking restart
再查看路由信息如下:
[email protected]:/etc/ppp# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.5.112.254 0.0.0.0 UG 0 0 0 eth0
10.5.112.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
可见已经恢复成eth0的默认路由
边栏推荐
- Unity Gobang Game Design and Simple AI(3)
- Data center project preliminary summary
- Gao Zelong, a famous digital collection expert and founder of the Digital Collection Conference, was interviewed by China Entrepreneur Magazine
- Remember a nest.js route that matches all the path problems that follow
- 2022-08-08: Given an array arr, it represents the height of the missiles that will appear in order from morning to night.When the cannon shoots missiles, once the cannon is set to shoot at a certain h
- GNNExplainer applied to node classification task
- io.lettuce.core.RedisCommandTimeoutException Command timed out
- crc计算
- static静态关键字和继承
- 05 多线程与高并发 - ThreadPoolExecutor 源码解析
猜你喜欢

输入框最前面添加放大镜&&background-image和background-color冲突问题

工控设备的系统如何进行加固

深度学习-神经网络原理2

C语言实现顺序栈和链队列

抗菌药物丨Toronto Research Chemicals 天冬酰胺D

报错:FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disab

Search 1688 product interface by image (item_search_img-search 1688 product by image (Politao interface) code docking tutorial

Data center project preliminary summary

CalBioreagents超全Id 蛋白兔单克隆抗体,助力科研

A test engineer with an annual salary of 35W was laid off. Personal experience: advice that you have to listen to
随机推荐
C language implements sequential stack and chain queue
Magnetic Core-Shell Fe3O4 Particles Supported Gold Nanostars | Magnetic Fe3O4-POSS-COOH | Superparamagnetic Fe3O4-Polydopamine Core-Shell Nanoparticles
Polyamide-amine (PAMAM) dendrimer-bismuth sulfide composite nanoparticles | bismuth sulfide modified Gd‑DTPA‑OA ligand | for scientific research
普罗米修斯原理及节点发布
带头双向循环链表的增删查改(C语言实现)
按图搜索1688商品接口(item_search_img-按图搜索1688商品(拍立淘接口)代码对接教程
Gao Zelong, a famous digital collection expert and founder of the Digital Collection Conference, was interviewed by China Entrepreneur Magazine
Error jinja2.exceptions.UndefinedError: 'form' is undefined
uniapp实现防抖搜索
[MySQL] Second, the relationship between processes, MySQL password cracking, table building and database building related commands
VB.net程序关闭后后台还在与SQL连接
vs番茄助手的方便功能和便捷快捷键介绍
kubernetes security
String.toLowerCase(Locale.ROOT)
SiO2 / KH550 modified ferroferric oxide nano magnetic particles | PDA package the ferromagnetic oxide nanoparticles (research)
GNNExplainer应用于节点分类任务
默默重新开始,第一页也是新的一页
sql problem solving statement to create a table
GNNExplainer applied to node classification task
阿里巴巴官方技术号