在openwrt上使用RM500Q-GL模块

在Newifi D2上使用RM500Q-GL模块刷入openwrt连接数据网络

Posted by 浅唱 on August 7, 2025

前言

之前的系统用的 RM500Q-GL 模块经常频繁断网,忍受不了重刷纯净系统尝试下是否可以解决问题,但好像不行 似乎是供电不足或者接触不良 大流量传输一会儿就会断连 猜测是供电不足
话不多说 记录一下重新刷机的操作流程

下载镜像

在设备页面搜索对应的型号,下载

openwrt-24.10.0-ramips-mt7621-d-team_newifi-d2-initramfs-kernel.bin 底包(恢复模式不保存配置)
openwrt-24.10.0-ramips-mt7621-d-team_newifi-d2-squashfs-sysupgrade.bin 升级包

刷入

  1. 先在 192.168.1.1 breed 恢复出厂设置 选择 openwrt
  2. 刷入底包 不重启
  3. 刷入升级包 自动重启

重启后 先将 lan ip 段修改为 10.1

下载软件

  1. 设置代理

    export http_proxy="http://<代理 IP>:<端口>"
    export https_proxy="http://<代理 IP>:<端口>"
    export http_proxy="http://192.168.10.233:7897"
    export https_proxy="http://192.168.10.233:7897"
    
  2. 更新软件包

    root@OpenWrt:~# opkg update
    Downloading https://downloads.openwrt.org/releases/24.10.0/targets/ramips/mt7621/packages/Packages.gz
    Updated list of available packages in /var/opkg-lists/openwrt_core
    Downloading https://downloads.openwrt.org/releases/24.10.0/targets/ramips/mt7621/packages/Packages.sig
    Signature check passed.
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/base/Packages.gz
    Updated list of available packages in /var/opkg-lists/openwrt_base
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/base/Packages.sig
    Signature check passed.
    Downloading https://downloads.openwrt.org/releases/24.10.0/targets/ramips/mt7621/kmods/6.6.73-1-3abe85def815b59c6c75ac1f92135cb6/Packages.gz
    Updated list of available packages in /var/opkg-lists/openwrt_kmods
    Downloading https://downloads.openwrt.org/releases/24.10.0/targets/ramips/mt7621/kmods/6.6.73-1-3abe85def815b59c6c75ac1f92135cb6/Packages.sig
    Signature check passed.
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/luci/Packages.gz
    Updated list of available packages in /var/opkg-lists/openwrt_luci
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/luci/Packages.sig
    Signature check passed.
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/Packages.gz
    Updated list of available packages in /var/opkg-lists/openwrt_packages
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/Packages.sig
    Signature check passed.
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/routing/Packages.gz
    Updated list of available packages in /var/opkg-lists/openwrt_routing
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/routing/Packages.sig
    Signature check passed.
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/telephony/Packages.gz
    Updated list of available packages in /var/opkg-lists/openwrt_telephony
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/telephony/Packages.sig
    Signature check passed.
    
  3. 下载中文字体

    root@OpenWrt:~# opkg install luci-i18n-base-zh-cn
    Installing luci-i18n-base-zh-cn (25.206.68186~6da5e65) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/luci/luci-i18n-base-zh-cn_25.206.68186~6da5e65_all.ipk
    Configuring luci-i18n-base-zh-cn.
    
  4. 下载软件包 防火墙 中文字体

    root@OpenWrt:~# opkg install luci-i18n-firewall-zh-cn luci-i18n-package-manager-zh-cn
    Installing luci-i18n-firewall-zh-cn (25.206.68186~6da5e65) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/luci/luci-i18n-firewall-zh-cn_25.206.68186~6da5e65_all.ipk
    Installing luci-i18n-package-manager-zh-cn (25.206.68186~6da5e65) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/luci/luci-i18n-package-manager-zh-cn_25.206.68186~6da5e65_all.ipk
    Configuring luci-i18n-package-manager-zh-cn.
    Configuring luci-i18n-firewall-zh-cn.
    
  5. 下载 luci-proto-modemmanager

    root@OpenWrt:~# opkg install luci-proto-modemmanager
    Installing luci-proto-modemmanager (25.206.68186~6da5e65) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/luci/luci-proto-modemmanager_25.206.68186~6da5e65_all.ipk
    Installing zlib (1.3.1-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/base/zlib_1.3.1-r1_mipsel_24kc.ipk
    Installing libffi (3.4.7-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/libffi_3.4.7-r1_mipsel_24kc.ipk
    Installing libattr (2.5.2-r3) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/libattr_2.5.2-r3_mipsel_24kc.ipk
    Installing libpcre2 (10.42-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/base/libpcre2_10.42-r1_mipsel_24kc.ipk
    Installing glib2 (2.82.0-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/glib2_2.82.0-r1_mipsel_24kc.ipk
    Installing libexpat (2.7.1-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/libexpat_2.7.1-r1_mipsel_24kc.ipk
    Installing libdbus (1.14.10-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/libdbus_1.14.10-r1_mipsel_24kc.ipk
    Installing dbus (1.14.10-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/dbus_1.14.10-r1_mipsel_24kc.ipk
    Installing libmbim (1.30.0-r2) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/libmbim_1.30.0-r2_mipsel_24kc.ipk
    Installing libqrtr-glib (1.2.2-r3) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/libqrtr-glib_1.2.2-r3_mipsel_24kc.ipk
    Installing libqmi (1.34.0-r2) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/libqmi_1.34.0-r2_mipsel_24kc.ipk
    Installing modemmanager (1.22.0-r20) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/modemmanager_1.22.0-r20_mipsel_24kc.ipk
    Configuring zlib.
    Configuring libffi.
    Configuring libattr.
    Configuring libpcre2.
    Configuring glib2.
    Configuring libdbus.
    Configuring libexpat.
    Configuring dbus.
    Configuring libmbim.
    Configuring libqrtr-glib.
    Configuring libqmi.
    Configuring modemmanager.
    Configuring luci-proto-modemmanager.
    
  6. 安装串口驱动

    root@OpenWrt:~# opkg install kmod-usb-serial-option
    Installing kmod-usb-serial-option (6.6.73-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/targets/ramips/mt7621/kmods/6.6.73-1-3abe85def815b59c6c75ac1f92135cb6/kmod-usb-serial-option_6.6.73-r1_mipsel_24kc.ipk
    Installing kmod-usb-serial-wwan (6.6.73-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/targets/ramips/mt7621/kmods/6.6.73-1-3abe85def815b59c6c75ac1f92135cb6/kmod-usb-serial-wwan_6.6.73-r1_mipsel_24kc.ipk
    Installing kmod-usb-serial (6.6.73-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/targets/ramips/mt7621/kmods/6.6.73-1-3abe85def815b59c6c75ac1f92135cb6/kmod-usb-serial_6.6.73-r1_mipsel_24kc.ipk
    Configuring kmod-usb-serial.
    Configuring kmod-usb-serial-wwan.
    Configuring kmod-usb-serial-option.
    

此时/dev 目录下出现 ttyUSB0-3 共 4 个设备

  1. 安装 qmi 驱动

    root@OpenWrt:~# opkg install kmod-usb-net-qmi-wwan
    Installing kmod-usb-net-qmi-wwan (6.6.73-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/targets/ramips/mt7621/kmods/6.6.73-1-3abe85def815b59c6c75ac1f92135cb6/kmod-usb-net-qmi-wwan_6.6.73-r1_mipsel_24kc.ipk
    Installing kmod-mii (6.6.73-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/targets/ramips/mt7621/kmods/6.6.73-1-3abe85def815b59c6c75ac1f92135cb6/kmod-mii_6.6.73-r1_mipsel_24kc.ipk
    Installing kmod-usb-net (6.6.73-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/targets/ramips/mt7621/kmods/6.6.73-1-3abe85def815b59c6c75ac1f92135cb6/kmod-usb-net_6.6.73-r1_mipsel_24kc.ipk
    Installing kmod-usb-wdm (6.6.73-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/targets/ramips/mt7621/kmods/6.6.73-1-3abe85def815b59c6c75ac1f92135cb6/kmod-usb-wdm_6.6.73-r1_mipsel_24kc.ipk
    Configuring kmod-mii.
    Configuring kmod-usb-net.
    Configuring kmod-usb-wdm.
    Configuring kmod-usb-net-qmi-wwan.
    此时/dev 目录下出现 cdc-wdm0 设备
    
  2. 检查 modem 状态

    root@OpenWrt:~# mmcli -m 0
    --------------------------------
    General  |                 path: /org/freedesktop/ModemManager1/Modem/0
            |            device id: ce92585cf7f578c2e3553abd9210d7762dbc7b0b
    --------------------------------
    Hardware |         manufacturer: Quectel
            |                model: RM500Q-GL
            |    firmware revision: RM500QGLABR11A06M4G
            |            supported: gsm-umts, lte
            |              current: gsm-umts, lte
            |         equipment id: 863305040386707
    --------------------------------
    System   |               device: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
            |              physdev: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
            |              drivers: option1
            |               plugin: quectel
            |         primary port: ttyUSB2
            |                ports: ttyUSB0 (ignored), ttyUSB1 (gps), ttyUSB2 (at), ttyUSB3 (at)
    --------------------------------
    Status   |       unlock retries: sim-pin (3), sim-puk (10), sim-pin2 (3), sim-puk2 (10)
            |                state: enabled
            |          power state: on
            |       signal quality: 0% (recent)
    --------------------------------
    Modes    |            supported: allowed: 2g, 3g, 4g; preferred: none
            |              current: allowed: 2g, 3g, 4g; preferred: none
    --------------------------------
    IP       |            supported: ipv4, ipv6, ipv4v6
    --------------------------------
    3GPP     |                 imei: 863305040386707
            |         registration: idle
            | packet service state: detached
    --------------------------------
    3GPP EPS | ue mode of operation: csps-2
    --------------------------------
    SIM      |     primary sim path: /org/freedesktop/ModemManager1/SIM/0
    

    但发现似乎只有 4G,重启一下

    root@OpenWrt:~# mmcli -m 0
      -----------------------------------
      General  |                    path: /org/freedesktop/ModemManager1/Modem/0
              |               device id: 55b790e914f167a75e8593a7784d60c2d154eb97
      -----------------------------------
      Hardware |            manufacturer: Quectel
              |                   model: RM500Q-GL
              |       firmware revision: RM500QGLABR11A06M4G
              |          carrier config: VoLTE_OPNMKT_CT
              | carrier config revision: 0A0113E0
              |            h/w revision: 20000
              |               supported: gsm-umts, lte, 5gnr, tds
              |                 current: gsm-umts, lte, 5gnr, tds
              |            equipment id: 863305040386707
      -----------------------------------
      System   |                  device: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
              |                 physdev: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
              |                 drivers: qmi_wwan, option1
              |                  plugin: quectel
              |            primary port: cdc-wdm0
              |                   ports: cdc-wdm0 (qmi), ttyUSB0 (ignored), ttyUSB1 (gps),
              |                          ttyUSB2 (at), ttyUSB3 (at), wwan0 (net)
      -----------------------------------
      Numbers  |                     own:
      -----------------------------------
      Status   |                    lock: sim-pin2
              |          unlock retries: sim-pin (3), sim-puk (10), sim-pin2 (3), sim-puk2 (10)
              |                   state: disabled
              |             power state: on
      -----------------------------------
      Modes    |               supported: allowed: 3g; preferred: none
              |                          allowed: 4g; preferred: none
              |                          allowed: 3g, 4g; preferred: 4g
              |                          allowed: 3g, 4g; preferred: 3g
              |                          allowed: 5g; preferred: none
              |                          allowed: 4g, 5g; preferred: 5g
              |                          allowed: 4g, 5g; preferred: 4g
              |                          allowed: 3g, 5g; preferred: 5g
              |                          allowed: 3g, 5g; preferred: 3g
              |                          allowed: 3g, 4g, 5g; preferred: 5g
              |                          allowed: 3g, 4g, 5g; preferred: 4g
              |                          allowed: 3g, 4g, 5g; preferred: 3g
              |                 current: allowed: 3g, 4g, 5g; preferred: 5g
      -----------------------------------
      Bands    |               supported: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8,
              |                          utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, eutran-7,
              |                          eutran-8, eutran-12, eutran-13, eutran-14, eutran-17, eutran-18,
              |                          eutran-19, eutran-20, eutran-25, eutran-26, eutran-28, eutran-29,
              |                          eutran-30, eutran-32, eutran-34, eutran-38, eutran-39, eutran-40,
              |                          eutran-41, eutran-42, eutran-43, eutran-46, eutran-48, eutran-66,
              |                          eutran-71, utran-19, ngran-1, ngran-2, ngran-3, ngran-5, ngran-7,
              |                          ngran-8, ngran-12, ngran-20, ngran-25, ngran-28, ngran-38, ngran-40,
              |                          ngran-41, ngran-48, ngran-66, ngran-71, ngran-77, ngran-78, ngran-79
              |                 current: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8,
              |                          utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, eutran-7,
              |                          eutran-8, eutran-12, eutran-13, eutran-14, eutran-17, eutran-18,
              |                          eutran-19, eutran-20, eutran-25, eutran-26, eutran-28, eutran-29,
              |                          eutran-30, eutran-32, eutran-34, eutran-38, eutran-39, eutran-40,
              |                          eutran-41, eutran-42, eutran-43, eutran-46, eutran-48, eutran-66,
              |                          eutran-71, utran-19, ngran-1, ngran-2, ngran-3, ngran-5, ngran-7,
              |                          ngran-8, ngran-12, ngran-20, ngran-25, ngran-28, ngran-38, ngran-40,
              |                          ngran-41, ngran-48, ngran-66, ngran-71, ngran-77, ngran-78, ngran-79
      -----------------------------------
      IP       |               supported: ipv4, ipv6, ipv4v6
      -----------------------------------
      3GPP     |                    imei: 863305040386707
              |           enabled locks: fixed-dialing
      -----------------------------------
      3GPP EPS |    ue mode of operation: csps-2
              |      initial bearer apn: ctnet
              |  initial bearer ip type: ipv4v6
      -----------------------------------
      SIM      |        primary sim path: /org/freedesktop/ModemManager1/SIM/0
              |          sim slot paths: slot 1: /org/freedesktop/ModemManager1/SIM/0 (active)
              |                          slot 2: none
    
  3. 快速连接

    root@OpenWrt:~# mmcli -m 0 --simple-connect="apn=ctnet,ip-type=ipv4v6" # 指定中国电信 apn 并且获取 ipv4 和 ipv6
    successfully connected the modem
    
  4. 在 openwrt-网络-接口 创建对应的网络接口

    创建 ipv4 接口 防火墙设置为 wan 创建 ipv6 接口 防火墙设置为 wan 获取到 ipv6 地址 但是我们需要获取 pd 地址以分配给 lan 接口下的设备,因此勾选扩展前缀 获取到 PD 地址 但是 lan 口还有一个本地的 ipv6,我不太需要 因此,在全局网络选项中删除 非常完美哈 测试下 ipv6 虽然有一项 DNS 失败,但是似乎不影响使用

  5. 安装 zerotier 并替换自建 planet

    root@OpenWrt:~# opkg install zerotier
    Installing zerotier (1.14.1-r3) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/zerotier_1.14.1-r3_mipsel_24kc.ipk
    Installing libstdcpp6 (13.3.0-r4) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/targets/ramips/mt7621/packages/libstdcpp6_13.3.0-r4_mipsel_24kc.ipk
    Installing kmod-tun (6.6.73-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/targets/ramips/mt7621/kmods/6.6.73-1-3abe85def815b59c6c75ac1f92135cb6/kmod-tun_6.6.73-r1_mipsel_24kc.ipk
    Installing ip-tiny (6.11.0-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/base/ip-tiny_6.11.0-r1_mipsel_24kc.ipk
    Installing libminiupnpc (2.2.8-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/libminiupnpc_2.2.8-r1_mipsel_24kc.ipk
    Installing libnatpmp1 (20230423-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/libnatpmp1_20230423-r1_mipsel_24kc.ipk
    Installing libatomic1 (13.3.0-r4) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/targets/ramips/mt7621/packages/libatomic1_13.3.0-r4_mipsel_24kc.ipk
    Configuring kmod-tun.
    Configuring libstdcpp6.
    Configuring ip-tiny.
    Configuring libminiupnpc.
    Configuring libnatpmp1.
    Configuring libatomic1.
    Configuring zerotier.
    disabled in /etc/config/zerotier
    
  6. 修改 zerotier 配置文件

    root@OpenWrt:~# cat /etc/config/zerotier
    
            config zerotier 'global'
                    # Sets whether ZeroTier is enabled or not
                    option enabled 1 #<--修改此处启用
                    # Sets the ZeroTier listening port (default 9993; set to 0 for random)
                    #option port '9993'
                    # Client secret (leave blank to generate a secret on first run)
                    option secret ''
                    # Path of the optional file local.conf (see documentation at
                    # https://docs.zerotier.com/config#local-configuration-options)
                    #option local_conf_path '/etc/zerotier.conf'
                    # Persistent configuration directory (to perform other configurations such
                    # as controller mode or moons, etc.)
                    #option config_path '/etc/zerotier' #<--稍后修改
                    # Copy the contents of the persistent configuration directory to memory
                    # instead of linking it, this avoids writing to flash
                    #option copy_config_path '1' #<--稍后修改 解释一下就是 链接时会直接操作原始的配置目录,复制则不会修改原始配置目录,每次重启都会复制指定目录中的配置 不会被覆盖
    
            # Network configuration, you can have as many configurations as networks you
            # want to join (the network name is optional)
            config network 'earth'
                    # Identifier of the network you wish to join
                    option id '5873cad879664679' #<--修改加入网络ID,需要替换planet才能连接上网络
                    # Network configuration parameters (all are optional, if not indicated the
                    # default values are set, see documentation at
                    # https://docs.zerotier.com/config/#network-specific-configuration)
                    option allow_managed '1'
                    option allow_global '0'
                    option allow_default '0'
                    option allow_dns '0'
    
            # Example of a second network (unnamed as it is optional)
            #config network
            #       option id '1234567890123456'
            #       option allow_managed '1'
            #       option allow_global '0'
            #       option allow_default '0'
            #       option allow_dns '0'
    
  7. 启动一次 zerotier 生成运行所需文件

    root@OpenWrt:~# service zerotier start
    Generating secret - please wait... done.
    root@OpenWrt:~# find / -name planet #等待出现该文件夹后再停止 zerotier 如未出现 重启重试几次
    /tmp/lib/zerotier-one/planet
    
  8. 复制配置目录到/etc/zerotier-one

    root@OpenWrt:~# cp -r /tmp/lib/zerotier-one /etc/zerotier-one
    
  9. 再次修改 zerotier 配置文件 笑死 默认示例的配置文件都被删完了

    config zerotier 'global'
            option enabled '1'
            option secret 'e20b6b1ea4:0:9d3ab19b2e221eca8514e9ba44ac7090fa9d18969e77270cc6ed56270dc8b4380f6d0aeee49bde16998bdd3f7f7f93919a7d23248d762649e0b886640c168896:7d7f57737e57e88da2f0ede3eae062516e9335013e046f50c6e891f497b98f579067eb43f9b0a4f3bce9b237807c987c54d9c60fcc8f8673b8d………………'
            option config_path '/etc/zerotier-one' # 增加这行 为刚才复制的配置目录
            option copy_config_path '1' # 增加这行 避免配置被覆盖,每次都还原/etc/zerotier-one的配置目录
    config network 'earth'
            option id '5873cad879664679'
            option allow_managed '1'
            option allow_global '0'
            option allow_default '0'
            option allow_dns '0'
    
  10. 安装 sftp

    root@OpenWrt:~# opkg install openssh-sftp-server
    Installing openssh-sftp-server (9.9_p2-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/openssh-sftp-server_9.9_p2-r1_mipsel_24kc.ipk
    Configuring openssh-sftp-server
    
  11. 替换 planet
    替换路径/etc/zerotier-one/planet
    别替换错了 替换到/tmp/lib/zerotier-one/planet 重启之后就无效了

  12. 重启 zerotier

    root@OpenWrt:~# service zerotier restart
    
  13. 到控制台许可新接入设备
  14. 测试 ping

    root@OpenWrt:~# ping 10.10.1.55
    PING 10.10.1.55 (10.10.1.55): 56 data bytes
    64 bytes from 10.10.1.55: seq=0 ttl=64 time=435.598 ms
    64 bytes from 10.10.1.55: seq=1 ttl=64 time=48.699 ms
    64 bytes from 10.10.1.55: seq=2 ttl=64 time=54.807 ms
    ^C
    --- 10.10.1.55 ping statistics ---
    3 packets transmitted, 3 packets received, 0% packet loss
    round-trip min/avg/max = 48.699/179.701/435.598 ms
    root@OpenWrt:~#
    
  15. 调整防火墙

    入站只能访问路由器
    转发可以在 zerotier 中设置路由,使其他节点可以通过该路由器转发到 lan 网络 转发之后就可以不在 192.168.10.0 网段内 访问 192.168.10.1 到达路由器本质上就是 转发到 lan 去了 ,而 192.168.10.1 是 lan 的网关

  16. 安装其他软件

    网络唤醒

    root@OpenWrt:~# opkg install luci-app-wol luci-i18n-wol-zh-cn
    Installing luci-app-wol (25.206.68186~6da5e65) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/luci/luci-app-wol_25.206.68186~6da5e65_all.ipk
    Installing etherwake (1.09-r5) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/etherwake_1.09-r5_mipsel_24kc.ipk
    Configuring etherwake.
    Configuring luci-app-wol.
    root@OpenWrt:~# opkg install luci-i18n-wol-zh-cn
    Installing luci-i18n-wol-zh-cn (25.221.62603~822db9a) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/luci/luci-i18n-wol-zh-cn_25.221.62603~822db9a_all.ipk
    Configuring luci-i18n-wol-zh-cn.
    

    给台式电脑分配静态 IP 地址,方便使用 wol

    dbus-utils软件包 获取dbus-monitor

    root@OpenWrt:~# opkg install dbus-utils
    Installing dbus-utils (1.14.10-r1) to root...
    Downloading https://downloads.openwrt.org/releases/24.10.0/packages/mipsel_24kc/packages/dbus-utils_1.14.10-r1_mipsel_24kc.ipk
    Configuring dbus-utils.
    
  17. 脚本监听短信电话转发到飞书

    root@OpenWrt:~# cat modem_event_listener.sh
    #!/bin/sh # modemmanager 通过 dbus-utils 监听短信来电并转发飞书
    FEISHU_WEBHOOK="https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    
            send_feishu_msg() {
            local text="$1"
            # 用wget发送POST,Content-Type: application/json
            wget -O- --header="Content-Type: application/json" \
            --post-data="{\"msg_type\":\"text\",\"content\":{\"text\":\"${text}\"}}" \
            "$FEISHU_WEBHOOK"
            }
    
            # 监听 ModemManager DBus 信号,过滤 Messaging 和 Voice 接口
            dbus-monitor --system "type='signal',sender='org.freedesktop.ModemManager1'" | while read -r line; do
    
            # --- 短信处理:监听 PropertiesChanged 短信状态变为 received ---
            if echo "$line" | grep -q "/org/freedesktop/ModemManager1/SMS/"; then
            if echo "$line" | grep -q "member=PropertiesChanged"; then
                    sms_path=$(echo "$line" | sed -n 's#.*\(/org/freedesktop/ModemManager1/SMS/[0-9]\+\).*#\1#p')
                    sms_info=$(mmcli -s "$sms_path" --output-keyvalue)
                            # 从完整信息中提取状态
                    state=$(echo "$sms_info" | grep 'sms.properties.state' | awk -F': ' '{print $2}' | tr -d ' ')
                    if [ "$state" = "received" ]; then
                    from=$(echo "$sms_info" | grep 'sms.content.number' | awk -F': ' '{print $2}')
                    content=$(echo "$sms_info" | grep 'sms.content.text' | head -n1 | awk -F': ' '{print $2}')
                            echo "---------------------"
                            echo "content"
                            echo "$content"
                            echo "---------------------"
                            decoded_content=$(echo -e "$(echo "$content" | sed 's/\\\\/\\/g')")
                            echo "---------------------"
                            echo "decoded_content"
                            echo "$decoded_content"
                            echo "---------------------"
                    sent=$(echo "$sms_info" | grep 'sms.properties.timestamp' | awk -F': ' '{print $2}')
                    text="【短信】\n发件人: $from\n时间: $sent\n内容: $decoded_content"
                    send_feishu_msg "$text"
                    fi
            fi
            fi
    
            # 来电事件(Voice Call Added)
            echo "$line" | grep "org.freedesktop.ModemManager1.Modem.Voice" | grep "Added" >/dev/null && {
            # 查询所有活动通话
            call_path=$(mmcli -m 0 --voice-list-calls | grep "Call" | awk '{print $1}' | head -n1)
    
    
            echo "---------------------"
            echo "call_path"
            echo "$call_path"
            echo "---------------------"
            call_info=$(mmcli -o "$call_path" --output-keyvalue)
            state=$(echo "$call_info" | grep 'call.properties.state-reason' | awk -F': ' '{print $2}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
            echo "---------------------"
            echo "call_info"
            echo "$call_info"
            echo "state"
            echo "$state"
            echo "---------------------"
            case "$state" in
                    incoming-new)
                            time=$(date "+%Y-%m-%d %H:%M:%S")
                            number=$(echo "$call_info" | grep 'call.properties.number' | awk -F': ' '{print $2}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
                            text="【来电】\n时间: $time\n号码: $number\n状态: $state"
                            echo "---------------------"
                            echo "number"
                            echo "$number"
                            echo "text"
                            echo "$text"
                            echo "---------------------"
                            send_feishu_msg "$text"
                            ;;
                    *)
                            echo "状态不匹配: $state"
                            ;;
            esac
    
    
            }
    
            done
    
    root@OpenWrt:~# chmod +x modem_event_listener.sh
    
  18. 设置启动项

    /etc/rc.local

    # Put your custom commands here that should be executed once
    # the system init finished. By default this file does nothing.
    sleep 15 #等待设备加载就绪
    #mmcli -m 0 --enable 2>&1 | logger -t modem-setup
    mmcli -m "$(mmcli -L | grep -o '/Modem/[0-9]\+' | grep -o '[0-9]\+' | head -n 1)" --simple-connect="apn=ctnet,ip-type=ipv4v6" 2>&1 | logger -t modem-setup ## 修改了modem编号0改为自动获取
    #sleep 2
    ip link set wwan0 down && ip link set wwan0 up #重启wwan0接口以获取ip地址
    /root/modem_event_listener.sh & #监听短信和来电转发到飞书
    exit 0
    
  19. 设置计划任务 定时查询流量

    0 22 \* \* _ sms_path=$(mmcli -m 0 --messaging-create-sms="number=10001,text=702" | grep -o '/org/freedesktop/ModemManager1/SMS/[0-9]\+') && mmcli -s "${sms_path##_/}" --send # 深圳电信指令 自行修改号码和指令
    
  20. 设置无线网络

    2.4G 5G

断连监控自动重连

经过多次测试,发现断连之后 10 秒左右,modem 就会重新连接,但编号会递增。

root@OpenWrt:~# mmcli -m 0
error: couldn't find modem
root@OpenWrt:~# mmcli -m 1
  -----------------------------------
  General  |                    path: /org/freedesktop/ModemManager1/Modem/1
           |               device id: 55b790e914f167a75e8593a7784d60c2d154eb97
  -----------------------------------
  Hardware |            manufacturer: Quectel
           |                   model: RM500Q-GL
           |       firmware revision: RM500QGLABR11A06M4G
           |          carrier config: VoLTE_OPNMKT_CT
           | carrier config revision: 0A0113E0
           |            h/w revision: 20000
           |               supported: gsm-umts, lte, 5gnr, tds
           |                 current: gsm-umts, lte, 5gnr, tds
           |            equipment id: 863305040386707
  -----------------------------------
  System   |                  device: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
           |                 physdev: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
           |                 drivers: option1, qmi_wwan
           |                  plugin: quectel
           |            primary port: cdc-wdm0
           |                   ports: cdc-wdm0 (qmi), ttyUSB0 (ignored), ttyUSB1 (gps),
           |                          ttyUSB2 (at), ttyUSB3 (at), wwan0 (net)
  -----------------------------------
  Numbers  |                     own:
  -----------------------------------
  Status   |                    lock: sim-pin2
           |          unlock retries: sim-pin (3), sim-puk (10), sim-pin2 (3), sim-puk2 (10)
           |                   state: disabled
           |             power state: on
  -----------------------------------
  Modes    |               supported: allowed: 3g; preferred: none
           |                          allowed: 4g; preferred: none
           |                          allowed: 3g, 4g; preferred: 4g
           |                          allowed: 3g, 4g; preferred: 3g
           |                          allowed: 5g; preferred: none
           |                          allowed: 4g, 5g; preferred: 5g
           |                          allowed: 4g, 5g; preferred: 4g
           |                          allowed: 3g, 5g; preferred: 5g
           |                          allowed: 3g, 5g; preferred: 3g
           |                          allowed: 3g, 4g, 5g; preferred: 5g
           |                          allowed: 3g, 4g, 5g; preferred: 4g
           |                          allowed: 3g, 4g, 5g; preferred: 3g
           |                 current: allowed: 3g, 4g, 5g; preferred: 5g
  -----------------------------------
  Bands    |               supported: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8,
           |                          utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, eutran-7,
           |                          eutran-8, eutran-12, eutran-13, eutran-14, eutran-17, eutran-18,
           |                          eutran-19, eutran-20, eutran-25, eutran-26, eutran-28, eutran-29,
           |                          eutran-30, eutran-32, eutran-34, eutran-38, eutran-39, eutran-40,
           |                          eutran-41, eutran-42, eutran-43, eutran-46, eutran-48, eutran-66,
           |                          eutran-71, utran-19, ngran-1, ngran-2, ngran-3, ngran-5, ngran-7,
           |                          ngran-8, ngran-12, ngran-20, ngran-25, ngran-28, ngran-38, ngran-40,
           |                          ngran-41, ngran-48, ngran-66, ngran-71, ngran-77, ngran-78, ngran-79
           |                 current: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8,
           |                          utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, eutran-7,
           |                          eutran-8, eutran-12, eutran-13, eutran-14, eutran-17, eutran-18,
           |                          eutran-19, eutran-20, eutran-25, eutran-26, eutran-28, eutran-29,
           |                          eutran-30, eutran-32, eutran-34, eutran-38, eutran-39, eutran-40,
           |                          eutran-41, eutran-42, eutran-43, eutran-46, eutran-48, eutran-66,
           |                          eutran-71, utran-19, ngran-1, ngran-2, ngran-3, ngran-5, ngran-7,
           |                          ngran-8, ngran-12, ngran-20, ngran-25, ngran-28, ngran-38, ngran-40,
           |                          ngran-41, ngran-48, ngran-66, ngran-71, ngran-77, ngran-78, ngran-79
  -----------------------------------
  IP       |               supported: ipv4, ipv6, ipv4v6
  -----------------------------------
  3GPP     |                    imei: 863305040386707
           |           enabled locks: fixed-dialing
  -----------------------------------
  3GPP EPS |    ue mode of operation: csps-2
           |      initial bearer apn: ctnet
           |  initial bearer ip type: ipv4v6
  -----------------------------------
  SIM      |        primary sim path: /org/freedesktop/ModemManager1/SIM/1
           |          sim slot paths: slot 1: /org/freedesktop/ModemManager1/SIM/1 (active)
           |                          slot 2: none
root@OpenWrt:~# mmcli -m 1 --simple-connect="apn=ctnet,ip-type=ipv4v6" 2>&1 | logger -t modem-setup
root@OpenWrt:~# mmcli -m 1
  -----------------------------------
  General  |                    path: /org/freedesktop/ModemManager1/Modem/1
           |               device id: 55b790e914f167a75e8593a7784d60c2d154eb97
  -----------------------------------
  Hardware |            manufacturer: Quectel
           |                   model: RM500Q-GL
           |       firmware revision: RM500QGLABR11A06M4G
           |          carrier config: VoLTE_OPNMKT_CT
           | carrier config revision: 0A0113E0
           |            h/w revision: 20000
           |               supported: gsm-umts, lte, 5gnr, tds
           |                 current: gsm-umts, lte, 5gnr, tds
           |            equipment id: 863305040386707
  -----------------------------------
  System   |                  device: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
           |                 physdev: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
           |                 drivers: option1, qmi_wwan
           |                  plugin: quectel
           |            primary port: cdc-wdm0
           |                   ports: cdc-wdm0 (qmi), ttyUSB0 (ignored), ttyUSB1 (gps),
           |                          ttyUSB2 (at), ttyUSB3 (at), wwan0 (net)
  -----------------------------------
  Numbers  |                     own:
  -----------------------------------
  Status   |                    lock: sim-pin2
           |          unlock retries: sim-pin (3), sim-puk (10), sim-pin2 (3), sim-puk2 (10)
           |                   state: connected
           |             power state: on
           |             access tech: 5gnr
           |          signal quality: 50% (recent)
  -----------------------------------
  Modes    |               supported: allowed: 3g; preferred: none
           |                          allowed: 4g; preferred: none
           |                          allowed: 3g, 4g; preferred: 4g
           |                          allowed: 3g, 4g; preferred: 3g
           |                          allowed: 5g; preferred: none
           |                          allowed: 4g, 5g; preferred: 5g
           |                          allowed: 4g, 5g; preferred: 4g
           |                          allowed: 3g, 5g; preferred: 5g
           |                          allowed: 3g, 5g; preferred: 3g
           |                          allowed: 3g, 4g, 5g; preferred: 5g
           |                          allowed: 3g, 4g, 5g; preferred: 4g
           |                          allowed: 3g, 4g, 5g; preferred: 3g
           |                 current: allowed: 3g, 4g, 5g; preferred: 5g
  -----------------------------------
  Bands    |               supported: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8,
           |                          utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, eutran-7,
           |                          eutran-8, eutran-12, eutran-13, eutran-14, eutran-17, eutran-18,
           |                          eutran-19, eutran-20, eutran-25, eutran-26, eutran-28, eutran-29,
           |                          eutran-30, eutran-32, eutran-34, eutran-38, eutran-39, eutran-40,
           |                          eutran-41, eutran-42, eutran-43, eutran-46, eutran-48, eutran-66,
           |                          eutran-71, utran-19, ngran-1, ngran-2, ngran-3, ngran-5, ngran-7,
           |                          ngran-8, ngran-12, ngran-20, ngran-25, ngran-28, ngran-38, ngran-40,
           |                          ngran-41, ngran-48, ngran-66, ngran-71, ngran-77, ngran-78, ngran-79
           |                 current: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8,
           |                          utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, eutran-7,
           |                          eutran-8, eutran-12, eutran-13, eutran-14, eutran-17, eutran-18,
           |                          eutran-19, eutran-20, eutran-25, eutran-26, eutran-28, eutran-29,
           |                          eutran-30, eutran-32, eutran-34, eutran-38, eutran-39, eutran-40,
           |                          eutran-41, eutran-42, eutran-43, eutran-46, eutran-48, eutran-66,
           |                          eutran-71, utran-19, ngran-1, ngran-2, ngran-3, ngran-5, ngran-7,
           |                          ngran-8, ngran-12, ngran-20, ngran-25, ngran-28, ngran-38, ngran-40,
           |                          ngran-41, ngran-48, ngran-66, ngran-71, ngran-77, ngran-78, ngran-79
  -----------------------------------
  IP       |               supported: ipv4, ipv6, ipv4v6
  -----------------------------------
  3GPP     |                    imei: 863305040386707
           |           enabled locks: fixed-dialing
           |             operator id: 46011
           |           operator name: CHN-CT
           |            registration: home
           |    packet service state: attached
  -----------------------------------
  3GPP EPS |    ue mode of operation: csps-2
           |      initial bearer apn: ctnet
           |  initial bearer ip type: ipv4v6
  -----------------------------------
  SIM      |        primary sim path: /org/freedesktop/ModemManager1/SIM/1
           |          sim slot paths: slot 1: /org/freedesktop/ModemManager1/SIM/1 (active)
           |                          slot 2: none
  -----------------------------------
  Bearer   |                   paths: /org/freedesktop/ModemManager1/Bearer/1
root@OpenWrt:~# ip link set wwan0 down && ip link set wwan0 up
root@OpenWrt:~# mmcli -m 1
error: couldn't find modem
root@OpenWrt:~# mmcli -m 2
  -----------------------------------
  General  |                    path: /org/freedesktop/ModemManager1/Modem/2
           |               device id: 55b790e914f167a75e8593a7784d60c2d154eb97
  -----------------------------------
  Hardware |            manufacturer: Quectel
           |                   model: RM500Q-GL
           |       firmware revision: RM500QGLABR11A06M4G
           |          carrier config: VoLTE_OPNMKT_CT
           | carrier config revision: 0A0113E0
           |            h/w revision: 20000
           |               supported: gsm-umts, lte, 5gnr, tds
           |                 current: gsm-umts, lte, 5gnr, tds
           |            equipment id: 863305040386707
  -----------------------------------
  System   |                  device: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
           |                 physdev: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
           |                 drivers: option1, qmi_wwan
           |                  plugin: quectel
           |            primary port: cdc-wdm0
           |                   ports: cdc-wdm0 (qmi), ttyUSB0 (ignored), ttyUSB1 (gps),
           |                          ttyUSB2 (at), ttyUSB3 (at), wwan0 (net)
  -----------------------------------
  Numbers  |                     own:
  -----------------------------------
  Status   |                    lock: sim-pin2
           |          unlock retries: sim-pin (3), sim-puk (10), sim-pin2 (3), sim-puk2 (10)
           |                   state: disabled
           |             power state: on
  -----------------------------------
  Modes    |               supported: allowed: 3g; preferred: none
           |                          allowed: 4g; preferred: none
           |                          allowed: 3g, 4g; preferred: 4g
           |                          allowed: 3g, 4g; preferred: 3g
           |                          allowed: 5g; preferred: none
           |                          allowed: 4g, 5g; preferred: 5g
           |                          allowed: 4g, 5g; preferred: 4g
           |                          allowed: 3g, 5g; preferred: 5g
           |                          allowed: 3g, 5g; preferred: 3g
           |                          allowed: 3g, 4g, 5g; preferred: 5g
           |                          allowed: 3g, 4g, 5g; preferred: 4g
           |                          allowed: 3g, 4g, 5g; preferred: 3g
           |                 current: allowed: 3g, 4g, 5g; preferred: 5g
  -----------------------------------
  Bands    |               supported: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8,
           |                          utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, eutran-7,
           |                          eutran-8, eutran-12, eutran-13, eutran-14, eutran-17, eutran-18,
           |                          eutran-19, eutran-20, eutran-25, eutran-26, eutran-28, eutran-29,
           |                          eutran-30, eutran-32, eutran-34, eutran-38, eutran-39, eutran-40,
           |                          eutran-41, eutran-42, eutran-43, eutran-46, eutran-48, eutran-66,
           |                          eutran-71, utran-19, ngran-1, ngran-2, ngran-3, ngran-5, ngran-7,
           |                          ngran-8, ngran-12, ngran-20, ngran-25, ngran-28, ngran-38, ngran-40,
           |                          ngran-41, ngran-48, ngran-66, ngran-71, ngran-77, ngran-78, ngran-79
           |                 current: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8,
           |                          utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, eutran-7,
           |                          eutran-8, eutran-12, eutran-13, eutran-14, eutran-17, eutran-18,
           |                          eutran-19, eutran-20, eutran-25, eutran-26, eutran-28, eutran-29,
           |                          eutran-30, eutran-32, eutran-34, eutran-38, eutran-39, eutran-40,
           |                          eutran-41, eutran-42, eutran-43, eutran-46, eutran-48, eutran-66,
           |                          eutran-71, utran-19, ngran-1, ngran-2, ngran-3, ngran-5, ngran-7,
           |                          ngran-8, ngran-12, ngran-20, ngran-25, ngran-28, ngran-38, ngran-40,
           |                          ngran-41, ngran-48, ngran-66, ngran-71, ngran-77, ngran-78, ngran-79
  -----------------------------------
  IP       |               supported: ipv4, ipv6, ipv4v6
  -----------------------------------
  3GPP     |                    imei: 863305040386707
           |           enabled locks: fixed-dialing
  -----------------------------------
  3GPP EPS |    ue mode of operation: csps-2
           |      initial bearer apn: ctnet
           |  initial bearer ip type: ipv4v6
  -----------------------------------
  SIM      |        primary sim path: /org/freedesktop/ModemManager1/SIM/2
           |          sim slot paths: slot 1: /org/freedesktop/ModemManager1/SIM/2 (active)
           |                          slot 2: none
root@OpenWrt:~# mmcli -m 2 --simple-connect="apn=ctnet,ip-type=ipv4v6" 2>&1 | logger -t modem-setup
root@OpenWrt:~# ip link set wwan0 down && ip link set wwan0 up
root@OpenWrt:~# mmcli -m 2
error: couldn't find modem
root@OpenWrt:~# mmcli -m 3
  -----------------------------------
  General  |                    path: /org/freedesktop/ModemManager1/Modem/3
           |               device id: 55b790e914f167a75e8593a7784d60c2d154eb97
  -----------------------------------
  Hardware |            manufacturer: Quectel
           |                   model: RM500Q-GL
           |       firmware revision: RM500QGLABR11A06M4G
           |          carrier config: VoLTE_OPNMKT_CT
           | carrier config revision: 0A0113E0
           |            h/w revision: 20000
           |               supported: gsm-umts, lte, 5gnr, tds
           |                 current: gsm-umts, lte, 5gnr, tds
           |            equipment id: 863305040386707
  -----------------------------------
  System   |                  device: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
           |                 physdev: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
           |                 drivers: option1, qmi_wwan
           |                  plugin: quectel
           |            primary port: cdc-wdm0
           |                   ports: cdc-wdm0 (qmi), ttyUSB0 (ignored), ttyUSB1 (gps),
           |                          ttyUSB2 (at), ttyUSB3 (at), wwan0 (net)
  -----------------------------------
  Numbers  |                     own:
  -----------------------------------
  Status   |                    lock: sim-pin2
           |          unlock retries: sim-pin (3), sim-puk (10), sim-pin2 (3), sim-puk2 (10)
           |                   state: disabled
           |             power state: on
  -----------------------------------
  Modes    |               supported: allowed: 3g; preferred: none
           |                          allowed: 4g; preferred: none
           |                          allowed: 3g, 4g; preferred: 4g
           |                          allowed: 3g, 4g; preferred: 3g
           |                          allowed: 5g; preferred: none
           |                          allowed: 4g, 5g; preferred: 5g
           |                          allowed: 4g, 5g; preferred: 4g
           |                          allowed: 3g, 5g; preferred: 5g
           |                          allowed: 3g, 5g; preferred: 3g
           |                          allowed: 3g, 4g, 5g; preferred: 5g
           |                          allowed: 3g, 4g, 5g; preferred: 4g
           |                          allowed: 3g, 4g, 5g; preferred: 3g
           |                 current: allowed: 3g, 4g, 5g; preferred: 5g
  -----------------------------------
  Bands    |               supported: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8,
           |                          utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, eutran-7,
           |                          eutran-8, eutran-12, eutran-13, eutran-14, eutran-17, eutran-18,
           |                          eutran-19, eutran-20, eutran-25, eutran-26, eutran-28, eutran-29,
           |                          eutran-30, eutran-32, eutran-34, eutran-38, eutran-39, eutran-40,
           |                          eutran-41, eutran-42, eutran-43, eutran-46, eutran-48, eutran-66,
           |                          eutran-71, utran-19, ngran-1, ngran-2, ngran-3, ngran-5, ngran-7,
           |                          ngran-8, ngran-12, ngran-20, ngran-25, ngran-28, ngran-38, ngran-40,
           |                          ngran-41, ngran-48, ngran-66, ngran-71, ngran-77, ngran-78, ngran-79
           |                 current: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8,
           |                          utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, eutran-7,
           |                          eutran-8, eutran-12, eutran-13, eutran-14, eutran-17, eutran-18,
           |                          eutran-19, eutran-20, eutran-25, eutran-26, eutran-28, eutran-29,
           |                          eutran-30, eutran-32, eutran-34, eutran-38, eutran-39, eutran-40,
           |                          eutran-41, eutran-42, eutran-43, eutran-46, eutran-48, eutran-66,
           |                          eutran-71, utran-19, ngran-1, ngran-2, ngran-3, ngran-5, ngran-7,
           |                          ngran-8, ngran-12, ngran-20, ngran-25, ngran-28, ngran-38, ngran-40,
           |                          ngran-41, ngran-48, ngran-66, ngran-71, ngran-77, ngran-78, ngran-79
  -----------------------------------
  IP       |               supported: ipv4, ipv6, ipv4v6
  -----------------------------------
  3GPP     |                    imei: 863305040386707
           |           enabled locks: fixed-dialing
  -----------------------------------
  3GPP EPS |    ue mode of operation: csps-2
           |      initial bearer apn: ctnet
           |  initial bearer ip type: ipv4v6
  -----------------------------------
  SIM      |        primary sim path: /org/freedesktop/ModemManager1/SIM/3
           |          sim slot paths: slot 1: /org/freedesktop/ModemManager1/SIM/3 (active)
           |                          slot 2: none
root@OpenWrt:~# mmcli -m 3 --simple-connect="apn=ctnet,ip-type=ipv4v6" 2>&1 | logger -t modem-setup
root@OpenWrt:~# ip link set wwan0 down && ip link set wwan0 up
root@OpenWrt:~# mmcli -m 3
error: couldn't find modem
root@OpenWrt:~# mmcli -m 4
  -----------------------------------
  General  |                    path: /org/freedesktop/ModemManager1/Modem/4
           |               device id: 55b790e914f167a75e8593a7784d60c2d154eb97
  -----------------------------------
  Hardware |            manufacturer: Quectel
           |                   model: RM500Q-GL
           |       firmware revision: RM500QGLABR11A06M4G
           |          carrier config: VoLTE_OPNMKT_CT
           | carrier config revision: 0A0113E0
           |            h/w revision: 20000
           |               supported: gsm-umts, lte, 5gnr, tds
           |                 current: gsm-umts, lte, 5gnr, tds
           |            equipment id: 863305040386707
  -----------------------------------
  System   |                  device: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
           |                 physdev: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
           |                 drivers: option1, qmi_wwan
           |                  plugin: quectel
           |            primary port: cdc-wdm0
           |                   ports: cdc-wdm0 (qmi), ttyUSB0 (ignored), ttyUSB1 (gps),
           |                          ttyUSB2 (at), ttyUSB3 (at), wwan0 (net)
  -----------------------------------
  Numbers  |                     own:
  -----------------------------------
  Status   |                    lock: sim-pin2
           |          unlock retries: sim-pin (3), sim-puk (10), sim-pin2 (3), sim-puk2 (10)
           |                   state: disabled
           |             power state: on
  -----------------------------------
  Modes    |               supported: allowed: 3g; preferred: none
           |                          allowed: 4g; preferred: none
           |                          allowed: 3g, 4g; preferred: 4g
           |                          allowed: 3g, 4g; preferred: 3g
           |                          allowed: 5g; preferred: none
           |                          allowed: 4g, 5g; preferred: 5g
           |                          allowed: 4g, 5g; preferred: 4g
           |                          allowed: 3g, 5g; preferred: 5g
           |                          allowed: 3g, 5g; preferred: 3g
           |                          allowed: 3g, 4g, 5g; preferred: 5g
           |                          allowed: 3g, 4g, 5g; preferred: 4g
           |                          allowed: 3g, 4g, 5g; preferred: 3g
           |                 current: allowed: 3g, 4g, 5g; preferred: 5g
  -----------------------------------
  Bands    |               supported: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8,
           |                          utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, eutran-7,
           |                          eutran-8, eutran-12, eutran-13, eutran-14, eutran-17, eutran-18,
           |                          eutran-19, eutran-20, eutran-25, eutran-26, eutran-28, eutran-29,
           |                          eutran-30, eutran-32, eutran-34, eutran-38, eutran-39, eutran-40,
           |                          eutran-41, eutran-42, eutran-43, eutran-46, eutran-48, eutran-66,
           |                          eutran-71, utran-19, ngran-1, ngran-2, ngran-3, ngran-5, ngran-7,
           |                          ngran-8, ngran-12, ngran-20, ngran-25, ngran-28, ngran-38, ngran-40,
           |                          ngran-41, ngran-48, ngran-66, ngran-71, ngran-77, ngran-78, ngran-79
           |                 current: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8,
           |                          utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, eutran-7,
           |                          eutran-8, eutran-12, eutran-13, eutran-14, eutran-17, eutran-18,
           |                          eutran-19, eutran-20, eutran-25, eutran-26, eutran-28, eutran-29,
           |                          eutran-30, eutran-32, eutran-34, eutran-38, eutran-39, eutran-40,
           |                          eutran-41, eutran-42, eutran-43, eutran-46, eutran-48, eutran-66,
           |                          eutran-71, utran-19, ngran-1, ngran-2, ngran-3, ngran-5, ngran-7,
           |                          ngran-8, ngran-12, ngran-20, ngran-25, ngran-28, ngran-38, ngran-40,
           |                          ngran-41, ngran-48, ngran-66, ngran-71, ngran-77, ngran-78, ngran-79
  -----------------------------------
  IP       |               supported: ipv4, ipv6, ipv4v6
  -----------------------------------
  3GPP     |                    imei: 863305040386707
           |           enabled locks: fixed-dialing
  -----------------------------------
  3GPP EPS |    ue mode of operation: csps-2
           |      initial bearer apn: ctnet
           |  initial bearer ip type: ipv4v6
  -----------------------------------
  SIM      |        primary sim path: /org/freedesktop/ModemManager1/SIM/4
           |          sim slot paths: slot 1: /org/freedesktop/ModemManager1/SIM/4 (active)
           |                          slot 2: none
root@OpenWrt:~# mmcli -m 4 --simple-connect="apn=ctnet,ip-type=ipv4v6" 2>&1 | logger -t modem-setup
root@OpenWrt:~# ip link set wwan0 down && ip link set wwan0 up
root@OpenWrt:~# mmcli -m 4
  -----------------------------------
  General  |                    path: /org/freedesktop/ModemManager1/Modem/4
           |               device id: 55b790e914f167a75e8593a7784d60c2d154eb97
  -----------------------------------
  Hardware |            manufacturer: Quectel
           |                   model: RM500Q-GL
           |       firmware revision: RM500QGLABR11A06M4G
           |          carrier config: VoLTE_OPNMKT_CT
           | carrier config revision: 0A0113E0
           |            h/w revision: 20000
           |               supported: gsm-umts, lte, 5gnr, tds
           |                 current: gsm-umts, lte, 5gnr, tds
           |            equipment id: 863305040386707
  -----------------------------------
  System   |                  device: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
           |                 physdev: /sys/devices/platform/1e1c0000.xhci/usb2/2-1
           |                 drivers: option1, qmi_wwan
           |                  plugin: quectel
           |            primary port: cdc-wdm0
           |                   ports: cdc-wdm0 (qmi), ttyUSB0 (ignored), ttyUSB1 (gps),
           |                          ttyUSB2 (at), ttyUSB3 (at), wwan0 (net)
  -----------------------------------
  Numbers  |                     own:
  -----------------------------------
  Status   |                    lock: sim-pin2
           |          unlock retries: sim-pin (3), sim-puk (10), sim-pin2 (3), sim-puk2 (10)
           |                   state: connected
           |             power state: on
           |             access tech: 5gnr
           |          signal quality: 50% (recent)
  -----------------------------------
  Modes    |               supported: allowed: 3g; preferred: none
           |                          allowed: 4g; preferred: none
           |                          allowed: 3g, 4g; preferred: 4g
           |                          allowed: 3g, 4g; preferred: 3g
           |                          allowed: 5g; preferred: none
           |                          allowed: 4g, 5g; preferred: 5g
           |                          allowed: 4g, 5g; preferred: 4g
           |                          allowed: 3g, 5g; preferred: 5g
           |                          allowed: 3g, 5g; preferred: 3g
           |                          allowed: 3g, 4g, 5g; preferred: 5g
           |                          allowed: 3g, 4g, 5g; preferred: 4g
           |                          allowed: 3g, 4g, 5g; preferred: 3g
           |                 current: allowed: 3g, 4g, 5g; preferred: 5g
  -----------------------------------
  Bands    |               supported: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8,
           |                          utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, eutran-7,
           |                          eutran-8, eutran-12, eutran-13, eutran-14, eutran-17, eutran-18,
           |                          eutran-19, eutran-20, eutran-25, eutran-26, eutran-28, eutran-29,
           |                          eutran-30, eutran-32, eutran-34, eutran-38, eutran-39, eutran-40,
           |                          eutran-41, eutran-42, eutran-43, eutran-46, eutran-48, eutran-66,
           |                          eutran-71, utran-19, ngran-1, ngran-2, ngran-3, ngran-5, ngran-7,
           |                          ngran-8, ngran-12, ngran-20, ngran-25, ngran-28, ngran-38, ngran-40,
           |                          ngran-41, ngran-48, ngran-66, ngran-71, ngran-77, ngran-78, ngran-79
           |                 current: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8,
           |                          utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, eutran-7,
           |                          eutran-8, eutran-12, eutran-13, eutran-14, eutran-17, eutran-18,
           |                          eutran-19, eutran-20, eutran-25, eutran-26, eutran-28, eutran-29,
           |                          eutran-30, eutran-32, eutran-34, eutran-38, eutran-39, eutran-40,
           |                          eutran-41, eutran-42, eutran-43, eutran-46, eutran-48, eutran-66,
           |                          eutran-71, utran-19, ngran-1, ngran-2, ngran-3, ngran-5, ngran-7,
           |                          ngran-8, ngran-12, ngran-20, ngran-25, ngran-28, ngran-38, ngran-40,
           |                          ngran-41, ngran-48, ngran-66, ngran-71, ngran-77, ngran-78, ngran-79
  -----------------------------------
  IP       |               supported: ipv4, ipv6, ipv4v6
  -----------------------------------
  3GPP     |                    imei: 863305040386707
           |           enabled locks: fixed-dialing
           |             operator id: 46011
           |           operator name: CHN-CT
           |            registration: home
           |    packet service state: attached
  -----------------------------------
  3GPP EPS |    ue mode of operation: csps-2
           |      initial bearer apn: ctnet
           |  initial bearer ip type: ipv4v6
  -----------------------------------
  SIM      |        primary sim path: /org/freedesktop/ModemManager1/SIM/4
           |          sim slot paths: slot 1: /org/freedesktop/ModemManager1/SIM/4 (active)
           |                          slot 2: none
  -----------------------------------
  Bearer   |                   paths: /org/freedesktop/ModemManager1/Bearer/4

因此,将所有的 -m 0都改为自动获取 modem 编号,又出现短信接收不到的问题,断连问题待测试

开启调试使用 AT 命令

root@OpenWrt:~# mmcli -m 0 --command='AT+CSCA?'
error: command failed: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Unauthorized: Operation only allowed in debug mode'

需要打开 debug 模式才可以发送 AT 命令
/etc/init.d/modemmanager文件中把日志等级调成 DEBUG 即可自动开启 debug 模式
开启调试模式执行了一下上面的命令,查询了一下好像是模块短信存储空间满了

root@OpenWrt:~# mmcli -m 0 --command='AT+CPMS?'
response: '+CPMS: "ME",127,127,"ME",127,127,"MT",127,127'
root@OpenWrt:~# mmcli -m 0 --command='AT+CMGD=1,4'
response: ''
root@OpenWrt:~# mmcli -m 0 --command='AT+CPMS?'
response: '+CPMS: "ME",0,127,"ME",0,127,"MT",0,127'

删除之后就可以正常接收了,每次启动的时候删除一下所有短信

短信监控转发

还有一个问题 长短信的路径和短短信的路径不同 长短信有个接收的过程 接收完毕还有一个信号里面的路径是短信的路径 而短短信的路径只有 modem 的路径 没有短信的路径

短短信
+ echo 'signal time=1755025022.378589 sender=:1.0 -> destination=(null destination) serial=3570 path=/org/freedesktop/ModemManager1/Modem/0; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged'
+ grep -q /org/freedesktop/ModemManager1/SMS/
+ echo 'signal time=1755025022.378589 sender=:1.0 -> destination=(null destination) serial=3570 path=/org/freedesktop/ModemManager1/Modem/0; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged'
长短信
+ echo+  'signal time=1755025418.749287 sender=:1.0 -> destination=(null destination) serial=3888 path=/org/freedesktop/ModemManager1/SMS/40; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged'
grep -q /org/freedesktop/ModemManager1/SMS/
+ echo 'signal time=1755025418.749287 sender=:1.0 -> destination=(null destination) serial=3888 path=/org/freedesktop/ModemManager1/SMS/40; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged'
+ grep -q 'member=PropertiesChanged'
+ echo 'signal time=1755025418.749287 sender=:1.0 -> destination=(null destination) serial=3888 path=/org/freedesktop/ModemManager1/SMS/40; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged'

因此监控脚本做了一下兼容 精细匹配获取 member=Added 信号
短信中有\r 符号会导致 wget 请求失败状态码 400,使用 tr -d '\r' 删去

最终产物

modem_event_listener.sh 监控脚本

#!/bin/sh # modemmanager 通过 dbus-utils 监听短信来电并转发飞书
FEISHU_WEBHOOK="https://open.feishu.cn/open-apis/bot/v2/hook/f197a3f1-fc87-4870-8a49-ff7c925d2def"

send_feishu_msg() {
  local text="$1"
  local cmd="wget -O- --header=\"Content-Type: application/json\" \
    --post-data='{\"msg_type\":\"text\",\"content\":{\"text\":\"${text}\"}}' \
    \"$FEISHU_WEBHOOK\""

  # 输出原始命令到文件
  echo "$cmd" >> /tmp/wget_debug.log

  # 执行命令
  eval "$cmd"
}

get_modem_number() {
    mmcli -L | grep -o '/Modem/[0-9]\+' | grep -o '[0-9]\+' | head -n 1
}
connect_modem() {
    modem_num=$(get_modem_number)
    if [[ -n "$modem_num" ]]; then
        logger -t modem-setup "Connecting to modem $modem_num..."
        mmcli -m "$modem_num" --simple-connect="apn=ctnet,ip-type=ipv4v6" 2>&1 | logger -t modem-setup
		ip link set wwan0 down && ip link set wwan0 up
    fi
}
# 监听 ModemManager DBus 信号,过滤 Messaging 和 Voice 接口
(dbus-monitor --system "type='signal',sender='org.freedesktop.ModemManager1'" | while read -r line; do

# 来电事件(Voice Call Added)
echo "$line" | grep "signal time=" | grep "interface=org.freedesktop.ModemManager1.Modem.Voice" | grep "member=CallAdded" >/dev/null && {
  # 查询所有活动通话
  call_path=$(mmcli -m "$(get_modem_number)" --voice-list-calls | grep "(ringing-in)" | awk '{print $1}' | head -n1)
  call_info=$(mmcli -o "$call_path" --output-keyvalue)
  state=$(echo "$call_info" | grep 'call.properties.state-reason' | awk -F': ' '{print $2}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
  if [ "$state" = "incoming-new" ]; then
    time=$(date "+%Y-%m-%d %H:%M:%S")
    number=$(echo "$call_info" | grep 'call.properties.number' | awk -F': ' '{print $2}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
    text="【来电】\n时间: $time\n号码: $number\n状态: $state"
    send_feishu_msg "$text"
  else
    echo "状态不匹配: $state"
  fi
}
  # --- 短信处理:监听 PropertiesChanged ---
echo "$line" grep "signal time=" | grep  "interface=org.freedesktop.ModemManager1.Modem.Messaging" | grep "member=Added" >/dev/null && {
  # 取最新received短信路径
  sms_path=$(mmcli -m "$(get_modem_number)" --messaging-list-sms | grep received | head  -n1 | awk '{print $1}')
  until [ "$(mmcli -s "$sms_path" --output-keyvalue | grep 'sms.properties.state' | awk -F': ' '{print $2}' | tr -d ' ')" = "received" ]; do
  sleep 1
done
  sms_info=$(mmcli -s "$sms_path" --output-keyvalue)
  from=$(echo "$sms_info" | grep 'sms.content.number' | awk -F': ' '{print $2}')
  content=$(echo "$sms_info" | grep 'sms.content.text' | head -n1 | awk -F': ' '{print $2}')
  decoded_content=$(echo -e "$(echo "$content" | sed 's/\\\\/\\/g')")
  sent=$(echo "$sms_info" | grep 'sms.properties.timestamp' | awk -F': ' '{print $2}')
  json_text=$(printf '%s' "$decoded_content" | tr -d '\r' | sed ':a;N;$!ba;s/\n/\\n/g')
  text="【短信】\n发件人: $from\n时间: $sent\n内容: $json_text"
  send_feishu_msg "$text"
}
done) &

# 监控 modem 序号变化
(current_modem=$(get_modem_number)
while true; do
    sleep 5
    new_modem=$(get_modem_number)
    if [[ -n "$new_modem" && "$new_modem" -gt "$current_modem" ]]; then
        logger -t modem-event "Modem number changed from $current_modem to $new_modem, reconnecting..."
        connect_modem
        current_modem="$new_modem"
    fi
done) &

启动脚本

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
sleep 20
#mmcli -m "$(mmcli -L | grep -o '/Modem/[0-9]\+' | grep -o '[0-9]\+' | head -n 1)" --simple-connect="apn=ctnet,ip-type=ipv4v6" 2>&1 | logger -t modem-setup #中国电信
mmcli -m "$(mmcli -L | grep -o '/Modem/[0-9]\+' | grep -o '[0-9]\+' | head -n 1)" --simple-connect="apn=cmnet,ip-type=ipv4v6" 2>&1 | logger -t modem-setup #中国移动
mmcli -m 0 --command='AT+CMGD=1,4'
ip link set wwan0 down && ip link set wwan0 up
/root/modem_event_listener.sh & 
exit 0

计划任务

0 22 * * * sms_path=$(mmcli -m "$(mmcli -L | grep -o '/Modem/[0-9]\+' | grep -o '[0-9]\+' | head -n 1)" --messaging-create-sms="number=10001,text=702" | grep -o '/org/freedesktop/ModemManager1/SMS/[0-9]\+') && mmcli -s "${sms_path##*/}" --send

经过努力还是出现频繁断连的情况,WIFI功能也不太稳定,原因不详,将WIFI关闭后断连情况大幅改善,偶尔仍会出现模块断连的情况,疑似USB接口接触不良或者供电不足的情况,几秒后自动重连,无法解决,只能这样了。