无法使用 4G USB 调制解调器和 netplan 将 ubuntu 服务器 22.04 连接到 RaspberryPi 3B+ 上的互联网

无法使用 4G USB 调制解调器和 netplan 将 ubuntu 服务器 22.04 连接到 RaspberryPi 3B+ 上的互联网

我正在尝试使用 4G USB 调制解调器和 netplan 将 ubuntu 服务器 22.04 连接到 RaspberryPi 3B+ 上的互联网。

USB 加密狗似乎已被识别:

carlo@pi-box:~$ lsusb
Bus 001 Device 008: ID 19d2:0016 ZTE WCDMA Technologies MSM ZTE Mobile Broadband

carlo@pi-box:~$ sudo dmesg | grep usb
[  423.387073] usb 1-1.3: new high-speed USB device number 10 using dwc2
[  423.497368] usb 1-1.3: New USB device found, idVendor=19d2, idProduct=0016, bcdDevice=54.24
[  423.497428] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  423.497452] usb 1-1.3: Product: ZTE Mobile Broadband
[  423.497474] usb 1-1.3: Manufacturer: ZTE,Incorporated
[  423.500645] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB0
[  423.502143] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB1
[  423.503982] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB2

netplan 配置是:

network:
    renderer: NetworkManager
    ethernets:
        eth0:
            dhcp4: true
            optional: true
        usb0:
            dhcp4: true
            optional: true
    modems:
      ttyUSB2:
        apn: mobile.vodafone.it
        dhcp4: true
        auto-config: true
    version: 2

使用该ifconfig -a命令我找不到任何界面。

调制解调器管理器似乎识别了该调制解调器:

carlo@pi-box:~$ mmcli -L
    /org/freedesktop/ModemManager1/Modem/1 [ZTE CORPORATION] MF833V

carlo@pi-box:~$ mmcli -m 1
  --------------------------------
  General  |                 path: /org/freedesktop/ModemManager1/Modem/1
           |            device id: c22dd449a679d1e0ad941d57c707e8fbabaf3ee4
  --------------------------------
  Hardware |         manufacturer: ZTE CORPORATION
           |                model: MF833V
           |    firmware revision: BD_CNGENMF833VV1.0.0B08
           |            supported: gsm-umts, lte
           |              current: gsm-umts, lte
           |         equipment id: 860493042386496
  --------------------------------
  System   |               device: /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3
           |              drivers: option
           |               plugin: zte
           |         primary port: ttyUSB2
           |                ports: ttyUSB0 (qcdm), ttyUSB1 (at), ttyUSB2 (at)
  --------------------------------
  Status   |       unlock retries: sim-pin (3), sim-puk (10)
           |                state: registered
           |          power state: on
           |          access tech: umts
           |       signal quality: 41% (recent)
  --------------------------------
  Modes    |            supported: allowed: 2g; preferred: none
           |                       allowed: 3g; preferred: none
           |                       allowed: 4g; preferred: none
           |                       allowed: 2g, 3g, 4g; preferred: none
           |              current: allowed: any; preferred: none
  --------------------------------
  IP       |            supported: ipv4, ipv6, ipv4v6
  --------------------------------
  3GPP     |                 imei: 860493042386496
           |          operator id: 22288
           |        operator name: 0046003 0046003
           |         registration: home
           | packet service state: attached
  --------------------------------
  3GPP EPS | ue mode of operation: csps-1
  --------------------------------
  SIM      |     primary sim path: /org/freedesktop/ModemManager1/SIM/1

网络管理器显示设备和连接:

carlo@pi-box:~$ nmcli

ttyUSB2: disconnected
        "ZTE Mobile Broadband"
        1 connection available
        gsm (option), hw

carlo@pi-box:~$ nmcli c

NAME                      UUID                                  TYPE      DEVICE
netplan-ttyUSB2           5b6fbb52-0291-359e-aa68-b49f69ba9ff2  gsm       --

如果我强制连接调制解调器,它似乎是成功的:

carlo@pi-box:~$ sudo mmcli -m 1 --simple-connect="apn=apn.fastweb.it"
successfully connected the modem

carlo@pi-box:~$ mmcli -m 1
  --------------------------------
  General  |                 path: /org/freedesktop/ModemManager1/Modem/1
           |            device id: c22dd449a679d1e0ad941d57c707e8fbabaf3ee4
  --------------------------------
  Hardware |         manufacturer: ZTE CORPORATION
           |                model: MF833V
           |    firmware revision: BD_CNGENMF833VV1.0.0B08
           |            supported: gsm-umts, lte
           |              current: gsm-umts, lte
           |         equipment id: 860493042386496
  --------------------------------
  System   |               device: /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3
           |              drivers: option
           |               plugin: zte
           |         primary port: ttyUSB2
           |                ports: ttyUSB0 (qcdm), ttyUSB1 (at), ttyUSB2 (at)
  --------------------------------
  Status   |       unlock retries: sim-pin (3), sim-puk (10)
           |                state: connected
           |          power state: on
           |          access tech: umts
           |       signal quality: 38% (recent)
  --------------------------------
  Modes    |            supported: allowed: 2g; preferred: none
           |                       allowed: 3g; preferred: none
           |                       allowed: 4g; preferred: none
           |                       allowed: 2g, 3g, 4g; preferred: none
           |              current: allowed: any; preferred: none
  --------------------------------
  IP       |            supported: ipv4, ipv6, ipv4v6
  --------------------------------
  3GPP     |                 imei: 860493042386496
           |          operator id: 22288
           |        operator name: 0046003 0046003
           |         registration: home
           | packet service state: attached
  --------------------------------
  3GPP EPS | ue mode of operation: csps-1
  --------------------------------
  SIM      |     primary sim path: /org/freedesktop/ModemManager1/SIM/1
  --------------------------------
  Bearer   |                paths: /org/freedesktop/ModemManager1/Bearer/0
carlo@pi-box:~$ mmcli -b 0
  ---------------------------------
  General            |        path: /org/freedesktop/ModemManager1/Bearer/0
                     |        type: default
  ---------------------------------
  Status             |   connected: yes
                     |   suspended: no
                     | multiplexed: no
                     |   interface: ttyUSB2
                     |  ip timeout: 20
                     |  profile id: 2
  ---------------------------------
  Properties         |         apn: apn.fastweb.it
                     |     roaming: allowed
  ---------------------------------
  IPv4 configuration |      method: ppp
                     |      prefix: 0
  ---------------------------------
  Statistics         |  start date: 2024-03-05T21:26:00Z
                     |    attempts: 1

但是用ifconfig -a命令我仍然找不到任何相关的接口。

如果我尝试连接,它会在 APN 上发出错误信号:

carlo@pi-box:~$ sudo nmcli c up netplan-ttyUSB2
Error: Connection activation failed: Failed to select the specified APN
Hint: use 'journalctl -xe NM_CONNECTION=5b6fbb52-0291-359e-aa68-b49f69ba9ff2 + NM_DEVICE=ttyUSB2' to get more details.

连接属性包括:

carlo@pi-box:~$ sudo nmcli c show netplan-ttyUSB2
connection.id:                          netplan-ttyUSB2
connection.uuid:                        5b6fbb52-0291-359e-aa68-b49f69ba9ff2
connection.stable-id:                   --
connection.type:                        gsm
connection.interface-name:              ttyUSB2
connection.autoconnect:                 yes
connection.autoconnect-priority:        0
connection.autoconnect-retries:         -1 (default)
connection.multi-connect:               0 (default)
connection.auth-retries:                -1
connection.timestamp:                   0
connection.read-only:                   no
connection.permissions:                 --
connection.zone:                        --
connection.master:                      --
connection.slave-type:                  --
connection.autoconnect-slaves:          -1 (default)
connection.secondaries:                 --
connection.gateway-ping-timeout:        0
connection.metered:                     unknown
connection.lldp:                        default
connection.mdns:                        -1 (default)
connection.llmnr:                       -1 (default)
connection.dns-over-tls:                -1 (default)
connection.wait-device-timeout:         -1
ipv4.method:                            auto
ipv4.dns:                               --
ipv4.dns-search:                        --
ipv4.dns-options:                       --
ipv4.dns-priority:                      0
ipv4.addresses:                         --
ipv4.gateway:                           --
ipv4.routes:                            --
ipv4.route-metric:                      -1
ipv4.route-table:                       0 (unspec)
ipv4.routing-rules:                     --
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-iaid:                         --
ipv4.dhcp-timeout:                      0 (default)
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     --
ipv4.dhcp-fqdn:                         --
ipv4.dhcp-hostname-flags:               0x0 (none)
ipv4.never-default:                     no
ipv4.may-fail:                          yes
ipv4.required-timeout:                  -1 (default)
ipv4.dad-timeout:                       -1 (default)
ipv4.dhcp-vendor-class-identifier:      --
ipv4.dhcp-reject-servers:               --
ipv6.method:                            ignore
ipv6.dns:                               --
ipv6.dns-search:                        --
ipv6.dns-options:                       --
ipv6.dns-priority:                      0
ipv6.addresses:                         --
ipv6.gateway:                           --
ipv6.routes:                            --
ipv6.route-metric:                      -1
ipv6.route-table:                       0 (unspec)
ipv6.routing-rules:                     --
ipv6.ignore-auto-routes:                no
ipv6.ignore-auto-dns:                   no
ipv6.never-default:                     no
ipv6.may-fail:                          yes
ipv6.required-timeout:                  -1 (default)
ipv6.ip6-privacy:                       -1 (unknown)
ipv6.addr-gen-mode:                     eui64
ipv6.ra-timeout:                        0 (default)
ipv6.dhcp-duid:                         --
ipv6.dhcp-iaid:                         --
ipv6.dhcp-timeout:                      0 (default)
ipv6.dhcp-send-hostname:                yes
ipv6.dhcp-hostname:                     --
ipv6.dhcp-hostname-flags:               0x0 (none)
ipv6.token:                             --
gsm.auto-config:                        yes
gsm.number:                             --
gsm.username:                           --
gsm.password:                           <hidden>
gsm.password-flags:                     0 (none)
gsm.apn:                                --
gsm.network-id:                         --
gsm.pin:                                <hidden>
gsm.pin-flags:                          0 (none)
gsm.home-only:                          no
gsm.device-id:                          --
gsm.sim-id:                             --
gsm.sim-operator-id:                    --
gsm.mtu:                                auto
proxy.method:                           none
proxy.browser-only:                     no
proxy.pac-url:                          --
proxy.pac-script:                       --

我做错了什么?有人有这种设置的经验吗?

答案1

我找到了问题所在。我分享了我的经验,也许这对其他人有帮助。我通过在连接上强制使用 APN 解决了​​ APN 问题(仅在 netplan yaml 文件中指定它是不够的):

nmcli c modify netplan-ttyUSB2 gsm.apn mobile.vodafone.it

并且我在 netplan yaml 文件中强制将自动配置设置为 false。之后,当我尝试连接时,我收到了另一个错误:

PPP service disconnected

我在标准 amd64 PC 上安装了 ubuntu server 22.04 测试了相同的用例,一切正常。当我连接 ( sudo nmcli c up netplan-ttyUSB2) 时,PC 上会创建一个带有 IP 地址的 ppp0 接口。查看后,我发现 raspberrypi 上缺少一些 linux 模块,因此我安装了它们:

sudo apt install linux-modules-extra-raspi

之后一切都像在 PC 上一样顺利运行。

相关内容