1.概述
systemd-networkd 是一個管理網(wǎng)絡(luò)服務(wù)程序,可以用來管理以太網(wǎng),WIFI,網(wǎng)橋,EC20 等模塊的網(wǎng)絡(luò)優(yōu)先級,以及連接情況。配合 systemd-resolved 服務(wù)一起使用。
本章主要目的是學習以太網(wǎng),wifi,EC20 模塊同時管理,并按指定優(yōu)先級收發(fā)數(shù)據(jù)。
2.硬件資源
? MYD-YA15XC-T 開發(fā)板
? WIFI 天線
? USB 轉(zhuǎn)接板
? EC20 模塊
? 網(wǎng)線
? 路由器
3. 軟件資源
? Linux kernel 5.4.31
? systemd-networkd
? systemd-resolved
4.環(huán)境準備
將 MYD-YA15XC-T 燒入鏡像,wifi 天線連接 WIFI, EC20 模塊接入 USB 口,接入網(wǎng)線,路由器配置 wifi 熱點,并連接外網(wǎng)。
5.操作步驟
5.1.檢查環(huán)境
1) 檢查 systemd-networkd 運行狀態(tài)。
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 運行狀態(tài)。
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) 查看網(wǎng)絡(luò)管理信息
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 本地回環(huán) 沒有在 systemd 上管理
?eth0 以太網(wǎng) 已經(jīng)在 systemd 上管理
?wlan0 wifi 沒有在 systemd 上管理
注意:如果是開發(fā)板是 STM32MP151 系列處理器則沒有 can 網(wǎng)絡(luò)。
5.2 檢查 xx-xxx.network
Systemd-networkd 的設(shè)備寫法為 xx-xxxx.network。 必須以 network 結(jié)尾,前面遍歷會以字典順序執(zhí)行。 可以將設(shè)備配置文件放置這幾個目錄 /etc/systemd/network/ ,/run/systemd/network/ , /lib/systemd/network/. 優(yōu)先級為 /etc/ > /run/ > /lib/ 。在 5.1 中已經(jīng)知道以太網(wǎng)被管理,這里直接從它的配置文件入手。 新建文件
/lib/systemd/network/50-wired.network
[Match]
Name=eth*
[Network]
DHCP=ipv4
[DHCP]
RouteMetric=15
CriticalConnection=true
?Name=eth* 所有 eth 開頭設(shè)備適配下面方案
? HDCP=ipv4 自動獲取 IP
? RouteMetric 躍點數(shù) 15
躍點數(shù) 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 路由躍點數(shù) 15
注:躍點數(shù)能夠反映躍點的數(shù)量、路徑的速度、路徑可靠性、路徑吞吐量以及管理屬性,Metric 的值越小,優(yōu)先級越高。
5.3 開啟 wifi 并檢查網(wǎng)絡(luò)現(xiàn)象
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: mtu 65536 qdisc noqueue state UNKNOWN gr,up,lower_up>
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: mtu 16 qdisc noop state DOWN group default qlen 10,echo>
link/can
3: eth0: mtu 1500 qdisc mq state UP g,multicast,up,lower_up>
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: mtu 1500 qdisc fq_codel stat,multicast,up,lower_up>
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: mtu 1500 qdisc fq_codel sta,broadcast,multicast,up>
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 已經(jīng)開啟,但是沒有被管理
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) 根據(jù)以上情況,可以得出,訪問外網(wǎng)時,只有 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 無法連接外網(wǎng)。
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. ? 測試拔掉網(wǎng)線后情況。
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) 根據(jù)以上的現(xiàn)象 unmanaged 與沒有路由表。還是無法使用 wlan0 接口連通外網(wǎng)。
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 通外網(wǎng)
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 聯(lián)通還無法連通外網(wǎng)的原因,是需要對應(yīng)的路由表。分析了網(wǎng)絡(luò)聯(lián)通的過程,那就可以使用 systemd-networkd 來進行多網(wǎng)絡(luò)管理。
5.4 systemd-networkd 增加 wlan0 管理
1) 在 /lib/systemd/network/中增加 79-wlan0.network 文件,并添加以下內(nèi)容。
[Match]
Name=wlan0
[Network]
DHCP=yes
[DHCP]
RouteMetric=20
?RouteMetric 20 躍點數(shù) 20 (小于 eth0 的 15)
? 重啟 systemd-networkd 服務(wù)
root@myir:# systemctl restart systemd-networkd
? 查看 networkctl 狀態(tài)
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 現(xiàn)在變成 configured
接下來,重啟下系統(tǒng),可以觀察到一個現(xiàn)象,就是 wifi 會自動打開,但是不會連接,那是因為沒有 wpa_supplicant 服務(wù),需要手動開啟。這樣才會將要連接 wifi 的SSID,PASSWD 和配置信息放置在/etc/wpa_supplicant.conf
手動開啟 wpa_supplicant 服務(wù)
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 躍點數(shù) 15,后面 wlan0,躍點數(shù) 20。
此時就是以太網(wǎng)優(yōu)先,如果以太網(wǎng)斷開,就走 WIFI 路由。測試 ping 百度不指定網(wǎng)
卡,中途拔掉以太網(wǎng)。
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 拔掉網(wǎng)線
打印信息
可以看到以太網(wǎng),wifi 同時連接時,網(wǎng)絡(luò)不會因為以太網(wǎng)中斷而停止。這里還有一個點,到底 ping 的時候走那個網(wǎng)卡,這里直接說明,會走 ip route 最前面的 default 路由,由于 eth0 metric = 15 ,wifi metric=20,所以連接順序無論怎么接,都是以太網(wǎng)在前。
5.5 wpa_supplicant 自動啟動連接 wifi
上面章節(jié)雖然說明了 優(yōu)先級情況,但是 wifi 需要手動啟動,無法自動連接,這里介紹如何開機啟動 wpa_supplicant。
前面章節(jié)有連接 wifi 時需要執(zhí)行 wpa_supplicant 命令。
wpa_supplicant -B -iwlan0 -c /etc/wpa_supplicant.conf
? Wpa_supplicant 對應(yīng)命令
? -B 后臺運行此程序
? -i wlan0 指定網(wǎng)卡名稱
? -c /etc/wpa_supplicant.conf 指定配置文件
其中/etc/wpa_supplicnat.conf 是需要寫入 SSID 與 passwd 的腳本
查看下使用 wpa_supplicant 服務(wù)的相關(guān)服務(wù)
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 是一個通配服務(wù),試下執(zhí)行命令
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. 可以看到建立了一個開機啟動服務(wù)的軟連接到/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 模塊配置
從以上章節(jié)對 wifi 的配置來看,可以很快添加 4G 模塊的網(wǎng)絡(luò),步驟如下:
?/lib/systemd/network/ 下添加 EC20 模塊的設(shè)備,設(shè)置成自動獲取 IP, metric。
?手動/自動連接模塊。
MYD-YA15XC-T 沒有直接的 4G 模塊的接口,需要通過 USB 轉(zhuǎn) miniPCIe 的轉(zhuǎn)接板連接 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 狀態(tài)
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 自動連接,執(zhí)行 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 外網(wǎng)的同時,下列做兩組測試。
? 第一組,依此拔下 EC20 模塊,拔下網(wǎng)線,關(guān)閉 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 模塊與拔下以太網(wǎng)的信息再斷下 wifi(由于斷 wifi 無消息顯示),打印消息上看,網(wǎng)絡(luò)并沒有斷掉。
? 第二組,分別斷掉 wifi, 以太網(wǎng),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 模塊后才斷掉網(wǎng)絡(luò)。
審核編輯:符乾江
-
網(wǎng)絡(luò)管理
+關(guān)注
關(guān)注
0文章
118瀏覽量
27637 -
開發(fā)板
+關(guān)注
關(guān)注
25文章
4896瀏覽量
97059
發(fā)布評論請先 登錄
相關(guān)推薦
評論