ModemManager disconnects every 24h

Hi, I have been using ModemManager with a EP06E Quectel modem in QMI mode for quite some time now.

The issue is every 24h my ISP sends a disconnect event and ModemManager can't recover the connection automatically, I even tried the latest snapshot that has this commit: https://github.com/openwrt/packages/pull/23590/commits/77c16abb1a3021bba0db97cb4349e906c9bb6ecb

The only thing that works is soft resetting the modem in cron like this:

0 5 * * * (echo -e -n 'AT+CGDCONT=1,"IPV4V6","movistar.es";+CFUN=0;+CFUN=1;\r' > /dev/ttyUSB2) && sleep 5 && ifdown wwan && ifup wwan

This a usable workaround at best, but i'd like ModemManager to just reconnect.

Here is a log of a recent disconnect:

Log
Thu Sep 26 17:13:23 2024 daemon.notice [2703]: <msg> [modem0/bearer1] verbose call end reason (3,1110): [cm] (null)
Thu Sep 26 17:13:23 2024 daemon.notice [2703]: <msg> [modem0] state changed (connected -> registered)
Thu Sep 26 17:13:23 2024 daemon.notice [2703]: <msg> [modem0/bearer1] connection #1 finished: duration 86274s, tx: 1128703508 bytes, rx: 13372259271 bytes
Thu Sep 26 17:13:23 2024 daemon.notice [2703]: <msg> [modem0] 3GPP packet service state changed (attached -> detached)
Thu Sep 26 17:13:23 2024 daemon.info ModemManager[23147]: hotplug: Reconnecting 'wwan' on 'disconnected' event
Thu Sep 26 17:13:23 2024 daemon.notice netifd: Interface 'wg0' has lost the connection
Thu Sep 26 17:13:24 2024 daemon.warn dnsmasq[1]: no servers found in /tmp/resolv.conf.d/resolv.conf.auto, will retry
Thu Sep 26 17:13:24 2024 daemon.notice netifd: Network device 'wg0' link is down
Thu Sep 26 17:13:24 2024 daemon.info ModemManager[23212]: hotplug: remove network interface wg0: event processed
Thu Sep 26 17:13:24 2024 daemon.notice netifd: wwan (23207): stopping network
Thu Sep 26 17:13:24 2024 daemon.notice netifd: Interface 'wg0' is now down
Thu Sep 26 17:13:24 2024 daemon.notice netifd: Interface 'wg0' is setting up now
Thu Sep 26 17:13:24 2024 daemon.info [2703]: <inf> [modem0] processing user request to disconnect modem: all bearers
Thu Sep 26 17:13:24 2024 daemon.info [2703]: <inf> [modem0] all requested bearers disconnected
Thu Sep 26 17:13:24 2024 daemon.notice netifd: wwan (23207): successfully disconnected all bearers in the modem
Thu Sep 26 17:13:25 2024 daemon.info [2703]: <inf> [modem0] processing user request to disable modem...
Thu Sep 26 17:13:25 2024 daemon.notice [2703]: <msg> [modem0] state changed (registered -> disabling)
Thu Sep 26 17:13:25 2024 daemon.info [2703]: <inf> [modem0] access technology changed (lte -> unknown)
Thu Sep 26 17:13:25 2024 daemon.info ModemManager[23316]: hotplug: add network interface wg0: event processed
Thu Sep 26 17:13:25 2024 user.notice ddns-scripts[6649]: duckdns: PID '6649' terminated by 'SIGTERM' at 2024-09-26 17:13
Thu Sep 26 17:13:25 2024 daemon.notice [2703]: <msg> [modem0] 3GPP packet service state changed (detached -> unknown)
Thu Sep 26 17:13:25 2024 daemon.notice [2703]: <msg> [modem0] 3GPP registration state changed (home -> unknown)
Thu Sep 26 17:13:25 2024 daemon.info [2703]: <inf> [modem0] consolidated registration state: cs 'searching', ps 'searching', eps 'home', 5gs 'unknown' --> 'unknown'
Thu Sep 26 17:13:25 2024 daemon.notice [2703]: <msg> [modem0] 3GPP packet service state changed (unknown -> detached)
Thu Sep 26 17:13:25 2024 daemon.info [2703]: <inf> [modem0] disabled modem
Thu Sep 26 17:13:25 2024 daemon.notice [2703]: <msg> [modem0] state changed (disabling -> disabled)
Thu Sep 26 17:13:25 2024 daemon.notice netifd: wwan (23207): successfully disabled the modem
Thu Sep 26 17:13:25 2024 daemon.notice netifd: Interface 'wwan' is now down
Thu Sep 26 17:13:25 2024 daemon.notice netifd: Interface 'wwan' is setting up now
Thu Sep 26 17:13:26 2024 daemon.notice netifd: wwan (23403): modem available at /org/freedesktop/ModemManager1/Modem/0
Thu Sep 26 17:13:26 2024 daemon.info [2703]: <inf> [modem0] processing user request to disconnect modem: all bearers
Thu Sep 26 17:13:26 2024 daemon.info [2703]: <inf> [modem0] all requested bearers disconnected
Thu Sep 26 17:13:26 2024 daemon.info [2703]: <inf> [modem0] processing user request to delete bearer '/org/freedesktop/ModemManager1/Bearer/1'...
Thu Sep 26 17:13:26 2024 daemon.info [2703]: <inf> [modem0] deleted bearer '/org/freedesktop/ModemManager1/Bearer/1'
Thu Sep 26 17:13:27 2024 daemon.info [2703]: <inf> [modem0] processing user request to enable modem...
Thu Sep 26 17:13:27 2024 daemon.notice [2703]: <msg> [modem0] state changed (disabled -> enabling)
Thu Sep 26 17:13:27 2024 daemon.notice [2703]: <msg> [modem0] power state updated: on
Thu Sep 26 17:13:27 2024 daemon.info [2703]: <inf> [modem0] checking if SIM was swapped...
Thu Sep 26 17:13:27 2024 daemon.info [2703]: <inf> [modem0] SIM identifier has not changed: ###
Thu Sep 26 17:13:27 2024 daemon.info [2703]: <inf> [modem0] SIM imsi has not changed: ###
Thu Sep 26 17:13:29 2024 daemon.notice netifd: wg0 (23276): Try again: `something.org:51820'. Trying again in 1.00 seconds...
Thu Sep 26 17:13:30 2024 daemon.notice [2703]: <msg> [modem0] 3GPP registration state changed (unknown -> searching)
Thu Sep 26 17:13:30 2024 daemon.info [2703]: <inf> [modem0] consolidated registration state: cs 'searching', ps 'searching', eps 'emergency-only', 5gs 'unknown' --> 'searching'
Thu Sep 26 17:13:31 2024 daemon.info [2703]: <inf> [modem0] enabled modem
Thu Sep 26 17:13:31 2024 daemon.notice [2703]: <msg> [modem0] state changed (enabling -> searching)
Thu Sep 26 17:13:31 2024 daemon.notice netifd: wwan (23403): successfully enabled the modem
Thu Sep 26 17:13:31 2024 daemon.notice netifd: wwan (23403): setting allowed mode to '4g'
Thu Sep 26 17:13:31 2024 daemon.info [2703]: <inf> [modem0] processing user request to set current modes to '4g' (preferred 'none')...
Thu Sep 26 17:13:31 2024 daemon.info [2703]: <inf> [modem0] current modes set to '4g' (preferred 'none')
Thu Sep 26 17:13:31 2024 daemon.notice netifd: wwan (23403): successfully set current modes in the modem
Thu Sep 26 17:13:31 2024 daemon.notice netifd: wwan (23403): starting connection with apn 'movistar.es'...
Thu Sep 26 17:13:31 2024 daemon.info [2703]: <inf> [modem0] processing user request to connect modem...
Thu Sep 26 17:13:31 2024 daemon.info [2703]: <inf> [modem0]   apn: movistar.es
Thu Sep 26 17:13:31 2024 daemon.info [2703]: <inf> [modem0]   ip type: ipv4
Thu Sep 26 17:13:31 2024 daemon.info [2703]: <inf> [modem0]   allowed auth: unknown
Thu Sep 26 17:13:31 2024 daemon.info [2703]: <inf> [modem0]   allow roaming: yes
Thu Sep 26 17:13:31 2024 daemon.notice [2703]: <msg> [modem0] simple connect started...
Thu Sep 26 17:13:31 2024 daemon.notice [2703]: <msg> [modem0] simple connect state (4/10): wait to get fully enabled
Thu Sep 26 17:13:31 2024 daemon.notice [2703]: <msg> [modem0] simple connect state (5/10): wait after enabled
Thu Sep 26 17:13:31 2024 daemon.notice [2703]: <msg> [modem0] simple connect state (6/10): register
Thu Sep 26 17:13:31 2024 daemon.info [2703]: <inf> [modem0] launching automatic network registration...
Thu Sep 26 17:13:35 2024 daemon.notice netifd: wg0 (23276): Try again: `something.org:51820'. Trying again in 1.20 seconds...
Thu Sep 26 17:13:42 2024 daemon.notice netifd: wg0 (23276): Try again: `something.org:51820'. Trying again in 1.44 seconds...
Thu Sep 26 17:13:48 2024 daemon.notice netifd: wg0 (23276): Try again: `something.org:51820'. Trying again in 1.73 seconds...
Thu Sep 26 17:13:55 2024 daemon.notice netifd: wg0 (23276): Try again: `something.org:51820'. Trying again in 2.07 seconds...
Thu Sep 26 17:14:02 2024 daemon.notice netifd: wg0 (23276): Try again: `something.org:51820'. Trying again in 2.49 seconds...
Thu Sep 26 17:14:09 2024 daemon.notice netifd: wg0 (23276): Try again: `something.org:51820'. Trying again in 2.99 seconds...
Thu Sep 26 17:14:17 2024 daemon.notice netifd: wg0 (23276): Try again: `something.org:51820'. Trying again in 3.58 seconds...
Thu Sep 26 17:14:26 2024 daemon.notice netifd: wg0 (23276): Try again: `something.org:51820'. Trying again in 4.30 seconds...
Thu Sep 26 17:14:32 2024 daemon.info [2703]: <inf> [modem0] 3GPP registration check timed out
Thu Sep 26 17:14:32 2024 daemon.notice [2703]: <msg> [modem0] 3GPP registration state changed (searching -> idle)
Thu Sep 26 17:14:32 2024 daemon.info [2703]: <inf> [modem0] consolidated registration state: cs 'idle', ps 'idle', eps 'idle', 5gs 'unknown' --> 'idle'
Thu Sep 26 17:14:32 2024 daemon.notice [2703]: <msg> [modem0] state changed (searching -> enabled)
Thu Sep 26 17:14:32 2024 daemon.warn [2703]: <wrn> [modem0] registration in network failed: Network timeout
Thu Sep 26 17:14:32 2024 daemon.notice netifd: wwan (23403): error: couldn't connect the modem: 'GDBus.Error:org.freedesktop.ModemManager1.Error.MobileEquipment.NetworkTimeout: Network timeout'
Thu Sep 26 17:14:32 2024 daemon.notice netifd: wwan (23637): stopping network
Thu Sep 26 17:14:32 2024 daemon.notice netifd: wwan (23637): couldn't load bearer path: disconnecting anyway
Thu Sep 26 17:14:32 2024 daemon.info [2703]: <inf> [modem0] processing user request to disconnect modem: all bearers
Thu Sep 26 17:14:32 2024 daemon.info [2703]: <inf> [modem0] all requested bearers disconnected
Thu Sep 26 17:14:32 2024 daemon.notice netifd: Interface 'wwan' is now down

What is the reason for you to use modemmmanager when there is native qmi in openwrt?

Please connect to your OpenWrt device using ssh and copy the output of the following commands and post it here using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have:

ubus call system board
cat /etc/config/network
cat /etc/config/wireless
cat /etc/config/dhcp
cat /etc/config/firewall

I use ModemManager because the LuCI app is quite good and I can easily change the preferred network type. QMI has the same issue, I have using it for three years and I only switched to ModemManager recently for the reasons above and seeing if it solved the issue.

ubus:

{
        "kernel": "6.6.52",
        "hostname": "u7621-01",
        "system": "MediaTek MT7621 ver:1 eco:3",
        "model": "UniElec U7621-01 (16M flash)",
        "board_name": "unielec,u7621-01-16m",
        "rootfs_type": "squashfs",
        "release": {
                "distribution": "OpenWrt",
                "version": "SNAPSHOT",
                "revision": "r27578-23ac1ad951",
                "target": "ramips/mt7621",
                "description": "OpenWrt SNAPSHOT r27578-23ac1ad951"
        }
}

network

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'
config globals 'globals'
        option ula_prefix 'fdb2:30e7:7797::/48'
        option packet_steering '1'
config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'
config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '10.0.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'
config interface 'wan'
        option device 'wan'
        option proto 'dhcp'
config interface 'wan6'
        option device 'wan'
        option proto 'dhcpv6'
config interface 'wwan'
        option proto 'modemmanager'
        option device '/sys/devices/platform/1e1c0000.xhci/usb2/2-1'
        option apn 'movistar.es'
        list allowedauth 'none'
        option allowedmode '4g'
        option iptype 'ipv4'
        option loglevel 'ERR'

wireless

config wifi-device 'radio0'
        option type 'mac80211'
        option path '1e140000.pcie/pci0000:00/0000:00:01.0/0000:01:00.0'
        option band '2g'
        option channel 'auto'
        option htmode 'HT40'
        option disabled '0'
        option country 'ES'
        option cell_density '0'
config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'redacted'
        option encryption 'psk2'
        option key 'redacted'
config wifi-device 'radio1'
        option type 'mac80211'
        option path '1e140000.pcie/pci0000:00/0000:00:02.0/0000:02:00.0'
        option band '5g'
        option channel '36'
        option htmode 'VHT40'
        option disabled '0'
        option country 'ES'
        option cell_density '0'
config wifi-iface 'default_radio1'
        option device 'radio1'
        option network 'lan'
        option mode 'ap'
        option ssid 'redacted'
        option encryption 'psk2'
        option key 'redacted'

dhcp

config dnsmasq
        option domainneeded '1'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/redacted.lan/'
        option domain 'redacted.lan'
        option expandhosts '1'
        option cachesize '1000'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option localservice '1'
        option ednspacket_max '1232'
config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv4 'server'
        option dhcpv6 'disabled'
        option ra 'disabled'
        option ra_slaac '1'
        list ra_flags 'managed-config'
        list ra_flags 'other-config'
config dhcp 'wan'
        option interface 'wan'
        option ignore '1'
config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'

firewall

config defaults
        option input 'REJECT'
        option output 'ACCEPT'
        option forward 'REJECT'
        option flow_offloading '1'
        option flow_offloading_hw '1'
        option synflood_protect '1'
config zone
        option name 'lan'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'ACCEPT'
        list network 'lan'
        list network 'wg0'
config zone
        option name 'wan'
        option input 'REJECT'
        option output 'ACCEPT'
        option forward 'REJECT'
        option masq '1'
        option mtu_fix '1'
        list network 'wan'
        list network 'wan6'
        list network 'wwan'
config forwarding
        option src 'lan'
        option dest 'wan'
config rule
        option name 'Allow-DHCP-Renew'
        option src 'wan'
        option proto 'udp'
        option dest_port '68'
        option target 'ACCEPT'
        option family 'ipv4'
config rule
        option name 'Allow-Ping'
        option src 'wan'
        option proto 'icmp'
        option icmp_type 'echo-request'
        option family 'ipv4'
        option target 'ACCEPT'
config rule
        option name 'Allow-IGMP'
        option src 'wan'
        option proto 'igmp'
        option family 'ipv4'
        option target 'ACCEPT'
config rule
        option name 'Allow-DHCPv6'
        option src 'wan'
        option proto 'udp'
        option dest_port '546'
        option family 'ipv6'
        option target 'ACCEPT'
config rule
        option name 'Allow-MLD'
        option src 'wan'
        option proto 'icmp'
        option src_ip 'fe80::/10'
        list icmp_type '130/0'
        list icmp_type '131/0'
        list icmp_type '132/0'
        list icmp_type '143/0'
        option family 'ipv6'
        option target 'ACCEPT'
config rule
        option name 'Allow-ICMPv6-Input'
        option src 'wan'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        list icmp_type 'router-solicitation'
        list icmp_type 'neighbour-solicitation'
        list icmp_type 'router-advertisement'
        list icmp_type 'neighbour-advertisement'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'
config rule
        option name 'Allow-ICMPv6-Forward'
        option src 'wan'
        option dest '*'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'
config rule
        option name 'Allow-IPSec-ESP'
        option src 'wan'
        option dest 'lan'
        option proto 'esp'
        option target 'ACCEPT'
config rule
        option name 'Allow-ISAKMP'
        option src 'wan'
        option dest 'lan'
        option dest_port '500'
        option proto 'udp'
        option target 'ACCEPT'

https://openwrt.org/docs/guide-user/network/wan/wwan/ltedongle
Go with ecm mode, modem reconnects on its own.
You are dealing with sub-par ppp mode modemmanager is defaulting to.

1 Like

Understood, will try.

Last time I tried ECM (2020?) I remember it NAT'ed everything, and I couldn't open ports. Is there any command to disable it?

Check in mobile phone, between multiple APN-s one could be with real IP.

I already did, with my ISP Movistar there are two APNs:
telefonica.net which provides IPv4&IPv6 but has a CG-NAT'ed IPv4 address and movistar.es which provides only IPv4 but with a real address which you can use for port forwarding.

The thing is that I remeber using movistar.es and port forwarding was not working in ECM because the wan IP that ECM provided was something like 192.168.x.x.

I will try again when I can and report back, thanks for the insight into reconnection in ECM.

You can disable current config and port will be free for other mode.

1 Like

I just tried and no matter how I open the firewall for Wireguard or iperf3, which was working with QMI, it is blocked in ECM.

There are no extra filters attached between qmi and ecm, either way you just "dial" or "connect" to packet-radio-modem locally with that protocol.
Sometimes providers do not accept MAC address change, and you need to copy previous one from other connection.

This is the issue I'm running into in the client:

iperf3: error - unable to connect to server - server may have stopped running or use a different port, firewall issue, etc.: Connection refused

Connectivity seems fine.

Config:

config redirect
	option dest 'lan'
	option target 'DNAT'
	option name 'iperf3'
	option src 'wan'
	option src_dport '5201'
	option dest_ip '10.0.1.1'
	option dest_port '5201'
	list proto 'tcp'
	list proto 'udp'

Was previously working with QMI and also I can't access the Quectel WebUI, but I don't even know if the EP06E has one? It should look like this (https://www.jeffgeerling.com/blog/2022/using-4g-lte-wireless-modems-on-raspberry-pi):

Somewhere in the menus you can bypass the nat and get public ip on your device while the service garden will be still reachable.

The thing is, it doesn't work. Nothing on port 80 or 443, and I haven't seen anyone reporting that it works on EP06E

seems modemmanager falls back to 3gpp ppp and does not use qmi.
strange the connection does not restart, say dhcp ethernet you can reconnect and it dhcp-s every time....

Using your cron job obviously works; ModemManager does not. Thus, I suggest you do the same as I do, for EC25, though: Just have a short script, periodically pinging a well known IP, i.g. 8.8.8.8 . Which is a better solution compared to cron. ModemManagers biggest flaw is the fact, that it relies on an external event to detect the breakage of the cell connection. But such an event does not always show up. In worst case, using QMI I have seen a modem simply to "hang". Active pings will detect it.