What's new

How to connect router to usb modem manually after reboot?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

chris.at

Regular Contributor
Hello,

I'm using my RT-AC68U in dual wan mode with dsl-modem as primary and lte usb stick als backup device (usb in android mode). So my configuration is dual wan enabled, failover mode with auto-fallback. This works perfectly, but after a reboot the usb modem is listed as "disconnected" and the router doesn't have an ip address on it's usb interface until it switches wan for the first time (which luckily happens very rarely).

Only if the modem was the active wan and then the router switched back to dsl usb's state changes to "standby", router has an ip address (always the same) on usb and I can connect to modems webgui from my lan clients (for this to work I insert one line with firewall start script: iptables -t nat -A POSTROUTING ! -s 192.168.0.153/32 -o usb0 -j MASQUERADE ).

What I want to do now is start the initial connection to the usb modem after a reload without the need to do a failover (unplug dsl) so that I can always reach the modems webgui right from the start.

Does anybody know how this could be done? Is there a command to trigger the usb from "disconnected" to "standby" state manually?

Thank you in advance,
regards,
Chris
 
Servus neighbor!

Assuming your LTE USB stick is the secondary WAN then you can try setting it in NVRAM.
There's no guarantee it will work as some stuff goes on in the background depending on other factors.
My readings are these states:
Standby is:
wan1_sbstate_t=0
wan1_state_t=2

So, setting this in a user script will probably work. Read out the current state first to be able to reset it with:
Code:
nvram get wan1_sbstate_t
nvram get wan1_state_t
Then set it with:
Code:
nvram set wan1_sbstate_t=0
nvram set wan1_state_t=2
 
Grüezi theloneleycoder,

thank you for that hint! I'll give it a try when I get a maintenance window from my family. ;) Will report back if it's working that way.

Best wishes,
Chris
 
Good Morning,

Additionally to your hint I copied all wlan1 variables before and after the reload and compared them, the difference is only here:
wan1_proto_t= (value is "dhcp" when in standby and empty after reload)
wan1_state_t= (value is "2" when in standby and "0" after reload)
wan1_expires= (was 818935 before reload and 775735 after reload)

So after reload (secondary wan was disconnected) I set wan1_state_t to 2 and it changed from disconnected to standby immediately on network map and when I clicked on secondary wan it displayed everything as if it was connected to the modem. But this was only cosmetic, I wasn't able to reach/ping the modem from router cli or network client so in reality the link wasn't established. Also setting proto to dhcp doesn't help.

There must be something inside the code that triggers the initial connection when needed and hopefully this is a command that can be sent manually. But which command is it? Sadly I'm not able to read the code good enough to find the right section and this command needed.

So if there is someone outside knowing the code and could take a look at it (or at least point to the right section so that I could try to read and understand it by myself) I would really appreciate it.

Kind regards,
Chris
 
You can restart the WAN interfaces individually.
Try that with:
Code:
service "restart_wan_if $(nvram get wan_secondary)"
Or directly addressing the interface, 0 = primary, 1 = secondary interface:
Code:
service "restart_wan_if 1"
Do this after setting the NVRAM values.

It _might_ work....
 
Thank you very much thelonelycoder, that's it! :D

Simply sending the restart command _without_ touching the NVRAM variables connects the router to the modem and changes the interface state to standby. Now I can reach the modems webgui, very nice. :) Maybe there is something going wrong during bootup, because I would assume the standby state (together with the missing masquerade for the interface) as initial state after startup.

Now I have to think about where to add this command because firewall-start would result in a loop (this script is called during wan-1-restart). wan-start would possibly also loop (don't know because I have no such script, but the name implies it), maybe nat-start (not called during wan-1-restart but otherwise possibly called when failover to wan-1 occours, so bad idea) or services-start (also don't know, no such script) would do the trick? I'd say lets try services-start with a longer sleep before the restart command.

Best wishes,
Chris
 
Now I have to think about where to add this command because firewall-start would result in a loop (this script is called during wan-1-restart). wan-start would possibly also loop (don't know because I have no such script, but the name implies it), maybe nat-start (not called during wan-1-restart but otherwise possibly called when failover to wan-1 occours, so bad idea) or services-start (also don't know, no such script) would do the trick? I'd say lets try services-start with a longer sleep before the restart command.
services-start is the one you want to employ for that job. This file is only run once when booting. With most or all of the other user scripts they are event driven and may run anytime a state changes.
services-start only runs once.
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top