蜂窝调制解调器 wwan0 接口的 DNS 失败

蜂窝调制解调器 wwan0 接口的 DNS 失败

我有一台 Raspberry Pi,运行最新的 Raspberry Pi 操作系统和 Linux 内核 6.6。

我有一台 Quectel EC25 调制解调器,带有一个活动 SIM 卡,可以成功连接到互联网。我可以通过这个 wwan0 接口 ping 8.8.8.8,但不能 ping google.com。我尝试在 resolv.conf 中设置名称服务器条目,但 DNS 似乎一直失败。我已禁用 NetworkManager 和 systemd-resolved 服务,以便它们不进行交互(运行时它们并没有改善 DNS 情况)。我尝试在网络命名空间内使用 wwan0 接口进行 nslookup 和 dig,它们立即成功。我不明白 dig/nslookup 如何工作,但不明白 ping。如何让 DNS 通过蜂窝调制解调器工作?

网络命名空间设置脚本:

root@raspberrypi:/home/pi/Desktop# cat create_and_enter_ns.sh
#!/bin/bash

MODEM_IF="wwan0"

ip netns add cellular
ip link set $MODEM_IF netns cellular
ip netns exec cellular bash

连接脚本从网络命名空间内部运行:

root@raspberrypi:/home/pi/Desktop# cat connect-cellular.sh
#!/bin/bash

MODEM_IF="wwan0"

echo "-------------------------------------------------------"
echo "*** Setting up cellular modem ..."

ip link set $MODEM_IF down
echo 'Y' | sudo tee /sys/class/net/wwan0/qmi/raw_ip
ip link set $MODEM_IF up
qmicli -p -d /dev/cdc-wdm0 --device-open-net='net-raw-ip|net-no-qos-header' --wds-start-network="apn='super',ip-type=4" --client-no-release-cid

echo "-------------------------------------------------------"
echo "*** Requesting IP Address for modem ..."

udhcpc -q -f -i wwan0

echo "-------------------------------------------------------"
echo "*** Displaying cellular connection details ..."

qmicli -d /dev/cdc-wdm0 --wds-get-current-settings

echo "-------------------------------------------------------"
echo "*** Setting nameservers in resolv.conf ..."

echo "nameserver 8.8.8.8" > /etc/resolv.conf
echo "nameserver 8.8.4.4" > /etc/resolv.conf

echo "-------------------------------------------------------"
echo "*** Displaying routes ..."

ip route
route

echo "-------------------------------------------------------"
echo "*** DNS Lookups ..."

nslookup google.com
dig google.com

echo "-------------------------------------------------------"
echo "*** Attempting pings ..."

echo "*** Pinging 8.8.8.8 ..."
ping -c 3 -W 3 8.8.8.8

echo "*** Pinging google.com ..."
ping -c 3 -W 3 google.com

echo "-------------------------------------------------------"
echo "*** Done ..."

连接脚本输出:

root@raspberrypi:/home/pi/Desktop# ./connect-cellular.sh
-------------------------------------------------------
*** Setting up cellular modem ...
Y
[/dev/cdc-wdm0] Network started
        Packet data handle: '2269105392'
[/dev/cdc-wdm0] Client ID not released:
        Service: 'wds'
            CID: '18'
-------------------------------------------------------
*** Requesting IP Address for modem ...
udhcpc: started, v1.35.0
Dropped protocol specifier '.udhcpc' from 'wwan0.udhcpc'. Using 'wwan0' (ifindex=3).
Failed to revert interface configuration: Unit dbus-org.freedesktop.resolve1.service not found.
udhcpc: broadcasting discover
udhcpc: broadcasting select for 100.75.157.67, server 100.75.157.68
udhcpc: lease of 100.75.157.67 obtained from 100.75.157.68, lease time 7200
Dropped protocol specifier '.udhcpc' from 'wwan0.udhcpc'. Using 'wwan0' (ifindex=3).
Failed to set DNS configuration: Unit dbus-org.freedesktop.resolve1.service not found.
-------------------------------------------------------
*** Displaying cellular connection details ...
[/dev/cdc-wdm0] Current settings retrieved:
           IP Family: IPv4
        IPv4 address: 100.75.157.67
    IPv4 subnet mask: 255.255.255.248
IPv4 gateway address: 100.75.157.68
    IPv4 primary DNS: 8.8.4.4
  IPv4 secondary DNS: 8.8.8.8
                 MTU: 1360
             Domains: none
-------------------------------------------------------
*** Setting nameservers in resolv.conf ...
-------------------------------------------------------
*** Displaying routes ...
default via 100.75.157.68 dev wwan0
100.75.157.64/29 dev wwan0 proto kernel scope link src 100.75.157.67
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         100.75.157.68   0.0.0.0         UG    0      0        0 wwan0
100.75.157.64   0.0.0.0         255.255.255.248 U     0      0        0 wwan0
-------------------------------------------------------
*** DNS Lookups ...
Server:         8.8.4.4
Address:        8.8.4.4#53

Non-authoritative answer:
Name:   google.com
Address: 142.251.163.139
Name:   google.com
Address: 142.251.163.101
Name:   google.com
Address: 142.251.163.138
Name:   google.com
Address: 142.251.163.102
Name:   google.com
Address: 142.251.163.113
Name:   google.com
Address: 142.251.163.100
Name:   google.com
Address: 2607:f8b0:4004:c1b::8b
Name:   google.com
Address: 2607:f8b0:4004:c1b::8a
Name:   google.com
Address: 2607:f8b0:4004:c1b::64
Name:   google.com
Address: 2607:f8b0:4004:c1b::71


; <<>> DiG 9.18.24-1-Debian <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7473
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;google.com.                    IN      A

;; ANSWER SECTION:
google.com.             15      IN      A       142.251.163.100
google.com.             15      IN      A       142.251.163.101
google.com.             15      IN      A       142.251.163.138
google.com.             15      IN      A       142.251.163.139
google.com.             15      IN      A       142.251.163.102
google.com.             15      IN      A       142.251.163.113

;; Query time: 132 msec
;; SERVER: 8.8.4.4#53(8.8.4.4) (UDP)
;; WHEN: Fri Apr 05 02:36:11 BST 2024
;; MSG SIZE  rcvd: 135

-------------------------------------------------------
*** Attempting pings ...
*** Pinging 8.8.8.8 ...
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=115 time=145 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=115 time=183 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=115 time=142 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 142.221/156.747/183.145/18.697 ms
*** Pinging google.com ...
PING google.com (142.251.163.139) 56(84) bytes of data.

--- google.com ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2056ms

-------------------------------------------------------
*** Done ...

更新:

事实上,DNS 似乎可以正常解析各种域名,但我永远无法通过 wwan0 ping 通它们。

root@raspberrypi:/home/pi/Desktop# dig stackoverflow.com

; <<>> DiG 9.18.24-1-Debian <<>> stackoverflow.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3647
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;stackoverflow.com.             IN      A

;; ANSWER SECTION:
stackoverflow.com.      300     IN      A       104.18.32.7
stackoverflow.com.      300     IN      A       172.64.155.249

;; Query time: 168 msec
;; SERVER: 8.8.8.8#53(8.8.8.8) (UDP)
;; WHEN: Fri Apr 05 14:05:58 BST 2024
;; MSG SIZE  rcvd: 78

root@raspberrypi:/home/pi/Desktop# ping 104.18.32.7
PING 104.18.32.7 (104.18.32.7) 56(84) bytes of data.
^C
--- 104.18.32.7 ping statistics ---
6 packets transmitted, 0 received, 100% packet loss, time 5098ms

我似乎也无法 ping 1.1.1.1(Cloudflare 公共 DNS):

root@raspberrypi:/home/pi/Desktop# ping -W 3 -c 1 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=115 time=294 ms

--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 294.368/294.368/294.368/0.000 ms
root@raspberrypi:/home/pi/Desktop# ping -W 3 -c 1 8.8.4.4
PING 8.8.4.4 (8.8.4.4) 56(84) bytes of data.
64 bytes from 8.8.4.4: icmp_seq=1 ttl=57 time=181 ms

--- 8.8.4.4 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 181.163/181.163/181.163/0.000 ms
root@raspberrypi:/home/pi/Desktop# ping -W 3 -c 1 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.

--- 1.1.1.1 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

root@raspberrypi:/home/pi/Desktop#

以下是跟踪路由的结果:

root@raspberrypi:/home/pi/Desktop# traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
 1  * * *
 2  * * *
 3  * * *
 4  * * *
 5  * * *
 6  * * *
 7  * * *
 8  * * dns.google (8.8.8.8)  571.410 ms
root@raspberrypi:/home/pi/Desktop# traceroute google.com
traceroute to google.com (142.251.163.100), 30 hops max, 60 byte packets
 1  * * *
 2  * * *
 3  * * *
 4  * * *
 5  * * *
 6  * * *
 7  * * *
 8  * * *
 9  * * *
10  * * *
11  * * *
12  * * *
13  * * *
14  * * *
15  * * *
16  * * *
17  * * *
18  * * *
19  * * *
20  * * *
21  * * *
22  * * *
23  * * *
24  * * *
25  * * *
26  * * *
27  * * *
28  * * *
29  * * *
30  * * *
root@raspberrypi:/home/pi/Desktop# traceroute -n google.com
traceroute to google.com (142.251.163.101), 30 hops max, 60 byte packets
 1  * * *
 2  * * *
 3  * * *
 4  * * *
 5  * * *
 6  * * *
 7  * * *
 8  * * *
 9  * * *
10  * * *
11  * * *
12  * * *
13  * * *
14  * * *
15  * * *
16  * * *
17  * * *
18  * * *
19  * * *
20  * * *
21  * * *
22  * * *
23  * * *
24  * * *
25  * * *
26  * * *
27  * * *
28  * * *
29  * * *
30  * * *
root@raspberrypi:/home/pi/Desktop#

更新 2:

我尝试了另一块主板,它带有 PCIe Quectel EC25 调制解调器,可以通过该接口 ping 通谷歌。我仔细检查了那块主板和 Sixfab 主板之间的所有我能想到的东西 - 并没有发现任何错误。但 Sixfab 主板无法 ping 通谷歌(请参阅下面的输出,作为两者之间路由和其他所有内容的比较)。

这可能是与实际 Linux 配置无关的服务级 DNS 问题吗?

其他工作板:

root@iot-gate-imx8plus:~# qmicli -d /dev/cdc-wdm0 --wds-get-current-settings
[/dev/cdc-wdm0] Current settings retrieved:
           IP Family: IPv4
        IPv4 address: 10.204.79.165
    IPv4 subnet mask: 255.255.255.252
IPv4 gateway address: 10.204.79.166
    IPv4 primary DNS: 8.8.8.8
  IPv4 secondary DNS: 8.8.4.4
                 MTU: 1500
             Domains: none
root@iot-gate-imx8plus:~#
root@iot-gate-imx8plus:~# ifconfig wwan0
wwan0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet 10.204.79.165  netmask 255.255.255.252  destination 10.204.79.165
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
        RX packets 1538  bytes 197923 (193.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1374  bytes 171063 (167.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@iot-gate-imx8plus:~# ip route
default via 10.204.79.166 dev wwan0 metric 10
10.2.0.0/16 dev wg0 scope link
10.204.79.164/30 dev wwan0 proto kernel scope link src 10.204.79.165
root@iot-gate-imx8plus:~#
root@iot-gate-imx8plus:~# ping google.com
PING google.com (142.250.180.14) 56(84) bytes of data.
64 bytes from lhr25s32-in-f14.1e100.net (142.250.180.14): icmp_seq=1 ttl=112 time=236 ms
64 bytes from lhr25s32-in-f14.1e100.net (142.250.180.14): icmp_seq=2 ttl=112 time=275 ms
64 bytes from lhr25s32-in-f14.1e100.net (142.250.180.14): icmp_seq=3 ttl=112 time=243 ms
64 bytes from lhr25s32-in-f14.1e100.net (142.250.180.14): icmp_seq=4 ttl=112 time=274 ms
^C
--- google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 236.348/257.205/275.411/17.489 ms
root@iot-gate-imx8plus:~# cat /etc/resolv.conf
# This is /run/systemd/resolve/resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# 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 should typically 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 8.8.8.8
nameserver 8.8.4.4
search .

Sixfab HAT 失败 DNS:

root@raspberrypi:/home/pi/Desktop# qmicli -d /dev/cdc-wdm0 --wds-get-current-settings
[/dev/cdc-wdm0] Current settings retrieved:
           IP Family: IPv4
        IPv4 address: 100.75.157.67
    IPv4 subnet mask: 255.255.255.248
IPv4 gateway address: 100.75.157.68
    IPv4 primary DNS: 8.8.4.4
  IPv4 secondary DNS: 8.8.8.8
                 MTU: 1360
             Domains: none
root@raspberrypi:/home/pi/Desktop#
root@raspberrypi:/home/pi/Desktop# ifconfig wwan0
wwan0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1360
        inet 100.75.157.67  netmask 255.255.255.248  destination 100.75.157.67
        inet6 fe80::b750:b71f:6494:4e58  prefixlen 64  scopeid 0x20<link>
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
        RX packets 153  bytes 16644 (16.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 47348  bytes 8168507 (7.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@raspberrypi:/home/pi/Desktop#
root@raspberrypi:/home/pi/Desktop# ip route
default via 100.75.157.68 dev wwan0 metric 10
100.75.157.64/29 dev wwan0 proto kernel scope link src 100.75.157.67
root@raspberrypi:/home/pi/Desktop#
root@raspberrypi:/home/pi/Desktop# ping -I wwan0 -W 3 -C 3 google.com
PING google.com (142.251.163.100) from 100.75.157.67 wwan0: 56(124) bytes of data.
^C
--- google.com ping statistics ---
19 packets transmitted, 0 received, 100% packet loss, time 18431ms

root@raspberrypi:/home/pi/Desktop#
root@raspberrypi:/home/pi/Desktop# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=115 time=118 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=115 time=116 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=115 time=115 ms
^C
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 115.051/116.219/117.650/1.077 ms
root@raspberrypi:/home/pi/Desktop# cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
search .
root@raspberrypi:/home/pi/Desktop#

更新 3:

我安装了 tshark,然后监控 wwan0,同时尝试在另一个终端中 ping google。有趣的是,接口上收到了 DNS 响应,但 ping 从未得到响应。

root@raspberrypi:/home/pi/Desktop# tshark -i wwan0
Running as user "root" and group "root". This could be dangerous.
Capturing on 'wwan0'
 ** (tshark:456216) 20:56:56.160995 [Main MESSAGE] -- Capture started.
 ** (tshark:456216) 20:56:56.161146 [Main MESSAGE] -- File: "/tmp/wireshark_wwan05F4ZL2.pcapng"
    1 0.000000000 100.75.157.67 → 8.8.8.8      DNS 56 Standard query 0x4501 A google.com
    2 0.000025703 100.75.157.67 → 8.8.8.8      DNS 56 Standard query 0x6c0c AAAA google.com
    3 0.287190564      8.8.8.8 → 100.75.157.67 DNS 168 Standard query response 0x6c0c AAAA google.com AAAA 2607:f8b0:4004:c1b::8b AAAA 2607:f8b0:4004:c1b::71 AAAA 2607:f8b0:4004:c1b::66 AAAA 2607:f8b0:4004:c1b::8a
    4 0.287191675      8.8.8.8 → 100.75.157.67 DNS 152 Standard query response 0x4501 A google.com A 142.251.163.138 A 142.251.163.102 A 142.251.163.101 A 142.251.163.100 A 142.251.163.113 A 142.251.163.139
    5 0.287529002 100.75.157.67 → 142.251.163.138 ICMP 84 Echo (ping) request  id=0xb5fb, seq=1/256, ttl=64

相关内容