User Tools

Site Tools


How To Use LTE modem in QMI mode for WAN connection

This recipe explains how to setup and configure OpenWrt for using a USB LTE/3g/UMTS-modem for WAN connection, using QMI interface. You may want to checkout the Multiwan package to use this simultaneously with other connections to the internet.

:!: All recent information is valid for BarierBreaker release and later. Not tested on AA or elder.


Many modern USB dongles could perform in different ways.

If your modem provides only AT command interface - please refer to Use 3g/UMTS USB Dongle for WAN connection.

If it is possible to switch your modem to provide NDIS interface - then this article if for YOU.

FIXME Add Speed and Performance test results on Modem mode and QMI mode.

:!: 8-) Subjective, solution based on NDIS (QMI mode) works much stable. Faster reconnect. Easy to control and monitor.

Modem Preparation

We need to switch modem to provide native NDIS interface instead of Modem interface.

:!: Please read about AT commands for your modem.

Here would be an Example for Huawei E392 LTE/3G dongle.

Connect modem to PC and get access to it with any COM terminal:

Send: AT

Recieve: 1:MODEM
Recieve: 2:PCUI 
Recieve: 3:DIAG
Recieve: 4:PCSC
Recieve: 5:GPS
Recieve: 6:GPS CONTROL
Recieve: 7:NDIS
Recieve: D:MMS
Recieve: E:PC VOICE
Recieve: A1:CDROM
Recieve: A2:SD
Recieve: OK

Recieve: A1,A2;1,2,3,A1,A2
Recieve: OK

Recieve: OK
AT^SETPORT=? - Lists the Available interfaces and their numbers

AT^SETPORT? - Show current configuration

AT^SETPORT="A1;2,7" - Sets configuration.

Modem configuration is splitted into 2 parts: before ";" and after.

Once modem is plugged-In - it declares itself in first configuration (normally with at least A1 - virtual CD drive with Drivers and application). If the drivers are installed - they see the modem and issue a special command to switch to "working" configuration - this is 2,7 interfaces in this example.

:!: Never turn Off PC interface!!! Otherwise you'd not have ability to access modem with terminal and change the config.

Optionally You can add more interfaces to be active i.e. SD card (Change to A1;2,7,A2), but this is out of scope of this article.

Once you've done - you can disconnect modem from the PC and connect it to the router.

Router Preparation

1. Install OpenWRT

2. Complete Steps OpenWrt Configuration

Router should be turned on and connected to the Internet to get the needed packages.Please refer to: Internet Connection.

Required Packages

  • usb-modeswitch - It will automatically issue a "special" command to the modem for switching it into the "Working" state
  • kmod-mii - Mii driver
  • kmod-usb-net - Usb to Ethernet
  • kmod-usb-wdm
  • kmod-usb-net-qmi-wwan
  • uqmi - Control utility

opkg update
opkg install usb-modeswitch kmod-mii kmod-usb-net kmod-usb-wdm kmod-usb-net-qmi-wwan uqmi

Optional Packages

1. Add support for PC Interface (ttyUSB0)

  • kmod-usb-serial-option
  • kmod-usb-serial
  • kmod-usb-serial-wwan

opkg update
opkg install kmod-usb-serial-option kmod-usb-serial kmod-usb-serial-wwan

2. Add support for FlashCard of your dongle - refer to: USB Storage


1. Install all the needed packages

opkg update
opkg install usb-modeswitch kmod-mii kmod-usb-net kmod-usb-wdm kmod-usb-net-qmi-wwan uqmi

:!: If your have not enought 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.

2. Reboot the router


3. Check that everything is OK and You got new device:

ls -l /dev/cdc-wdm0

crw-r--r--    1 root     root      180, 176 Oct  1 12:03 /dev/cdc-wdm0

If you have no such device - try to findout what went wrong:

try dmesg to read kernel logs on USB init

or look info about USB devices and interfaces present in the system:
cat /sys/kernel/debug/usb/devices

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  3 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=12d1 ProdID=1506 Rev= 0.00
S:  Manufacturer=Huawei Technologies
S:  Product=HUAWEI Mobile
C:* #Ifs= 3 Cfg#= 1 Atr=c0 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=02 Driver=option
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms
I:* If#= 1 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=01 Prot=09 Driver=qmi_wwan
E:  Ad=82(I) Atr=03(Int.) MxPS=  64 Ivl=2ms
I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=08 Driver=qmi_wwan
E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms

See Troubleshooting Section of this page for more information.


Interface configuration

First check that everything works correctly:

root@OpenWrt:~# uqmi -d /dev/cdc-wdm0 --get-data-status
root@OpenWrt:~# uqmi -d /dev/cdc-wdm0 --get-signal-info
        "type": "lte",
        "rssi": -71,
        "rsrq": -9,
        "rsrp": -94,
        "snr": 70
To start the internet connection - issue a command:
uqmi -d /dev/cdc-wdm0 --start-network internet --autoconnect
Where "internet" is the APN of your provider.

:!: Many providers allow to use "any" APN, so-called "no-settings" connection. So, in many cases "internet" would be just fine

Check the status:

uqmi -d /dev/cdc-wdm0 --get-data-status

–autoconnect key says that you want always be conencted, once dongle is inserted to the router and Celular 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:

  --start-network <apn>:            Start network connection (use with options below)
    --auth-type pap|chap|both|none: Use network authentication type
    --username <name>:              Use network username
    --password <password>:          Use network password
    --autoconnect:                  Enable automatic connect/reconnect
  --stop-network <pdh>:             Stop network connection (use with option below)
    --autoconnect:                  Disable automatic connect/reconnect

Network configuration

Now you should add new Interface to /etc/config/network

config interface 'wwan'
        option ifname 'wwan0'
        option proto 'dhcp'
You can do this using the vi text editor, but if you're not comfortable with that, point your browser to again, choose Network → Interfaces and click Add new interface.

Write wwan as the name of the interface and make it cover the wwan0 interface. Choose DHCP client as the protocol.

FIXME Insert a screenshot of LUCI add Interface. I have not enought rights.

Firewall configuration

The only thing that is left - Add wwan interface to WAN zone

Using LUCI:

  • go to Network → Firewall, scroll down to wan and click the Edit button
  • add a checkmark to the wwan box under Covered networks heading, click Save & Apply

:-D That's It! 8-)

FIXME Insert a Screen Shot from LUCI.

Additional Info

Some providers of the celular internet use redirection to their pages for access activation, when you are connected first time. I.e. YOTA in Russia.

Normally this would be blocked by dnsmasq:

Jan 18 14:36:49 OpenWrt daemon.warn dnsmasq[1325]: possible DNS-rebind attack detected:

You have 2 options:

  • Allow rebind responses RFC1918 (In LUCI goto NetworkDHCP and DNS and uncheck Rebind protection checkmark)
  • Add domain to Whitelist (In LUCI goto NetworkDHCP and DNS and type in "" without quotes to the Domain whitelist field.

Save & apply


Based on: This Article


My router is not detecting the dongle. What should I do?

Try the following commands:

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.
usbmode -s
Then wait for the dongle to get issued an IP from your ISP.

I have to issue usbmode -l and usbmode -s every time I reboot my router to detect my USB device. How can I automate it?

Include the following codes into /etc/rc.local just before exit 0:

/sbin/usbmode -l
/bin/sleep 2
/sbin/usbmode -s

I am using 'huawei_cdc_ncm' module and the /dev/cdc-wdm0 does not respond. What do I do?

This is probably related to ticket #18673 ( You should be able to use the modem by starting ndis manually by sending the following to /dev/ttyUSB1

It is possible to automate this task using hotplug Below are some scripts fetched from Do not forget to modify them to your needs. The scripts are for huawei modems obviously.


#!/bin/sh /etc/rc.common

# Interface name from /etc/config/network
# Your APN:


start() {
        if [ -e ${DEVICE} ]; then
                echo -ne "AT^NDISDUP=1,0\r\n" > ${DEVICE}
                sleep 3
                echo -ne "AT^NDISDUP=1,1,\"${APN}\"\r\n" > ${DEVICE}
                sleep 3
                ifup $IFNAME
                echo "No such device ${DEVICE}" | logger -t "ncm-network[$$]" -p info

stop() {
        if [ -e ${DEVICE} ]; then
                ifdown $IFNAME
                sleep 3
                echo -ne "AT^NDISDUP=1,0\r\n" > ${DEVICE}
                echo "No such device ${DEVICE}" | logger -t "ncm-network[$$]" -p info



# Uncomment set line below and check your modalias I from tmp file

#set >> /tmp/ncm-network.debug

if [ "${MODALIAS}" != "${MODEM_ID}" ]; then
        exit 0

case "$ACTION" in
                SYSTEM_UPTIME=$(cat /proc/uptime | awk -F"\." '{ print $1 }')
                if [ "${SYSTEM_UPTIME}" -gt 60 ]; then
                sleep ${PAUSE} && \
                echo "Start modem ${MODEM_ID}" | logger -t "hotplug[$$]" -p info && \
                /etc/init.d/ncm-network start
                } &
                echo "Stop modem ${MODEM_ID}" | logger -t "hotplug[$$]" -p info
                /etc/init.d/ncm-network stop

Some modems does not reconnect after loosing connection. Here is a connection check sh script which checks if it can ping remote servers with time intervals. If all pings fail, it tries to start the network by executing /etc/init.d/ncm-network start


# Enter the FQDNs you want to check with ping (space separated)
# Script does nothing if any tries to any FQDN succeeds

# Sleep between ping checks of a FQDN (seconds between pings)
SLEEP=3                         # Sleep time between each retry
RETRY=3                         # Retry each FQDN $RETRY times
SLEEP_MAIN=60                   # Main loop sleep time

  for NAME in $FQDN; do
    for i in $(seq 1 $RETRY); do
      ping -c 1 $NAME > /dev/null 2>&1
      if [ $? -eq 0 ]; then
        return 0
      sleep $SLEEP
  # If we are here, it means all failed
  return 1

while true; do
  if [ $? -ne 0 ]; then
    /etc/init.d/ncm-network start
  sleep $SLEEP_MAIN

doc/recipes/ltedongle.txt · Last modified: 2017/03/24 19:47 by Jalakas