# Laptop as 4G router



## balanga (Aug 8, 2017)

I'm interested in turning my laptop into a 4G access point for the Internet, ie I want to be able to route between WWAN and WLAN. 

Has anyone attempted to get this working, or know of any Howtos?


----------



## SirDice (Aug 8, 2017)

It's not any different from a basic internet router configuration, only the interfaces themselves are configured slightly different. The way you would "share" the internet is exactly the same, set up NAT on the external interface, enable routing and allow traffic on the internal interface(s). The fact the interfaces are ethernet, wireless or 4G is pretty much irrelevant.


----------



## balanga (Aug 9, 2017)

The problem is getting the WWAN interface working... I have a choice of using a 4G/LTE modem or or the onboard WWAN card but getting either working with FreeBSD has proved to be an insurmaountable barrier so far.


----------



## ekingston (Aug 9, 2017)

You may find you get a better response if you identify specifics of the devices you are having trouble with. Make, manufacturer, model. Also, including the relevant dmesg output that shows what FreeBSD actually sees of the devices can help.

Personally, I have no knowledge of WWAN driver support in FreeBSD.



balanga said:


> The problem is getting the WWAN interface working... I have a choice of using a 4G/LTE modem or or the onboard WWAN card but getting either working with FreeBSD has proved to be an insurmaountable barrier so far.


----------



## SirDice (Aug 9, 2017)

balanga said:


> The problem is getting the WWAN interface working...


Focus on that for the time being. Once you get it working it's not going to be difficult to set up the internet sharing. There are plenty of examples on how to do that. 

And I agree with ekingston, post some details of the card and the specific problems you're running into so we'll be able to help out with it.


----------



## balanga (Aug 9, 2017)

ekingston said:


> You may find you get a better response if you identify specifics of the devices you are having trouble with. Make, manufacturer, model. Also, including the relevant dmesg output that shows what FreeBSD actually sees of the devices can help.



I have an  IBM/Lenovo ThinkPad X61 in which I have inserted a SIM. I have no idea how FreeBSD would identify this. What would I look for in dmesg? If FreeBSD does see it, would it identify it as a COMPORT, modem PORT, PCI device or what?


----------



## Phishfry (Aug 9, 2017)

Most modems would show up under `usbconfig` and you would need to see if its supported from that output.


----------



## balanga (Aug 9, 2017)

Phishfry said:


> Most modems would show up under `usbconfig` and you would need to see if its supported from that output.



What about the on board SIM card? Is there any way to tell whether FreeBSD sees the SIM card?


----------



## Phishfry (Aug 9, 2017)

It is transparent to FreeBSD. The SIM does not matter. The modem talks to the SIM via USB.

Now there are limitations. For example in US we have CDMA networks and GSM and the SIMs are different.
So for example for Sierra modems they use a firmware change to switch between an GSM carrier (ATT)
versus a CDMA carrier like Verizon.
So the end user can change carriers, if you sign up for the Sierra Source website and download the firmware.
(Windows Required)
This is just an example of what is at hand for a Sierra MC73xx module. There are literally hundreds of others.
Most can't be switched from GSM to CDMA

Some will be carrier locked too, so you need to investigate the module in your laptop and determine the carrier.

You might be trying to connect to a GSM network with a CDMA card or some other gotcha.

Why dont you post output from usbconfig for help.

Once you can talk to the modem with `cu` then you can query the SIM


----------



## balanga (Aug 9, 2017)

Phishfry said:


> It is transparent to FreeBSD. The SIM does not matter. The modem talks to the SIM via USB.



I'm confused by this... I'm not using a USB modem. The SIM is directly inserted onto the motherboard. Would I still address it using `cu`?


----------



## Phishfry (Aug 9, 2017)

If you look at the MiniPCIe slot spec it has 3 interface types.
MiniPCIe
MiniPCIe with USB
mSata

The miniPCIe slots are for wifi and tv tuners
miniPCIe with USB is for broadband modems
mSata is for storage devices

So the Sim talks to the modem through USB no different than an external modem.
So `cu -l /dev/cuaU0.2` for me. You need to find the command channel.
*IF* it is supported.


----------



## tingo (Aug 14, 2017)

Also: on (at least some) laptop models (Yes, some ThinkPads too) the SIM card slot is there, but there might not be a 4G / WWAN mini-PCIe card in the laptop. So it is good to verify that this card is there. For the ones I have been in contact with, all have shown up as a usb device (as already mentioned in this thread. There might be other solutions (than usb) that I haven't seen.


----------



## balanga (Aug 15, 2017)

Phishfry said:


> Most modems would show up under `usbconfig` and you would need to see if its supported from that output.


`usbconfig`

```
ugen4.2: <Mini Card Sierra Wireless, Incorporated> at usbus4, cfg=0 md=HOST spd=FULL(12Mbps) pwr=ON (0mA)
```

The system has as Sierra Wireless MC 8775 card, and I've inserted a Vodafone SIM card as I believe the system is locked to the Vodafone network.

How would I change this to access the device?
`cu -l /dev/cuaU0.2`

I tried `cu -l /dev/cuaU4.2` but got 'No such file or directory'.

I have ordered a Sierra AirPrime MC7710 4G/LTE card, which will hopefully install although I'm not sure if FreeBSD supports it...


----------



## tingo (Aug 15, 2017)

Di you try the u3g(4) driver?


----------



## balanga (Aug 15, 2017)

tingo said:


> Di you try the u3g(4) driver?


Now I get 
`cu -l /dev/cuaU0.2`

```
Connected
>ATI
Sierra Wireless, Inc.
MC8775
APP1

OK
```

So definitely some progress...


----------



## Phishfry (Aug 16, 2017)

I can help from here. The MC7710 was a good bet if you got the bands right.

So LTE works in bands.
https://en.wikipedia.org/wiki/LTE_frequency_bands
I use MC7700 it uses ATT as a carrier and uses B2.
The MC7710 is for TMobile here in US and uses another band?
MC7750 is the CDMA version for Verizon.

I call all these modems MC77xx. There is also an zif cable embedded version called EM7700
So all these modules needed separate frequency "Bands" for the carrier.

The next model in the Sierra line was the MC73xx.
This module has several frequencies and is switched by firmware flash. can do GSM and CDMA

I have found that my MC7700 works on TMobile LTE network too.

MC8775 was one of the first sierra modems. It will work but only in 3G mode on GSM.
It was my first cell modem in 2011.


----------



## Phishfry (Aug 16, 2017)

First things first is to put the newest firmware on it. The Sierra Source site has the latest. It is tough to log in to it and make an account.
You have to a your own .com mail address. Its funky but once you have a login they have a bunch of stuff.
Ironically i could hyperlink to the file as it is not locked down correctly. I care not to.
You should get an account and update both MC8775 and MC7710 firmware.
The MC8775 is from 2010 and I bet the firmware is that old.

Can you try AT!GSTATUS?
Once you get a Sierra Source account they have the pdf AT Command Guides with all settings. Very well documented.


----------



## Phishfry (Aug 16, 2017)

Another thing to consider is, while updating the modem is fine, you need to think about the antenna's.

LTE is 700mhz while 3G is usually around 1800mhz. This is just in my area. Yours may vary.

My Dells have been fine with the stock antenna but they are IvyBridge circa 2012 and LTE was more prevalent.


----------



## balanga (Aug 16, 2017)

This MC8775 is in a ThinkPad X61 and is probably 10 years old. If I can get it working I'll try replacing it with a 4G modem - MC7710.

AT!GSTATUS resulted in

OK


----------



## Phishfry (Aug 16, 2017)

Here is mine on MC73xx


```
at!gstatus?
!GSTATUS:
Current Time:  1767       Temperature: 30
Bootup Time:   0       Mode:        ONLINE       
System mode:   LTE           PS state:    Attached   
LTE band:      B2             LTE bw:      15 MHz
LTE Rx chan:   925       LTE Tx chan: 18925
EMM state:     Registered         Normal Service
RRC state:     RRC Idle     
IMS reg state: No Srv        

RSSI (dBm):    -80       Tx Power:    0
RSRP (dBm):    -110       TAC:         5403 (21507)
RSRQ (dB):     -13       Cell ID:     00E06B07 (14707463)
SINR (dB):      2.2


OK
```


```
ati
Manufacturer: Sierra Wireless, Incorporated
Model: MC7354
Revision: SWI9X15C_05.05.16.02 r21040 carmd-fwbuild1 2014/03/17 23:49:48
MEID: 3592xxxxxxxxxx
ESN: 12801654587, 80193F3B
IMEI: 3592xxxxxxxxx
IMEI SV: 11
FSN: J8511200850410
+GCAP: +CGSM
```


----------



## Phishfry (Aug 16, 2017)

MC7710 might not work due to IBM laptops have bios locks for expansion cards.
They use a whitelist where only modules on the list will work.
On my HP I had to use a hacked bios to work with general purpose hardware.
Otherwise you go down the rathole of finding an IBM FRU Sierra MC7710.

Hopefully I am wrong, I think you might want to investigate the MiniPCIe situation via web search for that model.
edit:http://www.thinkwiki.org/wiki/Middleton's_BIOS


----------



## balanga (Aug 17, 2017)

Is it possible to check if a card is locked to a particular network?


----------



## tingo (Aug 17, 2017)

Try `at^cardlock?`. There is a whole series of AT commands dealing with SIM cards and 3G / 4G modems.


----------



## balanga (Aug 18, 2017)

I couldn't get that to work but came across an AT Command Reference which I'll try and study.

Unfortunately the only command which seems to generate a responce other OK or ERROR is  `ATI`...

Could it be password protected or locked in some way?


----------



## Phishfry (Aug 18, 2017)

I believe you are on a limited AT command prompt made for application interface.(See APP1 up there)
Called GOBI interface.

You need to check the higher ports for the full extended command prompts.
cuaU0.3, cuaU0.4,cuaU0.5


----------



## Phishfry (Aug 18, 2017)

Just a heads up for your MC7710. They run in two modes>DIP and QMI
QMI is proprietary Qualcomm Modem Interface. It is not supported by FreeBSD and the modem will not work
DIP is DirectIP for PPP which does work.

There are 2 ways to switch them. One via AT Commands and the other a Sierra Windows utility that modeswitches it.
The other way is to flash the wanted firmware. There are separate DIP and QMI firmware. Once again Windows required.


----------



## Phishfry (Aug 18, 2017)

balanga said:


> AT!GSTATUS resulted in
> 
> OK


This is also a symptom of the limited command console. Once you find the 'real' console by testing the others then AT!GSTATUS? will show more.
Like mine.

Try the upper ports first. Usually it is next to last USB endpoint. The cuaU0.1 port is probably GPS.
`cu -l /dev/cuaU0.3
cu -l /dev/cuaU0.4
cu -l /dev/cuaU0.5`

As you may know testing serial ports with `cu` can result in `cu` locking up.
It can also lock up the whole computer. So it is just testing and probing. No big deal.
If you find the GPS port with `cu` it will lock up.


----------



## balanga (Aug 18, 2017)

Phishfry said:


> I believe you are on a limited AT command prompt made for application interface.(See APP1 up there)
> Called GOBI interface.
> 
> You need to check the higher ports for the full extended command prompts.
> cuaU0.3, cuaU0.4,cuaU0.5


All of those respond with

```
/dev/cuaU0.x: No such file or directory
link down
```


----------



## Phishfry (Aug 18, 2017)

Yes you are right cuaU0.2 is the correct port. Also this module has no GPS.

I would try and put the newest firmware on it. Looks like a 2x speed advantage.


----------



## balanga (Aug 18, 2017)

Phishfry said:


> Yes you are right cuaU0.2 is the correct port. Also this module has no GPS.
> 
> I would try and put the newest firmware on it. Looks like a 2x speed advantage.


I read that I can only upgrade from within Windows....Do these instructions seem ok?

http://www.3g-modem-wiki.com/page/Sierra+Wireless+MC8775+&+MC8775v


----------



## Phishfry (Aug 19, 2017)

I would first try Sierra Source for the newset firmware. If it is no longer available then use the link to the site you referenced above.
Do notice that the firmware download link is broken, here is the fixed location:
http://www.istudioz.net/files/pub/MC8775/8775_h2_0_8_19.tar

Any carrier locked firmware would be negated with a generic firmware flash like above.

Here is the flasher. The links at that page seem broke but they just need fixup.
http://www.istudioz.net/files/pub/MC8775/binflash_original_v1.6.0.3.rar


----------



## balanga (Aug 21, 2017)

Many thanks Phishfry - I've managed to get my Thinkpad X61 accessing the Inernet via my MC8775 card now after using the links above and I'm not using a Vodafone SIM. Unfortunately this is under Windows, but at least I know I can do it. Now to get it working under FreeBSD...


----------



## balanga (Aug 24, 2017)

Phishfry said:


> Here is mine on MC73xx
> 
> 
> ```
> ...



I've installed Arch Linux and am able to retrieve similar info....


```
ati
Manufacturer: Sierra Wireless, Incorporated
Model: MC8775
Revision: H2_0_8_19MCAP G:/WS/FW/H2_0_8_19MCAP/MSM6280/SRC 2008/08/29 18:28:52
IMEI: 352678014273665
IMEI SV: 13
FSN: D281058731910
3GPP Release 5
+GCAP: +CGSM,+DS,+ES
```



> ```
> at!gstatus?
> !GSTATUS:
> Current Time:  1767       Temperature: 30
> ...




```
at!gstatus?
!GSTATUS:
Current Time:  1620       Temperature: 51
Bootup Time:   0       Mode:        ONLINE    
System mode:   WCDMA           PS state:    Attached
WCDMA band:      IMT2000             GSM band:      Unknown
WCDMA channel:   10737       GSM channel: 65535
GMM (PS) state:REGISTERED         NORMAL SERVICE
MM (CS) state: IDLE        NORMAL SERVICE

WCDMA  L1 State:L1M_PCH_SLEEP RRC state:     DISCONNECTED
RX level (dBm):-94

OK
```

It would seem that something is missing from my FreeBSD configuration which prevents it from displaying this info.


----------



## balanga (Aug 25, 2017)

SirDice said:


> It's not any different from a basic internet router configuration, only the interfaces themselves are configured slightly different. The way you would "share" the internet is exactly the same, set up NAT on the external interface, enable routing and allow traffic on the internal interface(s). The fact the interfaces are ethernet, wireless or 4G is pretty much irrelevant.



After struggling to get WWAN working, I'm now ready to "share" the Internet via wireless...  Does my laptop need to be running dhcpcd to provide IP addresses to any devices it services? 

Any tips on setting up NAT?


----------



## Phishfry (Aug 25, 2017)

I use dns/dnsmasq on my Access Points. That is my personal preference.
Here is my setup instructions for you using pf for NAT.
If you tell me your ethernet interface name and wifi card interface name I can help you more.(ie em0 and ath0)
That way you can share the internet via ethernet or wifi.
https://forums.freebsd.org/posts/348330/

Note these instructions need to be reworked for a PPP connection.
It is just an example of what is needed for a HostApd setup. That is what you want.


----------



## balanga (Aug 25, 2017)

Ethernet is em0 (Intel PRO/1000).
Wireless is wlan0 or wpi0 (Intel PRO/Wireless)   not sure which.... wlan0 shows up when running `ifconfig`. wpi0 shows up in `dmesg`


----------



## Phishfry (Aug 25, 2017)

OK em0 sounds right. The Intel wireless is not correct. How about showing the output of this:
`sysctl net.wlan.devices`


----------



## balanga (Aug 25, 2017)

```
net.wlan.devices: wpi0
```


----------



## Phishfry (Aug 26, 2017)

OK so first thing you need to check is that the wireless interface supports hostap mode. So check the man page.

I can help you more with this over the weekend.


----------



## balanga (Oct 29, 2017)

balanga said:


> `usbconfig`
> 
> ```
> ugen4.2: <Mini Card Sierra Wireless, Incorporated> at usbus4, cfg=0 md=HOST spd=FULL(12Mbps) pwr=ON (0mA)
> ...



... back to my ThinkPad X61 WWAN card....

I replace the previous card with an MC8355 and now I get this from `usbconfig`



> ugen5.2: <Sierra Wireless MC8355 - Gobi 3000TM Module Sierra Wireless Inc> at usbus5, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)



Is this to be expected?

I'm not sure how to access it, as the previously used device name no longer works.


----------



## Phishfry (Oct 29, 2017)

For diagnosis please post the output of this:
`usbconfig -u 5 -a 2 dump_device_desc`

What does this mean?


balanga said:


> I'm not sure how to access it, as the previously used device name no longer works.


Device name where? with cu?
Have you checked `ls /dev/cua*` to see what interfaces show up?


----------



## balanga (Oct 29, 2017)

Phishfry said:


> For diagnosis please post the output of this:
> `usbconfig -u 5 -a 2 dump_device_desc`
> 
> What does this mean?
> ...



I've now changed the WWAN to one I intended to use, ie the MC7710 and `usbconfig` shows


> ugen0.1: <UHCI root HUB Intel> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
> ugen1.1: <UHCI root HUB Intel> at usbus1, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
> ugen2.1: <EHCI root HUB Intel> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
> ugen3.1: <UHCI root HUB Intel> at usbus3, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
> ...



ie no sign of the WWAN card .... Maybe I haven't connected it properly....Or maybe it's time to investigate Middleton BIOS...


----------



## Phishfry (Oct 29, 2017)

Was the MC8355 a IBM branded module? If so then yes you may need to use a modfied bios.
To tell if IBM OEM look for an FRUxxxxx model number on the module.
FRU is 'Field Replaceable Unit' and a sure fire way to spot an IBM version of a device.


----------



## balanga (Oct 29, 2017)

The MC8775 has an FRU but the MC8355 doesn't even though I'm sure it came out of a ThinkPad...

Anyhow I'm currently trying to get hold of the Middleton BIOS although  it's proving difficult to get hold of it.


----------



## balanga (Apr 26, 2018)

Resuming an old thread....

Made a major breakthrough today!

Through a combination of a Huawei E3372 Hilink USB 4G/LTE modem, rndis, usb_modeswitch, I managed to connect my laptop to the Internet. No AT commands, no cuaU0, no ppp, just `dhclient ue0` 

Now I need to figure out how to turn the laptop into router/gateway between my LAN and the internet.

I'll provide details for anyone interested once I've documented the process.


----------



## balanga (Apr 27, 2018)

This is what I did.... (this is on FreeBSD 11.1-RELEASE amd64
/boot/loader.conf

```
if_urndis_load="YES"
```
`pkg install -y usb_modeswitch`

`reboot` with Huawei E3372 Hilink inserted
After booting up log on
`lsusb` should display the modem as a storage device.
run `/usr/local/sbin/usb_modeswitch -v 0x12d1 -p 0x1f01 -P 0x14db -J`
`lsusb` should now display the modem as a network device.
Running `ifconfig` should display the interface ue0. If it doesn't something has gone wrong.
`dhclient ue0` should assign an IP address from your SIM provider.
`ifconfig`  should show the IP address assigned to modem interface.

I currently access the Internet via ADSL and was amazed to find that Speedtest showed 3Mb/s over ADSL and 12Mb/s over 4G/LTE so I'll be looking to change my setup as soon as I figure out how to get the LAN routing sorted out. 

Not yet sure how routing should be set up and it would be nice to have `usb_modeswitch` run as part of the boot process.

Any suggestions would be appreciated.


----------



## cbj (Dec 9, 2018)

I got an Huawei E3372h working like it did on Linux, with automatic running `usb_modeswitch` on every boot with these lines in /etc/devd.conf:

```
notify 100 {
    match "system"        "USB";
    match "subsystem"    "DEVICE";
    match "type"        "ATTACH";
    match "vendor"      "0x12d1";
    match "product"        "0x1f01";
    action "/usr/local/sbin/usb_modeswitch -v 12d1 -p 1f01 -c /usr/local/share/usb_modeswitch/12d1:1f01 &";
};
```

The '&' at the end is not a mistake. On my laptop usb_modeswitch hangs waiting for reply from the stick, and this makes it less a problem.

To also get the system to assign an IP to the ue0 device, I had to append these lines to /etc/devd.conf:

```
attach 100 {
    device_name "cdce0";
    action "dhclient ue0";
};
```

I hope this is useful for you.


----------

