Use cdc_ether driver based dongles for WAN connection

This recipe explains how to setup and configure OpenWrt for using a USB 4G/3G modem based on cdc_ether driver.

This section has been tested on the following release:

root@OpenWrt:~# cat /etc/openwrt_release 
DISTRIB_ID='OpenWrt'
DISTRIB_RELEASE='SNAPSHOT'
DISTRIB_REVISION='r13212-300b7fe85a'
DISTRIB_TARGET='ath79/generic'
DISTRIB_ARCH='mips_24kc'
DISTRIB_DESCRIPTION='OpenWrt SNAPSHOT r13212-300b7fe85a'
DISTRIB_TAINTS=''

Before plugging in your USB Dongle, install the following packages either in Luci → System → Software or via commandline:

root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install kmod-usb-net-cdc-ether usb-modeswitch
Installing kmod-usb-net-cdc-ether (4.19.115-1) to root...
Downloading http://downloads.openwrt.org/snapshots/targets/ath79/generic/kmods/4.19.115-1-1eeead79165e05251a00d7cef457c9f2/kmod-usb-net-cdc-ether_4.19.115-1_mips_24kc.ipk
Installing kmod-mii (4.19.115-1) to root...
Downloading http://downloads.openwrt.org/snapshots/targets/ath79/generic/kmods/4.19.115-1-1eeead79165e05251a00d7cef457c9f2/kmod-mii_4.19.115-1_mips_24kc.ipk
Installing kmod-usb-net (4.19.115-1) to root...
Downloading http://downloads.openwrt.org/snapshots/targets/ath79/generic/kmods/4.19.115-1-1eeead79165e05251a00d7cef457c9f2/kmod-usb-net_4.19.115-1_mips_24kc.ipk
Installing usb-modeswitch (2017-12-19-f40f84c2-2) to root...
Downloading http://downloads.openwrt.org/snapshots/packages/mips_24kc/base/usb-modeswitch_2017-12-19-f40f84c2-2_mips_24kc.ipk
Installing librt (1.1.24-2) to root...
Downloading http://downloads.openwrt.org/snapshots/targets/ath79/generic/packages/librt_1.1.24-2_mips_24kc.ipk
Installing libusb-1.0-0 (1.0.22-2) to root...
Downloading http://downloads.openwrt.org/snapshots/packages/mips_24kc/base/libusb-1.0-0_1.0.22-2_mips_24kc.ipk
Configuring librt.
Configuring libusb-1.0-0.
Configuring kmod-mii.
Configuring usb-modeswitch.
Configuring kmod-usb-net.
Configuring kmod-usb-net-cdc-ether.

If the installation was successful, plugging the USB dongle will show a similar message in your logs:

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

To double-check, see the contents of /sys/kernel/debug/usb/devices to make sure the extra USB interfaces are detected by the drivers:

root@OpenWrt:~# cat /sys/kernel/debug/usb/devices

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 1
B:  Alloc=  0/800 us ( 0%), #Int=  1, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 4.19
S:  Manufacturer=Linux 4.19.115 ehci_hcd
S:  Product=EHCI Host Controller
S:  SerialNumber=1b000000.usb
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

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

T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 1
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 4.19
S:  Manufacturer=Linux 4.19.115 ehci_hcd
S:  Product=EHCI Host Controller
S:  SerialNumber=1b400000.usb
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

Rest of the configuration is same as configuring other network interfaces in OpenWrt:

Using luci: go to network → Interfaces → Add new interface... → Protocol : dhcp client, Interface: usb0

via commandline:

vi /etc/config/network 

config interface 'wanb'
        option ifname 'usb0'
        option proto 'dhcp'
        option metric '100'

Compared to PPP or QMI protocols there are no settings provided from OpenWRT for the dongle. All settings are made in the dongle itself.

Huawei provides a web interface called HiLink where you can check your 3G / 4G connection status, enter PIN code, enable data roaming or send and receive SMS.

To access it, go with your browser to hi.link, or in my case to 192.168.8.1.

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 '192.168.8.1'
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: 2021/06/22 08:57
  • by camarelli