How to manage LTE USB modem disconnect,reconnect and avoid crashing OPNsense

Started by GiantJack, November 07, 2019, 01:39:29 PM

Previous topic - Next topic
Hi There!

I have setup my OPNsense with 2 gateways: main (default) one is a DSL modem.
The second one is an LTE USB modem e3372h (hilink mode).

The LTE gateway helps to speed up a bit my not very fast DSL.
Both gateway works fine.

But I still face a couple of issues:

1- I may want to take the USB modem with me sometime (holidays, business trip...)

If I just take the modem out of the USB port of OPNsense =>  It does crash OPNsense !!
DHCP is dead, ping give no answer....all I can do is a reboot!

How can I avoid this ?

I would have expected that OPNsense should just set offline my LTE gateway...


2- This e3372h Hilink modem need to do a "usb_modeswitch" command when reconnected to the gateway.

I was thinking I could maybe "cron-ize" the command every five minute (it will just get with error message if the modem is always switched)...But that sounds a bit not clean.
is it possible to set this command "on connection" of the modem only?

I notice also that after reconnection & modeswitch command, I may need to manually disable/enable the interface to have the gateway online again...and there, I have no clue how I could make this automatic...?

One day, I will understand all of this !

Hi,
I made some experiments some time ago with this modem and because the problems you mention now I use a TL-MR3420 with this modem, and no more problems...

When I used only E3372 I made my script, I also added a cron that will run it every 5 min.

On my setup I first set ue0: static 192.168.10.10/24 gateway 192.168.10.1, add gateway... gateway group...
and pkg install usb_modeswitch

It is possible that you will need to make changes to this script for your setup but you have the main work done:

#!/bin/sh
# delete cd0 prepare USB E3372 modem
# LLC script v0.1

# test if USB dongle exist
usbdata=`usbconfig | grep HUAWEIMOBILE`
if [ -z "$usbdata" ]
then
echo "INSERT USB E3372 !"
exit
fi

cdata1=`/sbin/camcontrol devlist | grep cd0`
# test if no exist cd0 -> NO cd0
#echo "$cdata1"
if [ -n "$cdata1" ]
then
# exec commands to eject cd0 and activate network modem
echo "EJECT cd0"
/sbin/camcontrol eject cd0
/usr/local/sbin/usb_modeswitch --default-vendor 0x12d1 --default-product 0x1f01 -J
fi

#echo "EXIT USB-E3372 CD"
#exit 0

ue0inet=`/sbin/ifconfig ue0 | grep inet`
# test if exist ue0inet
while [ -z "$ue0inet" ]
do
echo "working to ue0 IP..."
/sbin/ifconfig ue0 up
/bin/sleep 1
/sbin/ifconfig ue0 inet 192.168.10.10 netmask 255.255.255.0
ue0inet=`/sbin/ifconfig ue0 | grep inet`
done

#/sbin/ifconfig ue0
echo "EXIT USB-E3372"
exit

Hello,

I have a very similar setup (DSL with USB LTE failover), but i am using an older android phone as the modem. My problem is exactly the same as yours: if/when the USB connection to the phone goes down (bad cable, phone rebooting, etc.) it brings the whole rig down. :( Kind of counterproductive if you added the failover for reliability in the first place. ;)
What I noticed that sometimes first the web UI freezes but SSH and network connectivity still works for a minute or two, other times the whole system freezes straight away and ping returns 'network unreachable'. This indicates some kind of overload to me.
As a first idea of remedy I removed the failover interface from NetFlow (so it is not used by any services, esp. not Suricata or Maltrail), which I hope will fix the freeze. I keep my fingers crossed, will report back if the phone should disconnect again. Hopefully this might help you as well.

...nope, sadly it didn't help. opnsense still freezes when the usb modem is disconnected. :(



Quote from: 3kj2w on November 17, 2019, 05:37:39 PM
Hi,
I made some experiments some time ago with this modem and because the problems you mention now I use a TL-MR3420 with this modem, and no more problems...


Hi!
do you use the TL-MR3420 "between" the huawei USB modem and Opnsense ?
If yes, I assume you have a dual NAT then ?
I do have a TL-MR3020, but I didn't wanted to add it in between to avoid this.



One day, I will understand all of this !

Quote from: szty0pa on November 29, 2019, 03:13:11 PM
...nope, sadly it didn't help. opnsense still freezes when the usb modem is disconnected. :(
at least, I'm not alone :-)
One day, I will understand all of this !

Because in my case TL-MR3420 with 4G/LTE is used only for WAN backup and I can't have open ports on 4G/LTE or a true Public IP with my operator I have no problems with dual NAT, Primary WAN - fiber optic is not used via TL-MR3420.

Quote from: 3kj2w on January 06, 2020, 04:08:25 PM
Because in my case TL-MR3420 with 4G/LTE is used only for WAN backup and I can't have open ports on 4G/LTE or a true Public IP with my operator I have no problems with dual NAT, Primary WAN - fiber optic is not used via TL-MR3420.

Good point!
I will give a try with my MR3020.

One day, I will understand all of this !

Hi !

I would like to share that a 4G backup gateway works fine even with double NAT. (as long as you need only access to internet and no incoming port which is anyway not possible for most 4G connexions).

I use a MR3020 connected to opensense by ethernet and with my a 4G modem e3372 connected by USB.

Also no problem to access the web interface of the MR3020 and of the modem from my LAN in case I need to tune or check some settings.

Disconnecting the modem kills the gateway (of course), but does not crash opnsense like before !!

Exactly what I need :-)


I also tried to aggregate connexion (dsl + 4G) from my 2 gateways...it works more or less (sometime perfect, sometime not working). I'm not sure of the reason.
Anyway I use this only sporadically, for example if needed to download faster some large file (for exemple a PS4 game update).

One day, I will understand all of this !