1.概述
systemd-networkd 是一个管理网络服务程序,可以用来管理以太网,WIFI,网桥,
EC20 等模块的网络优先级,以及连接情况。配合 systemd-resolved 服务一起使用。
本章主要目的是学习以太网,wifi,EC20 模块同时管理,并按指定优先级收发数据。
2.硬件资源
MYD-YA15XC-T 开发板
WIFI 天线
USB 转接板
EC20 模块
网线
路由器
3. 软件资源
Linux kernel 5.4.31
systemd-networkd
systemd-resolved
4.环境准备
将 MYD-YA15XC-T 烧入镜像,wifi 天线连接 WIFI, EC20 模块接入 USB 口,接入网
线,路由器配置 wifi 热点,并连接外网。
5.操作步骤
5.1.检查环境
1) 检查 systemd-networkd 运行状态。
root@myir:~# systemctl status systemd-networkd
[[0;1;32m●[[0m systemd-networkd.service - Network Service
Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vend
or preset:
Active: active (running)[[0m since Fri 2020-04-10 18:39:40 UTC; 40min ago
2) 检查 systemd-resolved 运行状态。
root@myir:~# systemctl status systemd-resolved
systemd-resolved.service - Network Name Resolution
Loaded: loaded (/lib/systemd/system/systemd-resolved.service; enabled; vendor
preset: enabled):40:02 myir systemd-networkd[205]: usb0: Configured
Active: active (running)[[0m since Fri 2020-04-10 18:39:41 UTC; 42min ago
Active: active(running) 正在运行
3) 查看 DNS 配置文件
root@myir:~# ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 24 Mar 9 2018 /etc/resolv.conf -> /etc/resolv-conf.system
d
root@myir:~# ls -l /sbin/resolvconf
lrwxrwxrwx 1 root root 21 Mar 9 2018 /sbin/resolvconf -> ../usr/bin/resolvectl
root@myir:~# ls -l /usr/bin/resolvectl -rwxr-xr-x 1 root root 79316 Mar 9 2018 /usr/bin/resolvectl
resolv.conf 是 resolv-conf.systemd 的软连接
/sbin/resolvconf 是/usr/bin/resolvectl 软连接
4) 查看网络管理信息
root@myir:~# networkctl
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
2 can0 n/a off unmanaged
3 eth0 ether routable configured
4 wlan0 wlan off unmanaged
5 usb0 gadget no-carrier configured
5 links listed. lo 本地回环 没有在 systemd 上管理
eth0 以太网 已经在 systemd 上管理
wlan0 wifi 没有在 systemd 上管理
注意:如果是开发板是 STM32MP151 系列处理器则没有 can 网络。
5.2 检查 xx-xxx.network
Systemd-networkd 的设备写法为 xx-xxxx.network。 必须以 network 结尾,前
面遍历会以字典顺序执行。 可以将设备配置文件放置这几个目录 /etc/systemd/network/ ,
/run/systemd/network/ , /lib/systemd/network/. 优先级为 /etc/ > /run/ > /lib/ 。在 5.1 中已
经知道以太网被管理,这里直接从它的配置文件入手。 新建文件
/lib/systemd/network/50-wired.network
[Match]
Name=eth*
[Network]
DHCP=ipv4
[DHCP]
RouteMetric=15
CriticalConnection=true
Name=eth* 所有 eth 开头设备适配下面方案
HDCP=ipv4 自动获取 IP
RouteMetric 跃点数 15
跃点数 ip route 可以看到如下信息:
root@myir:/etc/ppp/peers# ip route
default via 192.168.30.1 dev eth0 proto dhcp src 192.168.30.103 metric 15
192.168.7.0/24 dev usb0 proto kernel scope link src 192.168.7.2 linkdown
192.168.30.0/24 dev eth0 proto kernel scope link src 192.168.30.103
192.168.30.1 dev eth0 proto dhcp scope link src 192.168.30.103 metric 15
Metric 15 路由跃点数 15
注:跃点数能够反映跃点的数量、路径的速度、路径可靠性、路径吞吐量以及管理属性,
Metric 的值越小,优先级越高。
5.3 开启 wifi 并检查网络现象
1) 使用 wpa_supplicant 命令连接 wifi。
root@myir:~# ifconfig wlan0 up
root@myir:~# wpa_passphrase SSID passwd >> /etc/wpa_supplicant.conf
root@myir:/# wpa_supplicant -B -iwlan0 -c /etc/wpa_supplicant.conf
Successfully initialized wpa_supplicant
root@myir:/# ls[ 8972.189374] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link b
ecomes ready
root@myir:/# udhcpc -i wlan0
udhcpc: started, v1.31.1
udhcpc: sending discover
udhcpc: sending discover
udhcpc: sending select for 192.168.43.185
udhcpc: lease of 192.168.43.185 obtained, lease time 3600
/etc/udhcpc.d/50default: Adding DNS 192.168.43.1
2) 查看 ip address 情况
root@myir:/# ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN gr
oup default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN group default qlen 10
link/can
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP g
roup default qlen 1000
link/ether e2:2d:77:f3:19:23 brd ff:ff:ff:ff:ff:ff
inet 192.168.30.102/24 brd 192.168.30.255 scope global dynamic eth0
valid_lft 7194sec preferred_lft 7194sec
inet6 fe80::e02d:77ff:fef3:1923/64 scope link
valid_lft forever preferred_lft forever
4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel stat
e UP group default qlen 1000
link/ether b0:02:47:59:f5:e5 brd ff:ff:ff:ff:ff:ff
inet 192.168.43.185/24 brd 192.168.43.255 scope global wlan0
valid_lft forever preferred_lft forever
inet6 2408:84f3:2c41:7bb:b202:47ff:fe59:f5e5/64 scope global dynamic mngtmp
addr
valid_lft 3388sec preferred_lft 3388sec
inet6 fe80::b202:47ff:fe59:f5e5/64 scope link
valid_lft forever preferred_lft forever
5: usb0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel sta
te DOWN group default qlen 1000
link/ether d6:b0:42:8d:a4:08 brd ff:ff:ff:ff:ff:ff
inet 192.168.7.2/24 brd 192.168.7.255 scope global usb0
valid_lft forever preferred_lft forever
eth0 ip 192.168.30.102
wlan0 ip 192.168.43.185
3) 再次查看 ip route 情况。
root@myir:/etc/ppp/peers# ip route
default via 192.168.30.1 dev eth0 proto dhcp src 192.168.30.103 metric 15
192.168.7.0/24 dev usb0 proto kernel scope link src 192.168.7.2 linkdown
192.168.30.0/24 dev eth0 proto kernel scope link src 192.168.30.103
192.168.30.1 dev eth0 proto dhcp scope link src 192.168.30.103 metric 15
192.168.43.0/24 dev wlan0 proto kernel scope link src 192.168.43.185
4) 查看 networkctl 情况。
root@myir:~# networkctl
IDXLINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
2 can0 can off unmanaged
3 eth0 ether routable configured
4 wlan0 wlan routable unmanaged
5 usb0 gadget no-carrier configuring
5 links listed. wlan 已经开启,但是没有被管理
5) 再次查看路由情况。
root@myir:/# cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit. #
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains. #
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way, # replace this symlink by a static file or a different symlink. #
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf. nameserver 192.168.1.1
nameserver 192.168.43.1
192.168.43.1 为 wlan0 新增
6) 根据以上情况,可以得出,访问外网时,只有 eth0 可以工作,wlan0 无法工作。
root@myir:~# ping www.baidu.com -I eth0
PING www.a.shifen.com (14.215.177.38) from 192.168.30.103 eth0: 56(84) bytes of
data. 64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=55 time=7.68 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=2 ttl=55 time=6.82 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=3 ttl=55 time=7.15 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=4 ttl=55 time=7.09 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=5 ttl=55 time=7.13 ms
^C
--- www.a.shifen.com ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 6.819/7.174/7.677/0.278 ms
wlan0 无法连接外网。
root@myir:~# ping www.baidu.com -I wlan0
PING www.a.shifen.com (14.215.177.38) from 192.168.43.185 wlan0: 56(84) bytes o
f data. 测试拔掉网线后情况。
root@myir:~# ip route
192.168.7.0/24 dev usb0 proto kernel scope link src 192.168.7.2 linkdown
192.168.43.0/24 dev wlan0 proto kernel scope link src 192.168.43.185
root@myir:~# networkctl
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
2 can0 can off unmanaged
3 eth0 ether no-carrier configured
4 wlan0 wlan routable unmanaged
5 usb0 gadget no-carrier configuring
5 links listed. root@myir:~# cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit. #
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains. #
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way, # replace this symlink by a static file or a different symlink. #
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf. nameserver 192.168.43.1
7) 根据以上的现象 unmanaged 与没有路由表。还是无法使用 wlan0 接口连通外网。
root@myir:~# ping www.baidu.com -I wlan0
PING www.a.shifen.com (163.177.151.110) from 192.168.43.185 wlan0: 56(84) byte
s of data. ^C
--- www.a.shifen.com ping statistics --- 5 packets transmitted, 0 received, 100% packet loss, time 4177ms
但当使用手动给 wlan0 增加一条路由表后如下。
root@myir:~# ip route add default via 192.168.43.1 dev wlan0
root@myir:~# ip route
default via 192.168.43.1 dev wlan0
192.168.7.0/24 dev usb0 proto kernel scope link src 192.168.7.2 linkdown
192.168.43.0/24 dev wlan0 proto kernel scope link src 192.168.43.185
此时 IP,路由,DNS 都有,那么就可以 ping 通外网
root@myir:~# ping www.baidu.com -I wlan0
PING www.a.shifen.com (163.177.151.109) from 192.168.43.185 wlan0: 56(84) byte
s of data. 64 bytes from 163.177.151.109 (163.177.151.109): icmp_seq=1 ttl=53 time=38.0 m
s
64 bytes from 163.177.151.109 (163.177.151.109): icmp_seq=2 ttl=53 time=127 m
s
^C
--- www.a.shifen.com ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 38.038/78.559/126.632/34.542 ms
所以到这里可以得到即使 wifi 联通还无法连通外网的原因,是需要对应的路由表。分
析了网络联通的过程,那就可以使用 systemd-networkd 来进行多网络管理。
5.4 systemd-networkd 增加 wlan0 管理
1) 在 /lib/systemd/network/中增加 79-wlan0.network 文件,并添加以下内容。
[Match]
Name=wlan0
[Network]
DHCP=yes
[DHCP]
RouteMetric=20
RouteMetric 20 跃点数 20 (小于 eth0 的 15)
重启 systemd-networkd 服务
root@myir:# systemctl restart systemd-networkd
查看 networkctl 状态
root@myir:/lib/systemd/network# networkctl
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier configured
2 can0 can off initialized
3 eth0 ether routable configured
4 wlan0 wlan routable configured
5 usb0 gadget no-carrier configuring
5 links listed. wlan0 现在变成 configured
接下来,重启下系统,可以观察到一个现象,就是 wifi 会自动打开,但是不会连接,
那是因为没有 wpa_supplicant 服务,需要手动开启。这样才会将要连接 wifi 的
SSID,PASSWD 和配置信息放置在/etc/wpa_supplicant.conf
手动开启 wpa_supplicant 服务
root@myir:~# wpa_supplicant -B -iwlan0 -c /etc/wpa_supplicant.conf
ip route 信息
root@myir:~# ip route
default via 192.168.30.1 dev eth0 proto dhcp src 192.168.30.103 metric 15
default via 192.168.43.1 dev wlan0 proto dhcp src 192.168.43.186 metric 20
192.168.7.0/24 dev usb0 proto kernel scope link src 192.168.7.2 linkdown
192.168.30.0/24 dev eth0 proto kernel scope link src 192.168.30.103
192.168.30.1 dev eth0 proto dhcp scope link src 192.168.30.103 metric 15
192.168.43.0/24 dev wlan0 proto kernel scope link src 192.168.43.186
192.168.43.1 dev wlan0 proto dhcp scope link src 192.168.43.186 metric 20
这里可以看到 2 个 default,前面一个是 eth0 跃点数 15,后面 wlan0,跃点数 20。
此时就是以太网优先,如果以太网断开,就走 WIFI 路由。测试 ping 百度不指定网
卡,中途拔掉以太网。
root@myir:~# ping www.baidu.com
PING www.a.shifen.com (163.177.151.110) 56(84) bytes of data. 64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=1 ttl=52 time=9.88 m
s
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=2 ttl=53 time=188 m
s
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=3 ttl=52 time=9.45 m
s
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=4 ttl=53 time=164 m
s
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=5 ttl=52 time=8.71 m
s
[ 190.316708] stm32-dwmac 5800a000.ethernet eth0: Link is Down
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=10 ttl=53 time=73.4
ms
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=11 ttl=53 time=71.6
ms
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=12 ttl=53 time=130
ms
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=13 ttl=53 time=68.8
ms
[ 190.316708] stm32-dwmac 5800a000.ethernet eth0: Link is Down 拔掉网线
打印信息
可以看到以太网,wifi 同时连接时,网络不会因为以太网中断而停止。这里还有一个
点,到底 ping 的时候走那个网卡,这里直接说明,会走 ip route 最前面的 default 路由,
由于 eth0 metric = 15 ,wifi metric=20,所以连接顺序无论怎么接,都是以太网在前。
5.5 wpa_supplicant 自动启动连接 wifi
上面章节虽然说明了 优先级情况,但是 wifi 需要手动启动,无法自动连接,这里介
绍如何开机启动 wpa_supplicant。
前面章节有连接 wifi 时需要执行 wpa_supplicant 命令。
wpa_supplicant -B -iwlan0 -c /etc/wpa_supplicant.conf
Wpa_supplicant 对应命令
-B 后台运行此程序
-i wlan0 指定网卡名称
-c /etc/wpa_supplicant.conf 指定配置文件
其中/etc/wpa_supplicnat.conf 是需要写入 SSID 与 passwd 的脚本
查看下使用 wpa_supplicant 服务的相关服务
root@myir:~# ls -l /lib/systemd/system/wpa_supplicant*
-rw-r--r-- 1 root root 453 Mar 9 2018 /lib/systemd/system/wpa_supplicant-nl802
11@.service
-rw-r--r-- 1 root root 447 Mar 9 2018 /lib/systemd/system/wpa_supplicant-wired
@.service
-rw-r--r-- 1 root root 245 Mar 9 2018 /lib/systemd/system/wpa_supplicant.servic
e
-rw-r--r-- 1 root root 415 Mar 9 2018 /lib/systemd/system/wpa_supplicant@.ser
vice
这里的 wpa_supplicnat@.service 是一个通配服务,试下执行命令
root@myir:~# systemctl enable wpa_supplicant@wlan0.service
Created symlink /etc/systemd/system/multi-user.target.wants/wpa_supplicant@wl
an0.service ->
/lib/systemd/system/wpa_supplicant@.service. 可以看到建立了一个开机启动服务的软连接到/etc/systemd/system/multi- user.target.wants/wpa_supplicant@wlan0.service
查看下自启动软连接信息。
root@myir:~# cat /etc/systemd/system/multi-user.target.wants/wpa_supplicant
@wlan0.service
[Unit]
Description=WPA supplicant daemon (interface-specific version)
Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
Before=network.target
Wants=network.target
# NetworkManager users will probably want the dbus version instead. [Service]
Type=simple
ExecStart=/usr/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.co
nf -i%I
[Install]
WantedBy=multi-user.target
ExecStart=/usr/sbin/wpa_supplicant
-c/etc/wpa_supplicant/wpa_supplicant-%I.conf -i%I 这里我们将上面的生成的文件放置在/etc/wpa_supplicant/wpa_supplicant- wlan0.conf 不就可以自动启动。 注意:MYD-YA15XC-T 的 wpa_supplicant.conf 在目录/etc 下。需要按照自启动的配置目
录,将 wpa_supplicant.conf 改成 wpa_supplicant-wlan0.conf 并拷贝到新建的目录下
/etc/wpa_supplicant. root@myir:/etc/wpa_supplicant# ls
wpa_supplicant-wlan0.conf
重启后可自动连接 wifi。
5.6 4G 模块配置
从以上章节对 wifi 的配置来看,可以很快添加 4G 模块的网络,步骤如下:
/lib/systemd/network/ 下添加 EC20 模块的设备,设置成自动获取 IP, metric。
手动/自动连接模块。
MYD-YA15XC-T 没有直接的 4G 模块的接口,需要通过 USB 转 miniPCIe 的转接板连
接 4G 模块。米尔默认移植的 4G 模块为移远 EC20;运营商测试为移动。
1) 启动自动拨号脚本 quectel-CM &
root@myir:/etc/ppp# ./quectel-CM &
root@myir:/etc/ppp# [02-07_15:53:06:002] Quectel_QConnectManager_Linux_V1. 5.5
[02-07_15:53:06:004] Find /sys/bus/usb/devices/2-1 idVendor=0x2c7c idProduct=
0x125
[02-07_15:53:06:005] Auto find qmichannel = /dev/cdc-wdm0
[02-07_15:53:06:005] Auto find usbnet_adapter = wwan0
[02-07_15:53:06:005] Modem works in QMI mode
[02-07_15:53:06:043] cdc_wdm_fd = 7
[02-07_15:53:06:144] Get clientWDS = 18
[02-07_15:53:06:178] Get clientDMS = 1
[02-07_15:53:06:210] Get clientNAS = 3
[02-07_15:53:06:241] Get clientUIM = 1
[02-07_15:53:06:275] Get clientWDA = 1
[02-07_15:53:06:306] requestBaseBandVersion EC20CEFDKGR06A04M2G
[02-07_15:53:06:434] requestGetSIMStatus SIMStatus: SIM_READY
[02-07_15:53:06:466] requestGetProfile[1] ctnet///0
[02-07_15:53:06:498] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE
[02-07_15:53:06:529] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTE
D
[02-07_15:53:06:529] ifconfig wwan0 down
[02-07_15:53:06:547] ifconfig wwan0 0.0.0.0
[02-07_15:53:06:594] requestSetupDataCall WdsConnectionIPv4Handle: 0xe18a5fc
0
[02-07_15:53:06:722] ifconfig wwan0 up
[02-07_15:53:06:755] busybox udhcpc -f -n -q -t 5 -i wwan0
udhcpc: started, v1.31.1
udhcpc: sending discover
udhcpc: sending select for 10.38.63.3
udhcpc: lease of 10.38.63.3 obtained, lease time 7200
RTNETLINK answers: File exists
[02-07_15:53:07:222] /etc/udhcpc.d/50default: Adding DNS 120.196.165.7
[02-07_15:53:07:222] /etc/udhcpc.d/50default: Adding DNS 221.179.38.7
2) 查看 networkctl 状态
LINK TYPE OPERATIONALSETUP
1 lo loopback carrier configured
2 can0 can off initialized
3 eth0 ether routable configured
4 wlan0 wlan routable configured
5 usb0 gadget no-carrier configuring
6 wwan0 wwan routable configured
6 links listed. 3) 再次重启,eth0 和 wlan0 自动连接,执行 4G 的拨号脚本让 EC20 拨号成功。
查看路由表:
root@myir:/etc/ppp# ip route
default via 10.75.115.24 dev wwan0 metric 10
default via 192.168.30.1 dev eth0 proto dhcp src 192.168.30.103 metric 15
default via 192.168.43.1 dev wlan0 proto dhcp src 192.168.43.185 metric 20
10.75.115.16/28 dev wwan0 proto kernel scope link src 10.75.115.23
192.168.7.0/24 dev usb0 proto kernel scope link src 192.168.7.2
192.168.30.0/24 dev eth0 proto kernel scope link src 192.168.30.103
192.168.30.1 dev eth0 proto dhcp scope link src 192.168.30.103 metric 15
192.168.43.0/24 dev wlan0 proto kernel scope link src 192.168.43.185
192.168.43.1 dev wlan0 proto dhcp scope link src 192.168.43.185 metric 20
4) Ping 外网的同时,下列做两组测试。
第一组,依此拔下 EC20 模块,拔下网线,关闭 wifi。
root@myir:/etc/ppp# ping www.baidu.com
PING www.a.shifen.com (163.177.151.110) 56(84) bytes of data. 64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=9 ttl=49 time=69.9 m
s
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=13 ttl=50 time=50.2
ms
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=14 ttl=50 time=55.2
ms
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=15 ttl=50 time=58.4
ms
[ 360.021410] usb 2-1: USB disconnect, device number 2
[ 360.025904] option1 ttyUSB0: GSM modem (1-port) converter now disconnecte
d from ttyUSB0
[ 360.034187] option 2-1:1.0: device disconnected
[ 360.039434] option1 ttyUSB1: GSM modem (1-port) converter now disconnecte
d from ttyUSB1
[ 360.046381] option 2-1:1.1: device disconnected
[ 360.059715] option1 ttyUSB2: GSM modem (1-port) converter now disconnecte
d from ttyUSB2
[ 360.066565] option 2-1:1.2: device disconnected
[ 360.094517] option1 ttyUSB3: GSM modem (1-port) converter now disconnecte
d from ttyUSB3
[ 360.114436] option 2-1:1.3: device disconnected
[ 360.127444] qmi_wwan_q 2-1:1.4 wwan0: unregister 'qmi_wwan_q' usb-5800d00
0.usbh-ehci-1, WWAN/QMI device
[02-07_15:56:39:842] QmiWwanThread poll err/hup/inval
[02-07_15:56:39:842] poll fd = 7, events = 0x0018
[02-07_15:56:39:842] QmiWwanThread exit
[02-07_15:56:39:845] ifconfig wwan0 down
ifconfig: SIOCGIFFLAGS: No such device
[02-07_15:56:39:957] ifconfig wwan0 0.0.0.0
ifconfig: SIOCSIFADDR: No such device
[02-07_15:56:40:053] qmi_main exit
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=17 ttl=52 time=10.0
ms
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=18 ttl=52 time=11.8
ms
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=19 ttl=52 time=10.7
ms
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=20 ttl=52 time=9.87
ms
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=28 ttl=52 time=9.82
ms
[ 373.447569] stm32-dwmac 5800a000.ethernet eth0: Link is Down
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=30 ttl=53 time=1573
ms
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=31 ttl=53 time=533
ms
64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=32 ttl=53 time=73.5
ms
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
^C
--- www.a.shifen.com ping statistics --- 39 packets transmitted, 37 received, 5.12821% packet loss, time 42301ms
rtt min/avg/max/mdev = 8.666/110.402/1572.819/261.269 ms, pipe 2
[1]+ Done ./quectel-CM
红色字体分别是拔下 4G 模块与拔下以太网的信息再断下 wifi(由于断 wifi 无消息显
示),打印消息上看,网络并没有断掉。
第二组,分别断掉 wifi, 以太网,4G 模块。
root@myir:/etc/ppp# ping www.baidu.com
PING www.a.shifen.com (183.232.231.174) 56(84) bytes of data. 64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=1 ttl=56 time=49.6 m
s
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=21 ttl=56 time=45.7
ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=22 ttl=56 time=48.8
ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=23 ttl=56 time=47.8
ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=24 ttl=56 time=47.7
ms
[ 248.247712] stm32-dwmac 5800a000.ethernet eth0: Link is Down
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=25 ttl=56 time=46.6
ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=29 ttl=56 time=134
ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=30 ttl=56 time=394
ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=31 ttl=56 time=88.2
ms
[ 255.315629] usb 2-1: USB disconnect, device number 2
[ 255.320113] option1 ttyUSB0: GSM modem (1-port) converter now disconnecte
d from ttyUSB0
[ 255.342216] option 2-1:1.0: device disconnected
[ 255.349262] option1 ttyUSB1: GSM modem (1-port) converter now disconnecte
d from ttyUSB1
[ 255.356317] option 2-1:1.1: device disconnected
[ 255.376938] option1 ttyUSB2: GSM modem (1-port) converter now disconnecte
d from ttyUSB2
[ 255.394263] option 2-1:1.2: device disconnected
[ 255.417228] option1 ttyUSB3: GSM modem (1-port) converter now disconnecte
d from ttyUSB3
[ 255.442233] option 2-1:1.3: device disconnected
[ 255.462782] qmi_wwan_q 2-1:1.4 wwan0: unregister 'qmi_wwan_q' usb-5800d00
0.usbh-ehci-1, WWAN/QMI device
[02-07_15:54:56:702] QmiWwanThread poll err/hup/inval
[02-07_15:54:56:702] poll fd = 7, events = 0x0018
[02-07_15:54:56:703] QmiWwanThread exit
[02-07_15:54:56:705] ifconfig wwan0 down
ifconfig: SIOCGIFFLAGS: No such device
[02-07_15:54:56:798] ifconfig wwan0 0.0.0.0
ifconfig: SIOCSIFADDR: No such device
[02-07_15:54:56:819] qmi_main exit
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
^C
--- www.a.shifen.com ping statistics --- 39 packets transmitted, 31 received, 20.5128% packet loss, time 38340ms
rtt min/avg/max/mdev = 37.010/65.549/393.764/63.096 ms
[1]+ Done ./quectel-CM
root@myir:/etc/ppp#
可以看到最后断下 4G 模块后才断掉网络。