Professional Documents
Culture Documents
[OpenWrt Wiki] How to use LTE modem in QMI mode for WAN connection
[OpenWrt Wiki] How to use LTE modem in QMI mode for WAN connection
[OpenWrt Wiki] How to use LTE modem in QMI mode for WAN connection
You are here / / Documentation / User guide / Network / WAN (Internet access)
/ WWAN (3G/4G/LTE and similar) / How to use LTE modem in QMI mode for WAN connection
This recipe explains how to setup and configure OpenWrt for using 3G/4G/5G USB modems
for WAN () connection, using QMI or MBIM interface.
The same applies to external modems connected to USB ports and internal models installed
into M.2(NGFF) or mPCIe slots.
You may want to checkout the mwan3 (Multi WAN () load balancing/failover) package to use
this simultaneously with other connections to the internet.
About
Many modern USB modems may operate in different modes. If your modem provides only
serial interface(s) like /dev/ttyUSBx - please refer to How to use 3g/UMTS USB Dongle for
WAN connection. For more information about other protocols commonly used:
If it is possible to switch your modem to provide QMI or MBIM interface - then this article if for
you.
1 of 12 7/1/24, 7:29 PM
[OpenWrt Wiki] How to use LTE modem in QMI mode for ... https://openwrt.org/docs/guide-user/network/wan/wwan/lt...
This is an example of switching modes for popular Quectel modems (don't expect these
proprietary commands to work on devices from other manufacturers):
Reset the modem to apply changes - power toggle it or send AT+CFUN=1,1 command.
It is worth checking the list of PDP Contexts (and APNs) configured on the modem. Use a
terminal program to query the modem with AT+CGDCONT? and observe the output. Example:
AT+CGDCONT?
+CGDCONT: 1,"IPV4V6","internet",...
+CGDCONT: 2,"IPV4V6","ims",...
+CGDCONT: 3,"IPV4V6","sos",...
Typically, but not always, context #1 is used for Internet connection. If it is not configured with
the correct information (IP () type and APN), it is recommended to set the desired
parameters. Example:
AT+CGDCONT=1,"IP","internet"
Replace IP () with IPV4V6 or IPV6 if necessary and use your APN instead of
internet .
While in the terminal, check the modem firmware version with ATI and see if there is an
upgrade available.
Router Preparation
1. Install OpenWrt
Router should be turned on and connected to the Internet to get the needed packages.
Please refer to: Internet Connection.
Required Packages
To make use of QMI protocol, packages kmod-usb-net-qmi-wwan (driver) and uqmi
(control utility) are needed. For MBIM protocol the packages are kmod-usb-net-cdc-mbim
and umbim .
2 of 12 7/1/24, 7:29 PM
[OpenWrt Wiki] How to use LTE modem in QMI mode for ... https://openwrt.org/docs/guide-user/network/wan/wwan/lt...
Optional Packages
1. Add protocol support to Luci - install luci-proto-qmi for QMI or luci-proto-mbim for
MBIM.
That is needed to interact with the modem using AT commands, for configuration purposes or
to be able to send/receive SMS and USSD. A terminal program like picocom will be needed
to actually send AT commands.
3. Install usb-modeswitch if that is needed for switching the modem into a “working” state.
More about: USB mode switch
4. Add support for the storage of your modem - refer to: USB Storage
Sample installation
1. Install all the needed packages:
opkg update
opkg install kmod-usb-net-qmi-wwan uqmi luci-proto-qmi kmod-usb-serial-
option picocom
opkg update
opkg install kmod-usb-net-cdc-mbim umbim luci-proto-mbim kmod-usb-seria
l-option picocom
If your have not enough space on your device - think of installing Rootfs on External
Storage (extroot)
Another option is Hardware memory upgrade. Refer to your router Forum thread for
possibility and instructions.
reboot
ls -l /dev/cdc-wdm0
If you have no such device - try to find out what went wrong:
3 of 12 7/1/24, 7:29 PM
[OpenWrt Wiki] How to use LTE modem in QMI mode for ... https://openwrt.org/docs/guide-user/network/wan/wwan/lt...
dmesg
or look info about USB devices and interfaces present in the system:
cat /sys/kernel/debug/usb/devices
Configuration
With LuCi web interface
[QMI]: Assuming luci-proto-qmi package is installed, navigate to Network → Interfaces,
then Add new interface… → Protocol: QMI Cellular
[Common]:
Select Interface “cdc-wdm0” in the drop-down. If it is not available there, check if the
corresponding driver ( kmod-usb-net-* ) is loaded, reset the modem if its mode has recently
been changed.
Enter your APN and select the IP () type as instructed by the carrier, don't set IP ()
type to IPV4V6 until you're 100% sure that provider supports IPv6 (), that is critical in QMI
mode.
4 of 12 7/1/24, 7:29 PM
[OpenWrt Wiki] How to use LTE modem in QMI mode for ... https://openwrt.org/docs/guide-user/network/wan/wwan/lt...
Add the same interface name to the existing “wan” firewall zone in /etc/config/firewall :
config zone
option name 'wan'
[...]
list network 'wwan'
device file path yes (none) QMI device node, typically /dev/cdc-wdm0
v6apn string no (none) APN for IPv6 () if different from IPv4 () APN
5 of 12 7/1/24, 7:29 PM
[OpenWrt Wiki] How to use LTE modem in QMI mode for ... https://openwrt.org/docs/guide-user/network/wan/wwan/lt...
autoconnect boolean no 1
plmn number no (none) First three digits are the mcc (mobile
country code) and the last three digits are
the mnc (mobile network code), for
example if plmn=338020, then the mcc is
338 and the mnc is 020
6 of 12 7/1/24, 7:29 PM
[OpenWrt Wiki] How to use LTE modem in QMI mode for ... https://openwrt.org/docs/guide-user/network/wan/wwan/lt...
No device given
Usage: uqmi <options|actions>
Options:
--single, -s: Print output as a single line (for
scripts)
--device=NAME, -d NAME: Set device name to NAME (required)
--keep-client-id <name>: Keep Client ID for service <name>
--release-client-id <name>: Release Client ID after exiting
--mbim, -m NAME is an MBIM device with EXT_QMU
X support
--timeout, -t response timeout in msecs
Actions:
--get-versions: Get service versions
--set-client-id <name>,<id>: Set Client ID for service <name> to
<id>
(implies --keep-client-id)
--get-client-id <name>: Connect and get Client ID for servi
ce <name>
(implies --keep-client-id)
--sync: Release all Client IDs
--start-network: Start network connection (use with
options below)
--apn <apn>: Use APN
--auth-type pap|chap|both|none: Use network authentication type
--username <name>: Use network username
--password <password>: Use network password
--ip-family <family>: Use ip-family for the connection (i
pv4, ipv6, unspecified)
--autoconnect: Enable automatic connect/reconnect
--profile <index>: Use connection profile
--stop-network <pdh>: Stop network connection (use with o
ption below)
--autoconnect: Disable automatic connect/reconnect
--get-data-status: Get current data access status
--set-ip-family <val>: Set ip-family (ipv4, ipv6, unspecif
ied)
--set-autoconnect <val>: Set automatic connect/reconnect (di
sabled, enabled, paused)
--get-current-settings: Get current connection settings
--get-capabilities: List device capabilities
--get-pin-status: Get PIN verification status
--verify-pin1 <pin>: Verify PIN1
--verify-pin2 <pin>: Verify PIN2
--set-pin1-protection <state>: Set PIN1 protection state (disable
d, enabled)
--pin <pin>: PIN1 needed to change state
--set-pin2-protection <state>: Set PIN2 protection state (disable
d, enabled)
7 of 12 7/1/24, 7:29 PM
[OpenWrt Wiki] How to use LTE modem in QMI mode for ... https://openwrt.org/docs/guide-user/network/wan/wwan/lt...
8 of 12 7/1/24, 7:29 PM
[OpenWrt Wiki] How to use LTE modem in QMI mode for ... https://openwrt.org/docs/guide-user/network/wan/wwan/lt...
ex <id>
--send-message <data>: Send SMS message (use options belo
w)
--send-message-smsc <nr>: SMSC number
--send-message-target <nr>: Destination number (required)
--send-message-flash: Send as Flash SMS
--wda-set-data-format <type>: Set data format (type: 802.3|raw-i
p)
--wda-get-data-format: Get data format
umbim help
Usage: mbim <caps|pinstate|unlock|connect|disconnect> [options]
Options:
-d <device> the device (/dev/cdc-wdmX)
-t <transaction> the transaction id
-n no close
-v verbose
uqmi tool can talk to MBIM modems using --mbim or -m option on the command line.
Manual validation
First check that everything works correctly:
and
9 of 12 7/1/24, 7:29 PM
[OpenWrt Wiki] How to use LTE modem in QMI mode for ... https://openwrt.org/docs/guide-user/network/wan/wwan/lt...
Many providers allow to use “any” APN, so-called “no-settings” connection. So, in many
cases “internet” would be just fine
--autoconnect key says that you want always be connected, once dongle is inserted to the
router and Cellular Network is in range. It will be kept after reboot.
In case you need additional authentication, please look at the possible arguments for the
uqmi utility:
If you have it (if not then install missing usb serial drivers), you can run in first terminal:
cat /dev/ttyUSB0
Additional Info
Some providers of the cellular internet use redirection to their pages for access activation,
when you are connected first time. I.e. YOTA in Russia.
10 of 12 7/1/24, 7:29 PM
[OpenWrt Wiki] How to use LTE modem in QMI mode for ... https://openwrt.org/docs/guide-user/network/wan/wwan/lt...
• Allow rebind responses RFC1918 (In LUCI goto Network → DHCP () and DNS () and
uncheck Rebind protection checkmark)
• Add Yota.ru domain to Whitelist (In LUCI goto Network → DHCP () and DNS () and
type in “yota.ru” without quotes to the Domain whitelist field.
Notes
Based on: This Article (http://intelnuc.blogspot.ru/2014/10/turn-your-old-wireless-router-into-
lte.html)
Troubleshooting
Everything is okay but modem doesn't establish connection. What can I try?
You may want to try adding the argument --get-client-id wds and --set-client-id when running
uqmi like:
usbmode -l
It should respond with a message about your USB device is detected. If it does, issue the
next command. If it doesn't, you might want to get help from the forum.
11 of 12 7/1/24, 7:29 PM
[OpenWrt Wiki] How to use LTE modem in QMI mode for ... https://openwrt.org/docs/guide-user/network/wan/wwan/lt...
usbmode -s
Then wait for the modem to get issued an IP () from your ISP ().
This website uses cookies. By using the website, you agree with storing cookies on your
computer. Also you acknowledge that you have read and understand our Privacy Policy. If
you do not agree leave the website. OK More information about cookies
Except where otherwise noted, content on this wiki is licensed under the following license:
CC Attribution-Share Alike 4.0 International
12 of 12 7/1/24, 7:29 PM