OPNsense Forum

Archive => 18.1 Legacy Series => Topic started by: sancra01 on April 11, 2018, 03:54:03 am

Title: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: sancra01 on April 11, 2018, 03:54:03 am
Hi

I'm new to OPNsense but used pfSense for quite some time. I've just installed 18.1 on a spare laptop and my WAN device is a Netgear AC800S 4G/LTE modem. To get the device recognised by OPNsense I've run the console shell and typed in ...

usbconfig -d ugen0.6 set_config 1

The modem is then recognised as an ethernet device with a MAC address.

I then run option 1 "Assign interfaces" from the console and select local ethernet connection for LAN (em0) and Netgear modem for WAN (ue0). Once done I've got internet access and I'm very happy.

The problem is that when the device is rebooted it forgets about the modem. I've created a new file ...

/boot/loader.conf.local

... and added the following line ...

hw.usb.quirk.0=”0x0846 0x68e1 0 0xffff UQ_CFG_INDEX_1”

... as per a forum posting I found here (which worked for pfSense) ...

https://forum.pfsense.org/index.php?topic=93393.0 (https://forum.pfsense.org/index.php?topic=93393.0)

However, when I reboot the modem is not configured on the WAN interface. If I run through the procedure above again I can get it operational.

Does anyone know how I would make the ...

usbconfig -d ugen0.6 set_config 1

... to stick so that the modem is recognised on boot and OPNsense sets up the WAN interface correctly?

Many thanks

Craig

Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: franco on April 11, 2018, 06:40:16 pm
Hi Craig,

You can use rc.syshook's early hook for setting up network devices prior to network configuration. Don't forget to lock the interface from the GUI as well.

https://docs.opnsense.org/development/backend/autorun.html

loader.conf values go to System: Settings: Tunables now no problem (since 18.1.5).


Cheers,
Franco
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: franco on April 11, 2018, 06:41:06 pm
PS: USB devices may also require the os-boot-delay plugin to power up properly.
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: sancra01 on April 12, 2018, 01:47:26 am
Thanks for that additional information.

I was only on version 18.1 (based on the image I downloaded) so upgraded to latest version (18.1.6). As soon as it rebooted my USB modem was detected and assigned to the WAN interface. How good is that!

I had previously put an entry into the rc.syshook after my initial post but it didn't work. Looks like it's working now. I notice in the rc.syshook directory that there are other entries all beginning with a number. Does the number have an effect on the order of applying the scripts in there?

I'll have a play around with what I've got working today. I might have an additional question.

Many thanks for your help.

Cheers

Craig
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: sancra01 on April 12, 2018, 03:56:44 am
OK I've done a bit more testing. I'm posting this for anyone else who might be trying to get an LTE modem working.

First of all I upgraded to 18.1.6.

Secondly I added a tunable with the name ...

hw.usb.quirk.0

... and a value of ...

0x0846 0x68e1 0 0xffff UQ_CFG_INDEX_1

... (but to be honest I'm not sure why I use INDEX_1).

Thirdly I added the os-boot-delay plugin as recommended by Franco.

I removed loader.conf.local that I had created early and also deleted a file I had created in rc.syshook.d that ran the script ...

usbconfig -d ugen0.6 set_config 1

I then rebooted and my modem has been recognised and assigned to the WAN interface. I'm very happy with that.

I was under the impression that when using a quirk, if I disconnect/reconnect the modem it would be recognised and the WAN interface would be assigned to it but that's not happening for me. The modem is recognised when I plug it back in and the CDC Ethernet Control Model ECM assigns it an Ethernet MAC address but the WAN doesn't get assigned to it. Small thing I can live with but if there's a way to sort it out I'm all ears.

Many thanks for that additional information.

Cheers

Craig
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: OPNPeta on April 12, 2018, 07:51:29 am

Secondly I added a tunable with the name ...

hw.usb.quirk.0

... and a value of ...

0x0846 0x68e1 0 0xffff UQ_CFG_INDEX_1

... (but to be honest I'm not sure why I use INDEX_1).

Thirdly I added the os-boot-delay plugin as recommended by Franco.


Hi,

for my better understanding - where did you put the tuneable into to? Edited /boot/loader.conf and added a value hw.usb.quirk.0="0x0846 0x68e1 0 0xffff UQ_CFG_INDEX_1" ?

I have got nearly the same issue with different hardware and values for usbconfig -d ugen0.6 set_config 1 that I would have to adjust to make my iPhone work as hotspot ethernet device via USB (using kldload if_ipheth)
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: sancra01 on April 12, 2018, 07:57:42 am
You do it from the OPNsense webpage. Need version 18.1.5 or later as specified by Franco.

Goto ...

System | Settings | Tunables

.... and add a new tunable. Worked for me! Let me know how you go.

Cheers

Craig
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: franco on April 12, 2018, 06:32:18 pm
Craig, the number of rc.syshook scripts is for ordering, you can use the prefix for that if you need to land somewhere in the middle of two scripts already there, but in your case that's not necessary.

Please also don't forget to go to the interface settings in the GUI that uses the modem and set it to "Prevent interface removal" to avoid config reverts when the USB should fail to come up for some reason.


Cheers,
Franco
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: OPNPeta on April 12, 2018, 10:09:40 pm
You do it from the OPNsense webpage. Need version 18.1.5 or later as specified by Franco.

Goto ...

System | Settings | Tunables

.... and add a new tunable. Worked for me! Let me know how you go.

Cheers

Craig

Okay, fine, so I finally found these setting. I make a new tunable hw.usb.quirk.0 but where do I get the right value from I have to enter, too?

FreeBSD man says that USB_QUIRKS need VendorId, ProductId, LowRevision and HighRevision 16 bits numbers which can be decimal or hexadecimal based.

Using # usbconfig -u 4 -a 2 dump_device_desc (ugen4.2 = my USB iPhone device) tells me idVendor and idProduct and some other values so I made a tunable = hw.usb.quirk.0 and value =  0x05ac 0x12a8 0 0xffff UQ_CFG_INDEX_3 but it doesn't work.

What is still working and has worked via shell:
 
# kldload if_ipheth
# usbconfig -u 4 -a 2 set_config 3



I'd like to have these two commands loaded when OPNsense starts up without entering them via shell
Can you help me?? :o
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: sancra01 on April 13, 2018, 12:16:38 am
Right probably getting a bit out of my league now.

You could try the route of creating a script with those two lines below and place the script into the rc.syshook.d directory as per Franco's reference below ...

https://docs.opnsense.org/development/backend/autorun.html

That worked for me in one of my attempts of getting something working.

Hopefully that will steer you in the right direction. I'm afraid I'm as new as you are are doing this stuff.

Cheers

Craig
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: sancra01 on April 13, 2018, 12:21:03 am
Please also don't forget to go to the interface settings in the GUI that uses the modem and set it to "Prevent interface removal" to avoid config reverts when the USB should fail to come up for some reason.

Thanks Franco - I've made that setting - it's sticking nicely.

Do you have any idea as to how I can get the network to come up when I disconnect/reconnect the network as per ...

I was under the impression that when using a quirk, if I disconnect/reconnect the modem it would be recognised and the WAN interface would be assigned to it but that's not happening for me. The modem is recognised when I plug it back in and the CDC Ethernet Control Model ECM assigns it an Ethernet MAC address but the WAN doesn't get assigned to it. Small thing I can live with but if there's a way to sort it out I'm all ears.

Thanks

Craig
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: sancra01 on April 23, 2018, 03:48:33 am
I was under the impression that when using a quirk, if I disconnect/reconnect the modem it would be recognised and the WAN interface would be assigned to it but that's not happening for me. The modem is recognised when I plug it back in and the CDC Ethernet Control Model ECM assigns it an Ethernet MAC address but the WAN doesn't get assigned to it. Small thing I can live with but if there's a way to sort it out I'm all ears.

Anyone got any ideas of what I could try?
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: franco on April 24, 2018, 09:09:24 am
Do you have the system logs (generic) for this?

Normally a linkup event should reissue your network configuration, but if usb config is lost that won't be reapplied automatically. Worst case this requires devd configuration for the specific events occurring...
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: sancra01 on April 30, 2018, 02:36:56 am
Do you have the system logs (generic) for this?

Sorry for the delay. Had an internet free week! General log file below ...

Date    Message
Apr 30 10:13:18    kernel: ue0: Ethernet address: 00:a0:c6:00:00:00
Apr 30 10:13:18    kernel: ue0: <USB Ethernet> on cdce0
Apr 30 10:13:18    kernel: cdce0: <CDC Ethernet Control Model ECM> on usbus0
Apr 30 10:13:18    kernel: cdce0 on uhub1
Apr 30 10:13:18    kernel: ugen0.6: <NETGEAR, Inc. AirCard 800S> at usbus0
Apr 30 10:12:25    kernel: cdce0: detached
Apr 30 10:12:25    sshlockout[10744]: sshlockout/webConfigurator v3.0 starting up
Apr 30 10:12:25    kernel: cdce0: at uhub1, port 11, addr 5 (disconnected)
Apr 30 10:12:25    kernel: ugen0.6: <NETGEAR, Inc. AirCard 800S> at usbus0 (disconnected)
Apr 30 10:12:05    syslogd: kernel boot file is /boot/kernel/kernel


These are the logs for when I detach the modem USB cable and then reattach. As you can see the USB modem is detected but the WAN interface doesn't come up and doesn't get the IP address from the USB modem. If I reboot OPNsense now the USB modem will be detected and the WAN interface will come up and be assigned an IP address from the modem.

I'm not sure what I would need to do with devd configuration for a specific event.

Thanks

Craig
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: franco on May 02, 2018, 05:06:02 pm
Hi Craig,

Thanks, the device attaches, but does not generate a linkup event.

You can do drop in files at /usr/local/etc/devd with somewhat of the following:

https://github.com/opnsense/core/blob/master/src/etc/devd/ifnet.conf#L39

With this you can match the ue device(s) ATTACH and run a script like this:

action "ifconfig $subsystem up";

to generate the link up event and kickstart the reconfiguration process.


Cheers,
Franco
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: sancra01 on May 21, 2018, 07:30:27 am
Apologies for the delay getting back to you. OPNsense and the USB modem have been working quite well up until about a week ago and then I noticed that the USB modem is detaching and reattaching 6 seconds later once a day at random times (but usually in the early hours of the morning) so resolving this has jumped the priority list :)

I've added the line as suggested to my /usr/local/etc/devd/ifnet.conf as per below ...

notify 101 {
   match "system"      "IFNET";
   match "subsystem"   "!usbus[0-9]+";
   match "type"      "ATTACH";
   action "ifconfig $subsystem up";
};


... and I've had some success.

When I detach the USB modem and attach it again I've noticed that the status of the WAN interface is UP (previously DOWN after detach/attach) but it doesn't have a DHCP address from the modem. So I went to "Interfaces | Overview" and selected the dropdown for my WAN interface and then hit the button to renew the DHCP and the WAN interface started working again.

So I'm nearly there. I guess I need to add another line perhaps to renew the DHCP after the WAN interface comes up? I just have no idea what I need to add though.

Can you provide another gentle push in the right direction?

Many thanks

Craig
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: sancra01 on May 31, 2018, 05:51:13 am
I'm still having a bit of trouble trying to figure this out.

I'm guessing that I need to add another "action" in the ifnet.conf that will renew the IP address just after the WAN interface comes up. I've opened up a shell in OPNsense to try out a couple of commands to renew the IP address that the USB modem assigns but I'm not even sure of the command to renew.

I've read that ...

dhclient -r

... should renew it but when I run that it says there is no "r" option.

So how do you renew an ip address in OPNsense/FreeBSD? If I can work that out then adding that command line to the ifnet.conf might resolve my issue.

Grateful for any information anyone can provide.

Cheers

Craig
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: sancra01 on May 31, 2018, 06:22:38 am
Tried something else. Added line in red below to ifnet.conf which I found in the logs after I renewed the IP address using the OPNsense GUI ...

notify 101 {
   match "system"      "IFNET";
   match "subsystem"   "!usbus[0-9]+";
   match "type"      "ATTACH";
   action "ifconfig $subsystem up";
   action "/usr/local/etc/rc.newwanip ue0";
};


Disconnected/reconnected the modem, WAN interface came up but it didn't acquire an IP. Would I need to introduce a delay or something after bringing up the WAN interface and if so how would I do that?
Title: Re: Netgear 4G/LTE Modem - How to get it recognised at OPNsense Boot
Post by: sancra01 on June 15, 2018, 03:04:24 am
Anyone got any ideas that I could try?