pfSense Support Subscription

Author Topic: Useful 3G modem 'mode switching' script  (Read 10753 times)

0 Members and 1 Guest are viewing this topic.

Offline stephenw10

  • Hero Member
  • *****
  • Posts: 8165
  • Karma: +7/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #30 on: February 19, 2012, 02:44:27 pm »
What happens when it tries to dial out before the interface is switched?
I'm surprised that it doesn't just keep trying.
Maybe using dial-on demand or idle time out.

You could write a script that ran usb_modeswitch, waited and then called the appropriate interface connect function.

Steve

Offline jamesc

  • Jr. Member
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #31 on: February 19, 2012, 02:59:45 pm »
It doesnt do anything, the box continues its boot process as if no modem was plugged in. I see the modem details flash up on the console towards the end of the boot process but PPP has already initialised at this point (without seeing the modem) so i suspect it wont keep on attempting a dial out because as far it's concerned, no modem was detected at the time of initialisation, I hope that makes sense!

Offline stephenw10

  • Hero Member
  • *****
  • Posts: 8165
  • Karma: +7/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #32 on: February 19, 2012, 03:26:12 pm »
Yes I see exactly what you mean.
Would probably be best to use an rc script then.
This is just a guess but perhaps:
Code: [Select]
#!/bin/sh
/usr/local/sbin/usb_modeswitch -c yourmodem.txt
sleep 5
/etc/rc.reload_interfaces

Try issuing a /etc/rc.reload_interfaces and see if it finds the modem and connects.

Steve

Offline jamesc

  • Jr. Member
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #33 on: February 19, 2012, 03:52:40 pm »
I had just finished creating a similar script and was looking for a command that would restart PPP, the reload_interfaces seems to do the trick nicely, thank you.

Offline jly2680

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #34 on: March 05, 2012, 08:02:38 am »
how can i put my usbmode_switch script in startup??i have bandluxe 21 mbps 3g modem and successfully flip it to modem mode using usb_modeswitch..I want to connect my modem's ppp  in start up..thanks

Offline stephenw10

  • Hero Member
  • *****
  • Posts: 8165
  • Karma: +7/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #35 on: March 05, 2012, 08:36:17 am »
If it's an RC script, as I detailed above, put it in /usr/local/etc/rc.d and it will run at boot.

Steve

Offline jly2680

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #36 on: March 05, 2012, 09:03:48 am »
i already put my script in /usr/local/etc/rc.d/ but when i reboot pfsense,,ppp dials in fiirst before flipping my usb modem,thus i need to dial my ppp manually..i want to flip my modem first then ppp dials in..TIA

Offline stephenw10

  • Hero Member
  • *****
  • Posts: 8165
  • Karma: +7/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #37 on: March 05, 2012, 09:12:40 am »
Yes Jamesc experienced that problem above.
Doesn't it redial when you reload the interfaces in the script?

Steve

Offline jly2680

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #38 on: March 05, 2012, 09:23:36 am »
thanks..reload interfaces did the trick..now i will add 1 more different usb modem.. :)

Offline jly2680

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #39 on: March 05, 2012, 11:35:31 am »
problem occurs: persistent disconnections..i cant make my modem to hold for an hour or so..my ppp connection disconnects  every 10 seconds..i try to use my 3g modem directly with my laptop but never had a connection hangup..

Offline stephenw10

  • Hero Member
  • *****
  • Posts: 8165
  • Karma: +7/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #40 on: March 05, 2012, 12:34:31 pm »
Is it exactly 10 seconds every time? This might indicate some sort of ppp error. Or more random?
What do you see in the logs? Does it do this if you setup the connection manually instead of using the script?
Have you set the PPP session to be 'always on' (idle timeout = 0, which is the default setting)

using rc.reload_interfaces seemed a bit crude when I suggested it earlier and it still does. It maybe that it is causing some other undesired consequence. It would be much better to simply reload WAN or indeed just have it redial. Sadly I'm not sufficiently familiar with the code to suggest anything better.  :(

Steve

Edit: rc.linkup WAN up (or should that be 'up WAN') perhaps?  :-\ Complete guesswork!
« Last Edit: March 05, 2012, 01:02:05 pm by stephenw10 »

Offline jly2680

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #41 on: March 05, 2012, 02:07:39 pm »
i think ppp error side?
Code: [Select]
Mar 5 23:07:52 ppp: [opt2] IPCP: SendConfigReq #3
Mar 5 23:07:52 ppp: [opt2] IPADDR 176.225.134.77
Mar 5 23:07:52 ppp: [opt2] IPCP: rec'd Configure Ack #3 (Ack-Sent)
Mar 5 23:07:52 ppp: [opt2] IPADDR 176.225.134.77
Mar 5 23:07:52 ppp: [opt2] IPCP: state change Ack-Sent --> Opened
Mar 5 23:07:52 ppp: [opt2] IPCP: LayerUp
Mar 5 23:07:52 ppp: [opt2] 176.225.134.77 -> 10.0.0.1
Mar 5 23:07:52 ppp: [opt2] IFACE: Up event
Mar 5 23:08:36 ppp: Multi-link PPP daemon for FreeBSD
Mar 5 23:08:36 ppp:
Mar 5 23:08:36 ppp: process 28199 started, version 5.5 (root@FreeBSD_8.0_pfSense_2.0-snaps.pfsense.org 10:25 12-Oct-2011)
Mar 5 23:08:36 ppp: caught fatal signal term
Mar 5 23:08:36 ppp: [opt2] IFACE: Close event
Mar 5 23:08:36 ppp: [opt2] IPCP: Close event
Mar 5 23:08:36 ppp: [opt2] IPCP: state change Opened --> Closing
Mar 5 23:08:36 ppp: [opt2] IPCP: SendTerminateReq #4
Mar 5 23:08:36 ppp: [opt2] IPCP: LayerDown
Mar 5 23:08:36 ppp: waiting for process 16679 to die...
Mar 5 23:08:36 ppp: [opt2] IFACE: Down event
Mar 5 23:08:36 ppp: [opt2] IPCP: rec'd Terminate Ack #4 (Closing)
Mar 5 23:08:36 ppp: [opt2] IPCP: state change Closing --> Closed
Mar 5 23:08:36 ppp: [opt2] IPCP: LayerFinish
Mar 5 23:08:36 ppp: [opt2] Bundle: No NCPs left. Closing links...
Mar 5 23:08:36 ppp: [opt2] Bundle: closing link "opt2_link0"...
Mar 5 23:08:36 ppp: [opt2_link0] Link: CLOSE event
Mar 5 23:08:36 ppp: [opt2_link0] LCP: Close event
Mar 5 23:08:36 ppp: [opt2_link0] LCP: state change Opened --> Closing
Mar 5 23:08:36 ppp: [opt2_link0] Link: Leave bundle "opt2"
Mar 5 23:08:36 ppp: [opt2] Bundle: Status update: up 0 links, total bandwidth 9600 bps
Mar 5 23:08:36 ppp: [opt2] IPCP: Close event
Mar 5 23:08:36 ppp: [opt2] IPCP: Down event
Mar 5 23:08:36 ppp: [opt2] IPCP: state change Closed --> Initial
Mar 5 23:08:36 ppp: [opt2_link0] LCP: SendTerminateReq #3
Mar 5 23:08:36 ppp: [opt2_link0] LCP: LayerDown
Mar 5 23:08:36 ppp: [opt2_link0] LCP: rec'd Terminate Ack #3 (Closing)
Mar 5 23:08:36 ppp: [opt2_link0] LCP: state change Closing --> Closed
Mar 5 23:08:36 ppp: [opt2_link0] LCP: LayerFinish
Mar 5 23:08:36 ppp: [opt2_link0] Link: DOWN event
Mar 5 23:08:36 ppp: [opt2_link0] LCP: Down event
Mar 5 23:08:36 ppp: [opt2_link0] LCP: state change Closed --> Initial

Offline jly2680

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #42 on: March 06, 2012, 02:47:57 am »
/etc/rc.reload_interfaces in my script causes my 3g ppp connection to restart every 10-20 secs..

Offline stephenw10

  • Hero Member
  • *****
  • Posts: 8165
  • Karma: +7/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #43 on: March 06, 2012, 04:03:37 am »
Can you show us your script?
It should only be run once at boot, I can't see how it could possibly effect the ppp cycling time.  :-\

Steve

Offline jly2680

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #44 on: March 06, 2012, 07:31:58 am »
Code: [Select]
#!/bin/sh
/usr/local/sbin/usb_modeswitch usb_modeswitch -v 1a8d -p 2000 -M "5553424312345678000000000000061e000000000000000000000000000000" -2 "5553424312345679000000000000061b000000020000000000000000000000" -n 1 -W
sleep 5
/etc/rc.reload_interfaces


removing reload interfaces makes my 3g ppp connection stable..is there a place where my script will run first then ppp dials in?or to restart ppp connection after my script run?
i can easily do this with openwrt/ddwrt but i want to try pfsense..
« Last Edit: March 06, 2012, 07:36:05 am by jly2680 »