# Building a FreeBSD 4G router



## balanga (Sep 3, 2017)

I would like to build a FreeBSD based 4G/LTE router which has the features available in this commercial product:-

https://www.amazon.co.uk/TP-LINK-MR...l+Band+AC750+Wireless+4G+Sim+LTE+Modem+Router

Where would I start?

I was thinking about something like this as it includes a SIM socket:-

https://pcengines.ch/apu2c4.htm

Not sure how to attach two antennas though...


----------



## r_t_f_m (Sep 3, 2017)

With https://pcengines.ch/apu3a4.htm and pfSense, https://www.pfsense.org/download/,  you'll have everything needed to build a 4G/LTE router.

OPNSense, https://opnsense.org/download/, a spin-off of pfSense, is also an other possibility.


----------



## Phishfry (Sep 4, 2017)

Did you get your old laptop acting as a MiFi? PPP+WiFi/HostAPd??

Do your learning on that box and save on the fancy gadgets.

I do like the APU and yes it would make a good Mifi candidate but you do need to add 2 or 3 antenna holes for your Wifi.
The stock case comes with 2 rp-sma holes which is fine for one device, like the cell modem(which needs two for speed)
but cards like AR9380 Atheros AR5BXB112 have 3 antenna connectors.
So 2-3 Wifi Antennas and 2 cell antennas. You could even do 2 Wifi cards and 1 cell modem on them I believe. Boot off usb or SATA.
2 Wifi cards so you could do separate 2.4 and 5ghz networks or some other usage like public wifi and private network.
You could also add a GPS antenna for your mc7710.

The negative is look at the performance numbers and 1Gigabit ethernet drops to 650Megabit with pf NAT on.
There is not a lot of ass to the cpu. Similar to E38xx offered in Intel boards.
6-8W max is nice for a quad core.

Did you get your MC7710 flashed to DIP mode with the newest firmware?

The laptop as a Mifi is a good starting points because it already has the antennas needed. Just add software.

With a laptop you have the added bonus of being able to boot up Windows HDD and diagnose modem with Sierra Watcher.
With APU it is console only.
No VGA.


----------



## balanga (Sep 4, 2017)

r_t_f_m said:


> With https://pcengines.ch/apu3a4.htm and pfSense, https://www.pfsense.org/download/,  you'll have everything needed to build a 4G/LTE router.
> 
> OPNSense, https://opnsense.org/download/, a spin-off of pfSense, is also an other possibility.



Do you know of any guide as to set about building such a router? One problem I see is how to connect some antennas...


----------



## balanga (Sep 4, 2017)

Phishfry said:


> Did you get your old laptop acting as a MiFi? PPP+WiFi/HostAPd??
> 
> Do your learning on that box and save on the fancy gadgets.
> 
> ...



My ThinkPad X61 WWAN router project is on hold at the moment since I don't have my MC7710 with me at the moment...I believe I might not be able to use it anyway because of some whitelisting issue, which I may be able to remove using the Middleton Bios, but apparently I can't update the BIOS if I have a dead battery, so I need to buy a new battery first.

At the moment I'm trying to gather information which would allow me to build a FreeBSD-based system which is at least as powerful as this:-

http://uk.tp-link.com/products/details/cat-4691_Archer-MR200.html#specifications

Or maybe it's possible to install some BSD-based routing software onto the above....

As for antennas, I'm not sure how many I need, and whether the available cases have sufficient holes


----------



## ralphbsz (Sep 4, 2017)

I think you are focussing on the wrong thing: which motherboard to use (and the APU is just a specific type of motherboard) is secondary; for this application, pretty much any motherboard will do from a compute/memory point of view.  I agree with Phishfry's suggestion to use an old laptop (or whatever you have sitting around).

How to connect antennas?  That's a problem that's solvable with a little elbow grease and money: drill more holes in the case, buy connectors and cables and antennas.  You might have to use a bigger case.  For many years, my home server / router / firewall / access point was a Soekris board (physically a little smaller than the APU) in a small case: use an electric drill to add extra coax connectors for antennas.  This works good for APU and Soekris-style boards; it doesn't work well for laptops though.

The real problem will be the software stack.  After many years of suffering through bad performance and regular crashes, I gave up on using either OpenBSD or FreeBSD as a wireless access point.  The stack is just not good enough for this purpose.  The single biggest problem is a known software issue that makes it hard to use any Apple-made device as a client on a FreeBSD access point (the details are in foggy memory), which might be fixed by now.  I also found the kernel's wireless drivers to not be reliable enough, and ended up having to reboot my machine multiple times per day, which gets to be really old.  Hopefully, YMMV and you'll have a better experience (mine was several years ago), but you really need to verify that the software can handle it.


----------



## Phishfry (Sep 4, 2017)

Wow I think you need to try HostAPd again. I switched from pfSense as my AP to FreeBSD and it took a little bit but I have a rock solid setup.
I do remember the issues with Apple Airport extreme AP.

root@APU3:~ # uptime
 7:56PM  up 15 days,  2:43, 1 users, load averages: 0.06, 0.11, 0.09

The box works without effort.

root@APU3:~ # ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
   ether 00:15:6d:84:b2:f6
   inet 192.168.100.1 netmask 0xffffff00 broadcast 192.168.100.255
   nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
   media: IEEE 802.11 Wireless Ethernet autoselect mode 11na <hostap>
   status: running
   ssid APU3 channel 157 (5785 MHz 11a ht/40+) bssid 00:15:6d:84:b2:f6
   regdomain FCC country US ecm authmode WPA2/802.11i privacy MIXED
   deftxkey 2 TKIP 2:128-bit TKIP 3:128-bit txpower 23 mcastrate 6
   mgmtrate 6 scanvalid 60 ampdulimit 64k ampdudensity 8 shortgi wme
   burst dtimperiod 1 -dfs
   groups: wlan

I am using a Ubiquity SR71-E which is not cheap but I buy the best.

I only recently upgraded from my first WAP, a Lanner/Checkpoint U5 with PentiumM LV 600mhz
It had MiniPCI slot and I had a Mikrotek Atheros AR9220 card in it and the signal strength was much higher.
It was a 1000mw card so I really think the radio matters alot.

The Atheros AR9380 AR5BXB112 was my previous cheap favorite but when I pitted it against a professional card I saw the flaws.

To me the only drawback is speed. You could do better with a store bought kit for 30 bucks.
Myself I like the ability to build my own WAP.
It gives me satisfaction knowing that I cannot be screwed over by a manufacturers EOL decision.
I know every bit of software running my WAP and can upgrade it at will.


----------



## balanga (Sep 5, 2017)

ralphbsz said:


> I think you are focussing on the wrong thing: which motherboard to use (and the APU is just a specific type of motherboard) is secondary; for this application, pretty much any motherboard will do from a compute/memory point of view.



I'm looking at motherboards because I want something which comes with a SIM slot.


----------



## ralphbsz (Sep 5, 2017)

Phishfry said:


> Wow I think you need to try HostAPd again.


Never actually used hostapd, didn't need it (no security on my AP, and no security needed, due to physical isolation).  Just used the standard drivers, with some atheros card, and did an ifconfig command to put the wireless device into AP mode.  This configuration was never stable for long periods, and never worked well with Apple clients (not with apple APs, which is what I replaced it with).  Biggest single problem: After a few hours or days of running, the kernel would start spewing "ath0: stuck beacon; resetting (bmiss count 4)" messages, and only a reboot cured those.  If those messages start coming out at a high rate (a few per second, or a few hundred per second), then the kernel will die.  Second problem (and I can't remember the details and haven't found them in my logs): Apple client 802.11 implementation do something weird with power management on the link, which is incompatible with the FreeBSD AP implementation (this is low-level stuff, not hostapd stuff).  This causes the power management to go haywire, and the links default to the lowest speed; we were getting a single-digit Mbit/s for Apple clients (both MacOS and iOS), and 40-50 Mbit/s for other clients.  After much research, I concluded that neither issue is going to be fixed anytime soon in FreeBSD (nor in OpenBSD), and decided to just get a commercial AP and get on with life: For an investment of $90 or so (the cheapest Apple Airport, picked up on the way home right at the Apple store) all the problems were solved; it works perfectly boringly, and gives zero trouble.

Just looked it up: I tried two different Atheros-based mPCI cards; the first one used the 9285 chip, the second one the 9287.  Same problems.  This was FreeBSD 9.0.

Since then I've been very leary of trying to use a general-purpose OS as an AP.  It may be possible, if you invest enough time into getting the perfect hardware (the one that is supported by perfect drivers), and tune and tweak everything optimally.  You admitted above "it took a little bit".  It wasn't worth my time.


----------



## Phishfry (Sep 5, 2017)

ralphbsz said:


> stuck beacon


Yea those days are long gone thank goodness.
Even when those messages dominated the console they were not a real showstopper for me.
I just like making my own WAP. Mine has been very solid. No connection issues at all. Just not real fast.
I need to move mine off the APU3 and onto an APU2.



ralphbsz said:


> the 9285 chip, the second one the 9287. Same problems.


Those sound like half card models. I always use full length MiniPCIe cards for AP.
I have become partial to Mikrotik and Ubiquity radios.

For clients my Dells use half card and the best I can do is AR9380/AR5BHB112 Which is only ath0 halfcard with 3x MiMo. It comes at a premium. Even used ones from ebay fetch $40. In a tiny build I might consider one for hostap mode. 

Intel half card radios do OK too and they have a 3x MiMo arrangment, but no hostap mode on the driver.


----------



## ralphbsz (Sep 6, 2017)

Maybe I should try it again, this time using one of the newer cards you recommend, and obviously much newer software (11.1 > 9.0, duh).  I'll put it on my to-do list.


----------



## Phishfry (Sep 6, 2017)

My first go I ran this card which had much more power than my current card. I used an old Checkpoint U5 with MiniPCI.
https://mikrotik.com/product/R52Hn

Then I got these for MiniPCIe:
https://mikrotik.com/product/R11e-5HnD
https://mikrotik.com/product/R11e-2HPnD

Finally ended up using these:
https://www.newegg.com/Product/Product.aspx?Item=0ED-0005-00061
They are from 2011 but versatile. They don't have a big heatsink are dual band and use regular antenna connectors..

They all work good but none were cheap. 40-50 bucks each.
Regular commodity cards work but I was willing to throw money at it. You get what you pay for.

I made a NanoBSD WAP image but that is on backburner. I hate disturbing a good setup.
Its actually working off the SD Card but i turned off most logging.


----------



## balanga (Dec 8, 2017)

I'm in the processing of changing by broadband provider and one of the ISPS I'm looking at provides one of these 4G routers.

Can anyone suggest what components I need to be able to create a FreeBSD based router which has the functionality of the above?


----------



## tingo (Dec 8, 2017)

1 x FreeBSD machine with the necessary interfaces
1 x supported USB 4G modem
enough time to figure out the setup
or just install pfSense on it...


----------

