Huawei modem

From B-Wiki
Revision as of 15:13, 10 May 2020 by Tinel (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

model: e3131

Original post

https://forum.netgate.com/topic/99859/pfsense-2-3-and-huawei-e8372-making-it-work https://zedt.eu/tech/hardware/switch-huawei-e3131-hilink-modem-mode/

Change it to modem only

Latest Huawei 3G/4G modems come with firmware that implements a feature Huawei calls “HiLink“, transforming the classical PPP dial-up connection to an always-on wireless broadband.

This feature is highly useful on Windows operating systems, but will add an extra level of complexity to using the modem on Linux or in a 3G/4G capable router.

To complicate matters even more, the classical AT^U2DIAG command to disable certain features doesn’t work on (some of) these new modems, like the E3131 I had to deal with. Fortunately, a workaround exists (for now).

To switch an E3131 to modem mode (and disable Hilink), start by connecting it to a computer (Windows will be required to simplify the procedure) and install its driver (and bundled software). When done, check that the necessary device drivers are installed correctly.

From the above list you’ll need to remember the COM port number for the 3G PC UI Interface (in my case COM12) baudrate: 9600 3G PC UI Interface Start your favourite terminal program (I prefer PuTTY) and connect it to the COM port listed above

Once connected type in AT – if everything works the modem will answer back with OK. The modem might also periodically output some debug information which is safe to ignore.

Use the AT^SETPORT command to find the current configuration mode or set a new one. Note down the current mode to be able to return to Hilink / defaults later.

AT^SETPORT? – will display the current mode AT^SETPORT=? – will display available modes AT^SETPORT="A1,A2;1,2,3" – will set modem only AT^SETPORT="A1,A2;1,16,3,2,A1,A2" – will set a different mode (this is my modem’s default mode) Unplug and re-plug the modem for the change to take effect. Your system will re-detect the device and reinstall the drivers. You can now use it as a proper modem (PPP). Share:

Adapted for E3131 below

For my home network I like using a small nano PC by Foxconn as my router. The down side is that the nano only has a single Ethernet port. My internet is an LTE connection and the carrier provides one of the new “smart” modems in my case the Huawei E8372. Because of the lack of a second Ethernet port and the risk of double NAT I want the LTE modem to be directly connected to the pfSense PC. As the modem defaults to storage mode it was an interesting journey to get pfSense to make use of it. I am no expert in pfSense or FreeBSD and have trawled the forums and some websites for various bits I cobbled together into something that works for me. It may not be the best way so your mileage may vary. I just wanted my LTE modem to work with pfSense.

Some notes on the setup

pfSense does not like it when there are not two network adapters. You will be constantly stuck and the interfaces configuration prompt. I resolved this by using a USB Ethernet adapter for the curious Trendnet TU3-ETG. I enable the Secure Shell and use Bitvise to SSH to the pfSense PC so I can easily copy and paste the contents of the configuration files.

What is needed:

usb_modeswitch (This needs to be installed from the FreeBSD repositories as it's not included in pfSense.) Shellcmd (Available via the pfSense package manager) Text editor (Nano is a nice editor you can install it from the shell with pkg install nano)

You will install two packages (Three if you want nano) You will create two files; lte.cfg for the modem configuration & lte.sh which will be used by Shellcmd

usbconfig dump_device_desc

Install usb_modechange

Beware this is not a supported configuration and this may break with updates but it is the only way I found to install usb_modeswitch

From the shell run the command below and install the package:

pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/release_3/All/usb_modeswitch-2.5.2.txz

Install Shellcmd

From the web GUI go to System / Package Manager then select Available Packages find Shellcmd and install it.

Create lte.cfg file for usb_modeswitch configuration for E8372

Use your prefered text editor to create the modem configuration file in cd /usr/local/sbin I named the file lte.cfg

Modem configuration for the E8372 was found here http://www.draisberghof.de/usb_modeswitch Modem configuration for the E3131 was found here http://forums.debian.net/viewtopic.php?f=7&t=112944

Modem Configuration copy the text below and paste it in the lte.cfg file.

#Huawei E3131-2

DefaultVendor= 0x12d1
DefaultProduct=0x14fe

TargetVendor=  0x12d1
TargetProduct= 0x1506

MessageContent="55534243123456780000000000000011062000000101000100000000000000"
NoDriverLoading=1


###################################################
#Huawei E8372
#Contributed by: ozonejunkie

DefaultVendor= 0x12d1
DefaultProduct=0x1f01

TargetVendor=  0x12d1
TargetProduct= 0x14db

MessageContent="55534243123456780000000000000a11062000000000000100000000000000"
NoDriverLoading=1
####################################################

Create lte.sh file for Script to modeswitch modem

The code to correctly switch your modem you can put a script file in /etc/rc.d. I named mine lte.sh remember to chmod +x the lte.sh file

#!/bin/sh
/usr/local/sbin/usb_modeswitch -c /usr/local/sbin/lte.cfg
sleep 5

Any shell script can be placed in the /usr/local/etc/rc.d/ directory. The filename must end in .sh and it must be marked as executable (chmod +x lte.sh).

Configure Shellcmd

Via the web GUI go to the Services menu and select Shellcmd & click Add

Shellcmd Configuration

Command: /etc/rc.d/lte.sh Shellcmd Type: earlyshellcmd Description: LTE Start Click Save

You should now be able to configure the interface via the interfaces menu.