Use cdc_ether driver based dongles for WAN connection

This recipe explains how to setup and configure OpenWrt for using a USB 3G/4G/5G modem operating in ECM mode supported by cdc_ether driver.

The same applies to external modems connected to USB ports and internal models installed into M.2(NGFF) or mPCIe slots.

Before using your USB modem, install packages either in Luci → System → Software or via command line:

root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install kmod-usb-net-cdc-ether

Some [older] modems may additionally need usb-modeswitch package. It is used to switch the modem into a “working” mode. More about: USB mode switch

If the installation was successful, plugging the USB dongle in or restarting the internal modem will show similar messages in the log:

root@OpenWrt:~# dmesg
[  208.424433] usb 1-1: new high-speed USB device number 3 using ehci-platform
[  209.251501] usb 1-1: USB disconnect, device number 3
[  209.652469] usb 1-1: new high-speed USB device number 4 using ehci-platform
[  210.060700] cdc_ether 1-1:1.0 usb0: register 'cdc_ether' at usb-1b000000.usb-1, CDC Ethernet Device, d2:60:c8:b6:65:46

Note the interface name (usb0) mentioned on the last line, it will be used later. For another modem the name could be eth2 or something like that.

It is worth to check the output of cat /sys/kernel/debug/usb/devices to make sure the necessary drivers are loaded for USB interfaces:

root@OpenWrt:~# 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=02(comm.) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=12d1 ProdID=14dc Rev= 1.02
S:  Manufacturer=HUAWEI
S:  Product=HUAWEI Mobile
C:* #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=06 Prot=00 Driver=cdc_ether
E:  Ad=83(I) Atr=03(Int.) MxPS=  16 Ivl=32ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether
E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 2 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=(none)
E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=125us


Some modems require manual switching into ECM mode by using AT commands. This could be done on any computer prior to installation or on the router directly using a terminal application like picocom. More about: sending AT commands from the router.

A few extra packages need to be installed in order to “talk” with the modem from the router:

opkg install kmod-usb-serial-option picocom

This is an example for popular Quectel modems (don't expect these proprietary commands to work on devices from other manufacturers):

AT+QCFG="usbnet"	# check the current mode
AT+QCFG="usbnet",1	# set ECM mode

It is worth checking the APN(s) configured on the modem. If the modem offers its own web interface, use it for this task. Alternatively, if the modem has serial (ttyUSB) interface(s) exposed, use a terminal program to query the modem with AT+CGDCONT? and observe the output. Example:

+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:


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.

Navigate to Network → Interfaces → Add new interface... → Protocol: DHCP Client, Interface: “usb0” (or another name found earlier)

Assign the firewall zone (wan) on 'Firewall Settings' tab.

Open Advanced Settings and make sure that both “Use default gateway” and “Use DNS servers advertised by peer” checkboxes are selected.

Alternatively you can edit the configuration files with any text editor like vi or nano:

  • add a new interface in /etc/config/network:
config interface 'wwan'
        option proto 'dhcp'
        option ifname 'usb0'
  • add the same interface name to the “wan” firewall zone in /etc/config/firewall:
config zone
    option name 'wan'
    list network 'wwan'

For some modems adding an interface will be sufficient, but others may need an APN provisioned, it is also sometimes necessary to send a special “autodial” command to the AT command port. It is recommended to install additional packages picocom kmod-usb-serial-option and consult AT Commands Guide for the given modem.

If the modem needs a “dial” command sent on each connection attempt, then it is worth trying to configure the NCM interface instead.

Compared to PPP or QMI protocols there are no settings provided from OpenWrt for the modem. All the configuration changes are made on the modem itself, typically by using AT commands.

Alternatively, some manufacturers (Huawei, ZTE, etc) provide a web interface where you can enter your APN, check connection status, enter PIN code, enable data roaming, change bands, send/receive SMS, etc. As an example, with Huawei modem in HiLink mode the interface is accessible via or (that is a default IP address).

If the request is blocked, it may be that your firewall does not allow it. In this case you can define a rule like the following:

config rule
	option name 'Allow-HiLink'
	option src 'lan'
	option proto 'tcp'
	option target 'ACCEPT'
	option family 'ipv4'
	option dest 'wan'
	list dest_ip ''
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.More information about cookies
  • Last modified: 2024/04/01 21:11
  • by andrewz