learningbydeveloping.com

 

Learning by developing

...because practice teaches you

Reference: http://blog.josefsson.org/2011/05/22/openwrt-with-huawei-e367-and-tp-link-tl-wr1043nd/

 

During this mini tutorial we will explain how did we configure a Huawei E367. There are some other good tutorials around the network and I recommend you to take a look to them, but I still hope this can be useful. Let’s get started:

 

1st. We will need to install some libraries which are needed by the 3g dongle.

$opkg install kmod-usb-serial-option usb-modeswitch usb-modeswitch-data

 

Offline installation:

root@OpenWrt:~/packageConfigure3g# opkg install /root/usbboot/kmod-usb-serial_2.6.39.4-1_ar71xx.ipkInstalling kmod-usb-serial (2.6.39.4-1) to root…

Configuring kmod-usb-serial.

root@OpenWrt:~/packageConfigure3g# opkg install /root/usbboot/kmod-usb-serial-wwan_2.6.39.4-1_ar71xx.ipk

Installing kmod-usb-serial-wwan (2.6.39.4-1) to root…

Configuring kmod-usb-serial-wwan.

root@OpenWrt:~/packageConfigure3g# opkg install /root/usbboot/kmod-usb-serial-option_2.6.39.4-1_ar71xx.ipk

Installing kmod-usb-serial-option (2.6.39.4-1) to root…

root@OpenWrt:~/packageConfigure3g# opkg install /root/usbboot/libusb_0.1.12-2_ar71xx.ipk

Installing libusb (0.1.12-2) to root…

Configuring libusb.

root@OpenWrt:~/packageConfigure3g# opkg install /root/usbboot/usb-modeswitch_1.2.0-2_ar71xx.ipk

Installing usb-modeswitch (1.2.0-2) to root…

Configuring usb-modeswitch.

root@OpenWrt:~/packageConfigure3g# opkg install /root/usbboot/usb-modeswitch-data_20111023-1_ar71xx.ipk

Installing usb-modeswitch-data (20111023-1) to root…

Configuring usb-modeswitch-data.

 

 

2nd. Get the vendor information:

root@OpenWrt:~# cat /proc/bus/usb/devices 

T:  Bus=01 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#=  5 Spd=480  MxCh= 0

D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1

P:  Vendor=12d1 ProdID=1446 Rev= 0.00

S:  Manufacturer=Huawei Technologies

S:  Product=HUAWEI Mobile

C:* #Ifs= 2 Cfg#= 1 Atr=c0 MxPwr=500mA

I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage

E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

I:* If#= 1 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage

E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

 

Reference: http://www.draisberghof.de/usb_modeswitch/

3rd. Now we will have to create a file called usb-modeswitch.conf in /etc/ directory and configure it:

# cat usb-modeswitch.conf########################################################

# Huawei E367  (HSPA+ modem)

EnableLogging=1

 

DefaultVendor= 0x12d1

DefaultProduct=0x1446

 

TargetVendor=  0x12d1

TargetProductList=”1001,1406,140b,140c,1412,141b,14ac,1506″

 

CheckSuccess=20

 

MessageContent=”55534243123456780000000000000011060000000000000000000000000000″

 

4th. Load the usb-modeswitch.conf at every boot. Add the following line in rc.local(or in some other script) to switch the mode and take the interface up. If you have problems use “sleep 10” between both instructions:

#switches the modem mode to be able to use it as 3gusb_modeswitch -c /etc/usb-modeswitch.conf

ifup ppp0

 

The result of executing “usb_modeswitch -c /etc/usb-modeswitch.conf” command would be similar to:

root@OpenWrt:~# usb_modeswitch -c /etc/usb-modeswitch.conf 

Looking for target devices …

No devices in target mode or class found

Looking for default devices …

Found devices in default mode, class or configuration (1)

Accessing device 009 on bus 001 …

Getting the current device configuration …

OK, got current device configuration (1)

Using first interface: 0x00

Using endpoints 0x01 (out) and 0x81 (in)

Inquiring device details; driver will be detached …

Looking for active driver …

OK, driver found (“usb-storage”)

OK, driver “usb-storage” detached

 

SCSI inquiry data (for identification)

————————-

Vendor String: HUAWEI

Model String: Mass Storage

Revision String: 2.31

————————-

 

USB description data (for identification)

————————-

Manufacturer: Huawei Technologies

Product: HUAWEI Mobile

Serial No.: not provided

————————-

Setting up communication with interface 0

Using endpoint 0x01 for message sending …

Trying to send message 1 to endpoint 0x01 …

OK, message successfully sent

Resetting response endpoint 0x81

Resetting message endpoint 0x01

Device is gone, skipping any further commands

 

Checking for mode switch (max. 20 times, once per second) …

Searching for target devices …

Searching for target devices …

Searching for target devices …

Searching for target devices …

Searching for target devices …

 

Found target device, now opening

Found correct target device

 

Mode switch succeeded. Bye.

 

After this execution we can get the vendor info again to check that the mode has been changed:

T:  Bus=01 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#= 10 Spd=480  MxCh= 0D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1

P:  Vendor=12d1 ProdID=14ac Rev= 0.00

S:  Manufacturer=Huawei Technologies

S:  Product=HUAWEI Mobile

C:* #Ifs= 6 Cfg#= 1 Atr=c0 MxPwr=500mA

I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option

E:  Ad=81(I) Atr=03(Int.) MxPS=  64 Ivl=2ms

E:  Ad=82(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= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option

E:  Ad=83(I) Atr=03(Int.) MxPS=  64 Ivl=2ms

E:  Ad=84(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= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option

E:  Ad=83(I) Atr=03(Int.) MxPS=  64 Ivl=2ms

E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms

I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option

E:  Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms

I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option

E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms

I:* If#= 4 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage

E:  Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

I:* If#= 5 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage

E:  Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

E:  Ad=88(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

 

 

You might have problems with the DNS and in order to solve them you have to add a new script into the /etc/hotplug.d/iface/ directory. Let’s call it 01-reconnect-if-dns-is-broken. Its content would look like follow:

root@OpenWrt:~# cat 01-reconnect-if-dns-is-brokencase “${ACTION:-ifup}” in

ifup)

if grep -q 10.11.12.13 /tmp/resolv.conf.auto; then

(sleep 30 && ifdown wan && ifup wan) &

fi

;;

esac

 

Then just change its permissions to executable: “$ chmod u+x /etc/hotplug.d/iface/01-reconnect-if-dns-is-broken”.

 

Now we have part of the work already done. In order to complete this work we have to add the modem interface to /etc/config/network. My configuration looks like follows:

root@OpenWrt:~# cat networkConfig3gconfig ‘interface’ ‘ppp0′

option ‘ifname’ ‘ppp0′

option ‘proto’ ‘3g’

option ‘device’ ‘/dev/ttyUSB0′

option ‘apn’    ‘internet’

option ‘pincode’ ‘0000’

 

The configuration file itself looks self-explanatory to me, but please feel free to ask if something is not clear.

 

To finalize we will need to add, in the firewall, the ppp0 interface with the wan so that we can share the connection coming from ppp0 in the same way we would share the wan connection. To do this just configure the correct zone in /etc/config/firewall:

config ‘zone’option ‘name’ ‘wan’

option ‘input’ ‘REJECT’

option ‘output’ ‘ACCEPT’

option ‘forward’ ‘REJECT’

option ‘masq’ ‘1’

option ‘mtu_fix’ ‘1’

option ‘network’ ‘wan ppp0′

 

Now you can either reboot the router or restart the network, firewall and insert the module for the modem with “$ insmod usb-serial vendor=0x12d1 product=0x1506 maxSize=4096”

 

To check that the device you are using is the correct one use “$ gcom -d /dev/ttyUSB0 info”:

##### Wireless WAN Modem Configuration #####Product text:

====

 

Manufacturer: huawei

Model: E367

Revision: 11.807.XX.XX.XX

IMEI: XXX.X

+GCAP: +CGSM,+DS,+ES

OK

====

Manufacturer:           huawei

IMEI and Serial Number: XXXX..X

Manufacturer’s Revision:

11.807.05.10.

Hardware Revision:      NOT

Network Locked:         ERROR:

Customisation:          NOT SUPPORT

Band settings:          (NOT)

APN:                    ERROR:

##### END #####

 

 

I am not going to go further with the description of every single step, because Simon Josefsson already described it in his blog (http://blog.josefsson.org/2011/05/22/openwrt-with-huawei-e367-and-tp-link-tl-wr1043nd/) all the details perfectly and I consider that reinvent the wheel is not the best thing to do.

 

Have a nice week!

 

David.

Leave a Reply