# Laptop as 4G router



## balanga (Apr 14, 2017)

I'm interested in setting up a ThinkPad as a  4G router using a Huawei 4G modem.

Has anyone done this or know of a handy guide to set it up?

How can I tell if this would work?


----------



## Phishfry (Apr 15, 2017)

Sierra wireless modems can do this. I have set up a couple of headless devices with MC7355 and a Atheros wifi card for a homebrew MiFi.
The guides for doing this are pretty few and far.

Here he uses PPP and shows how to add VID and PID for unsupported devices.
https://technotation.com/2012/08/15/freebsd-and-mobile-broadband

I can only pull around 15Mb/s on testmy.net and that is close to the tower.
I am using an mvno reseller on ATT and I am getting throttled.($15/month@1gig)


----------



## balanga (Apr 18, 2017)

Following the link above I get

```
ls /dev/cuaU*
ls: No match.
```

I guess that means 11.0-RELEASE has no support for USB modems out of the box... Maybe I should try 12...???


----------



## balanga (Apr 18, 2017)

Not sure if this will show me how to set up my Huawei 4G modem...

https://gist.github.com/pvalkone/9170523

There seem to be a number of posts on how to set up USB modems but I can't see any consistancy in various approaches.  How do I tell if FreeBSD recognises that a USB modem has been attached? ie. how would it be addressed?  u3g0?


----------



## Phishfry (Apr 18, 2017)

That approach would work too. Instead of using devd I usually add the VID and PID and recompile. Then no need to kldload u3g or have it in rc.conf as it is automatically detected at bootup. All the PPP -ddial stuff looks like what I use.

The first place you need to start is determine your devices VID&PID and determine whether they are supported. Just like the link I provided shows.
usbconfig dump_device_desc


----------



## Phishfry (Apr 18, 2017)

balanga said:


> I guess that means 11.0-RELEASE has no support for USB modems out of the box..


How did you come to this conclusion? My Sierra modems are all USB interface. You see there are 3 flavors of MiniPCIe sockets.
mSATA
mPCIe
mPCIe with USB.
The Sierra modems use a mPCIe usb interface and answer on cuaU0.2 or cuaU0.3.
I know of no mobile broadband modem which is not USB interface. It is how they communicate with the SIM.

Please describe your broadband module in detail. Is it a MiFi hub or a USB modem on a stick. Perhaps an internal module?
Some devices might present themselves as an ue0 connection and can be treated differently. A quick test is plug and play. Plug it into a live system and see what it says onscreen. Does it mention ue0. Post the exact output of a hot plug.


----------



## balanga (Apr 18, 2017)

I reached that conclusion because of

```
ls /dev/cuaU*
ls: No match.
```

which made me think I needed to recompile the kernel... not something I wanted to do...

The modem I have is a USB modem which takes both a SIM card and a TF card, and is labelled 4G+ MEGAFON. It is an M150-2 modem, which is otherwise known as a Huawei E3372

I have added umodem_load="YES" to   /boot/loader.conf and this is part of dmesg


```
ugen0.3: <UPEK> at usbus0
info: [drm] Enabling RC6 states: RC6 on, RC6p off, RC6pp off
em0: link state changed to UP
ugen2.3: <HUAWEIMOBILE> at usbus2
umass0: <Mass Storage> on usbus2
umass0:  SCSI over Bulk-Only; quirks = 0x0000
umass0:7:0: Attached to scbus7
cd0 at umass-sim0 bus 0 scbus7 target 0 lun 0
cd0: <HUAWEI Mass Storage 2.31> Removable CD-ROM SCSI-2 device
cd0: Serial Number 0123456789ABCDEF
cd0: 40.000MB/s transfers
cd0: Attempt to query device size failed: NOT READY, Medium not present
cd0: quirks=0x10<10_BYTE_ONLY>
da0 at umass-sim0 bus 0 scbus7 target 0 lun 1
da0: <HUAWEI TF CARD Storage 2.31> Removable Direct Access SCSI-2 device
da0: Serial Number 0123456789ABCDEF
da0: 40.000MB/s transfers
da0: Attempt to query device size failed: NOT READY, Medium not present
da0: quirks=0x2<NO_6_BYTE>
(cd0:umass-sim0:0:0:0): READ(10). CDB: 28 00 00 00 8d c1 00 00 04 00
(cd0:umass-sim0:0:0:0): CAM status: SCSI Status Error
(cd0:umass-sim0:0:0:0): SCSI status: Check Condition
```


----------



## Phishfry (Apr 18, 2017)

OK first thing stand out to me is this
da0: <HUAWEI TF CARD Storage 2.31> Removable Direct Access SCSI-2 device
 This is a drive with the Windows drivers on it. It must be ejected. usbmodeswitch does this or note how your github guy does it in step 5.
AT^U2DIAG=0

But yes you must do either steps 1-4 with your VID&PID or compile.

Its really not that bad. I am sloppy and just use -GENERIC to add in devices.
After you edit the usbdevs and u3g.c files.
make buildkernel
make installkernel
reboot and enjoy.

Thing is after you switch the SCSI storage off the device may change VID&PID again in new mode. So you may need to add it twice.

VID=Vendor ID
PID=Product ID or IDProduct


----------



## Phishfry (Apr 18, 2017)

https://lists.freebsd.org/pipermail/freebsd-wireless/2016-April/006652.html
Here he gives details on that modem. This is one of those sticks that has a webserver built in. Yikes.


----------



## balanga (Apr 18, 2017)

To be quite honest I'm having a hard making sense of the different methods of getting things configured. 

What do I need to put in /boot/loader.conf and do I need a /etc/devd/huawei-3372.conf?

And how do I automatically disable the virtual CD-ROM and SD card reader? And I'm completely confused about what you mean about having a webserver built-in...


----------



## Phishfry (Apr 18, 2017)

You defiantly picked a tough one. My first instinct would be checkout your Mint installation and install modemmanager-gui. It has a whole host of information about your device and will help you. You may even be able to install putty and use ttyUSB0 to send the commands to disable SCSI-Drive as per those instructions from github. Once that is done recheck your VID and PID in Mint and return to FreeBSD. See if your usbconfig dump_device_desc is showing the same VID&PID as before. Compare the two OS. If the same then either add to u3g&usbdevs and recompile or deal with devd. With a recompile all you need to do is add PPP settings to rc.conf as the device is detected correctly. Not a jury rig.

You generally need to have an active data SIM installed to get this going. Ubuntu/Mint is good for checking this. All you need to do is edit your broadband connection and add APN. Get it working there first and figure out FreeBSD.

You may need to switch it to this VID and PID like the mailing list post.
idVendor = 0x12d1  idProduct = 0x14dc
Maybe you could switch it with Mint modemmanager(mm_cli) and then it will be detected with FreeBSD. No compile or devd.


What is your current VID & PID in FreeBSD?


----------



## Phishfry (Apr 18, 2017)

About my webserver remarks. Note the above quoted from the mailing list post.
"An admin HTTP-page can be found from 192.168.1.1"

To present a web landing page a web server must be installed on the 4G module. Which also means it has a Host OS. Probably running a 4+ year old web server. Real secure I bet. AT commands have been around forever. Whats wrong with them? That's what Sierra uses. They do have a Gobi API which allows programming features at the OS level. So something to exploit there too.


----------



## balanga (Apr 19, 2017)

Phishfry said:


> You defiantly picked a tough one. My first instinct would be checkout your Mint installation and install modemmanager-gui. It has a whole host of information about your device and will help you. You may even be able to install putty and use ttyUSB0 to send the commands to disable SCSI-Drive as per those instructions from github. Once that is done recheck your VID and PID in Mint and return to FreeBSD. See if your usbconfig dump_device_desc is showing the same VID&PID as before. Compare the two OS. If the same then either add to u3g&usbdevs and recompile or deal with devd. With a recompile all you need to do is add PPP settings to rc.conf as the device is detected correctly. Not a jury rig.
> 
> You generally need to have an active data SIM installed to get this going. Ubuntu/Mint is good for checking this. All you need to do is edit your broadband connection and add APN. Get it working there first and figure out FreeBSD.
> 
> ...




I'm currently using the USB under Windows and see that it installed something called *Mobile Partner* (from Huawei) which is stored on the modem in a CDFS file system. There are also an installation for Linux which I have not attempted to use yet. Maybe the source can be obtained to develop a FreeBSD version.

I did notice that the connection type is NDIS rather than modem... does that mean it isn't using PPP? If so, should I regard the device as a NIC rather than a modem? On Windows I did not need to edit the connection or add the APN... presumably the info on the SIM card was sufficient.

The VID/PID is correct, although I'm not sure how FreeBSD uses this info....

Another interesting link:-

http://www.gnuton.org/blog/2015/07/huawei-e3372/


----------



## Phishfry (Apr 19, 2017)

You should search the pfSense forum as well for that model number. There will be more relevant info there.
Here is a quick example:
https://forum.pfsense.org/index.php?topic=103328.0


----------

