0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

開發(fā)板開發(fā)筆記——網(wǎng)絡管理的詳細步驟說明

米爾MYIR ? 來源:米爾MYIR ? 作者:米爾MYIR ? 2022-03-04 10:50 ? 次閱讀

1.概述

systemd-networkd 是一個管理網(wǎng)絡服務程序,可以用來管理以太網(wǎng),WIFI,網(wǎng)橋,EC20 等模塊的網(wǎng)絡優(yōu)先級,以及連接情況。配合 systemd-resolved 服務一起使用。

本章主要目的是學習以太網(wǎng),wifi,EC20 模塊同時管理,并按指定優(yōu)先級收發(fā)數(shù)據(jù)。

2.硬件資源

? MYD-YA15XC-T 開發(fā)板

? WIFI 天線

? USB 轉接板

? 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)絡管理信息

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)絡。

5.2 檢查 xx-xxx.network

Systemd-networkd 的設備寫法為 xx-xxxx.network。 必須以 network 結尾,前面遍歷會以字典順序執(zhí)行。 可以將設備配置文件放置這幾個目錄 /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 開頭設備適配下面方案

? 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)絡現(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)的原因,是需要對應的路由表。分析了網(wǎng)絡聯(lián)通的過程,那就可以使用 systemd-networkd 來進行多網(wǎng)絡管理。

5.4 systemd-networkd 增加 wlan0 管理

1) 在 /lib/systemd/network/中增加 79-wlan0.network 文件,并添加以下內容。

[Match]

Name=wlan0

[Network]

DHCP=yes

[DHCP]

RouteMetric=20

?RouteMetric 20 躍點數(shù) 20 (小于 eth0 的 15)

? 重啟 systemd-networkd 服務

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 服務,需要手動開啟。這樣才會將要連接 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 躍點數(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)絡不會因為以太網(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 對應命令

? -B 后臺運行此程序

? -i wlan0 指定網(wǎng)卡名稱

? -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 是一個通配服務,試下執(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. 可以看到建立了一個開機啟動服務的軟連接到/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)絡,步驟如下:

?/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 狀態(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)線,關閉 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)絡并沒有斷掉。

? 第二組,分別斷掉 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)絡。

審核編輯:符乾江

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權轉載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
收藏 人收藏

    評論

    相關推薦

    全志T113-S3開發(fā)板網(wǎng)絡通信

    前言:在使用開發(fā)板的過程中經(jīng)常會使用到ssh、ftp等網(wǎng)絡服務,這時需要使用開發(fā)板網(wǎng)絡功能。因此新拿到的開發(fā)板要先進行
    的頭像 發(fā)表于 12-26 08:32 ?436次閱讀
    全志T113-S3<b class='flag-5'>開發(fā)板</b><b class='flag-5'>網(wǎng)絡</b>通信

    迅為RK3588開發(fā)板Android系統(tǒng)開發(fā)筆記-使用ADB工具

    工具在網(wǎng)盤資料“iTOP-3588 開發(fā)板\\\\02_【iTOP-RK3588 開發(fā)板開發(fā)資料\\\\ 07_Android 系統(tǒng)開發(fā)配套資料\\\\01_ADB 工具配套資料”
    發(fā)表于 11-27 10:39

    【迅為】瑞芯微RK3588開發(fā)板RK3568開發(fā)板區(qū)別及優(yōu)勢

    RK3568開發(fā)板
    的頭像 發(fā)表于 11-18 14:19 ?563次閱讀
    【迅為】瑞芯微RK3588<b class='flag-5'>開發(fā)板</b>RK3568<b class='flag-5'>開發(fā)板</b>區(qū)別及優(yōu)勢

    正點原子fpga開發(fā)板不同型號

    正點原子作為國內領先的FPGA開發(fā)板供應商,其產(chǎn)品線覆蓋了從入門級到高端應用的各個領域。這些開發(fā)板不僅適用于學術研究,還廣泛應用于工業(yè)控制、通信、圖像處理等多個領域。 1. 入門級開發(fā)板 1.1
    的頭像 發(fā)表于 11-13 09:30 ?1176次閱讀

    51開發(fā)板芯片資料

    51開發(fā)板芯片資料
    發(fā)表于 09-18 09:29 ?1次下載

    linux開發(fā)板與樹莓派的區(qū)別

    操作系統(tǒng)的微型計算機,主要用于教育、編程、媒體播放等領域。 硬件配置 Linux開發(fā)板:Linux開發(fā)板的硬件配置因廠商和型號而異,通常包括處理器、內存、存儲、網(wǎng)絡接口等。 樹莓派:樹莓派的硬件配置相對固定,包括處理器、內存、U
    的頭像 發(fā)表于 08-30 15:34 ?1124次閱讀

    linux開發(fā)板如何編譯curl

    在Linux開發(fā)板上編譯 curl 庫通常涉及到幾個步驟,包括準備開發(fā)環(huán)境、下載源代碼、配置編譯選項以及執(zhí)行編譯和安裝過程。以下是一個基本的指南,幫助你在Linux開發(fā)板上編譯 cur
    的頭像 發(fā)表于 08-30 15:33 ?767次閱讀

    linux開發(fā)板和單片機開發(fā)的區(qū)別

    硬件架構 Linux開發(fā)板和單片機開發(fā)在硬件架構上有很大的區(qū)別。Linux開發(fā)板通?;贏RM、x86或其他處理器架構,具有較高的處理能力和內存容量。而單片機開發(fā)則基于微控制器,如80
    的頭像 發(fā)表于 08-30 15:30 ?1138次閱讀

    合宙LuatOS開發(fā)板使用手冊——Air700EAQ

    本文詳細講解了Air700EAQ開發(fā)板的使用說明
    的頭像 發(fā)表于 08-28 14:37 ?575次閱讀
    合宙LuatOS<b class='flag-5'>開發(fā)板</b>使用手冊——Air700EAQ

    EVASH Ultra EEPROM 開發(fā)板使用說明書 簡介

    EVASH Ultra EEPROM 開發(fā)板使用說明書 簡介 歡迎使用EVASH Ultra EEPROM開發(fā)板使用說明書。本說明書將為
    的頭像 發(fā)表于 07-01 09:39 ?543次閱讀

    米爾基于NXP iMX.93開發(fā)板的M33處理器應用開發(fā)筆記

    資源MYD-LMX9X開發(fā)板(米爾基于NXPiMX.93開發(fā)板)3.軟件資源Windows7及以上版本軟件:IAREmbeddedWorkbench4.板載固件調試
    的頭像 發(fā)表于 06-29 08:01 ?1556次閱讀
    米爾基于NXP iMX.93<b class='flag-5'>開發(fā)板</b>的M33處理器應用<b class='flag-5'>開發(fā)筆記</b>

    迅為國產(chǎn)四核RK3562開發(fā)板底板硬件接口原理說明

    迅為國產(chǎn)四核RK3562開發(fā)板底板硬件接口原理說明
    的頭像 發(fā)表于 06-14 15:27 ?1829次閱讀
    迅為國產(chǎn)四核RK3562<b class='flag-5'>開發(fā)板</b>底板硬件接口原理<b class='flag-5'>說明</b>

    fpga開發(fā)板是什么?fpga開發(fā)板有哪些?

    FPGA開發(fā)板是一種基于FPGA(現(xiàn)場可編程門陣列)技術的開發(fā)平臺,它允許工程師通過編程來定義和配置FPGA芯片上的邏輯電路,以實現(xiàn)各種數(shù)字電路和邏輯功能。FPGA開發(fā)板通常包括FPGA芯片、時鐘模塊、電源模塊、輸入輸出接口等組
    的頭像 發(fā)表于 03-14 18:20 ?2166次閱讀

    fpga開發(fā)板使用教程

    FPGA開發(fā)板的使用教程主要包括以下幾個關鍵步驟。
    的頭像 發(fā)表于 03-14 15:50 ?1237次閱讀

    fpga開發(fā)板與linux開發(fā)板區(qū)別

    FPGA開發(fā)板與Linux開發(fā)板是兩種不同的硬件開發(fā)平臺,各自具有不同的特點和應用場景。在以下的文章中,我將詳細介紹FPGA開發(fā)板和Linu
    的頭像 發(fā)表于 02-01 17:09 ?2410次閱讀