Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

How to connect router to usb modem manually after reboot?

Discussion in 'Asuswrt-Merlin' started by chris.at, Sep 21, 2017.

  1. chris.at

    chris.at Occasional Visitor

    Joined:
    Jan 27, 2015
    Messages:
    30
    Location:
    Austria
    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
     
  2. thelonelycoder

    thelonelycoder Part of the Furniture

    Joined:
    Jan 23, 2014
    Messages:
    3,065
    Location:
    In the heart of Switzerland
    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
     
  3. chris.at

    chris.at Occasional Visitor

    Joined:
    Jan 27, 2015
    Messages:
    30
    Location:
    Austria
    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
     
  4. chris.at

    chris.at Occasional Visitor

    Joined:
    Jan 27, 2015
    Messages:
    30
    Location:
    Austria
    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
     
  5. thelonelycoder

    thelonelycoder Part of the Furniture

    Joined:
    Jan 23, 2014
    Messages:
    3,065
    Location:
    In the heart of Switzerland
    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....
     
    chris.at likes this.
  6. chris.at

    chris.at Occasional Visitor

    Joined:
    Jan 27, 2015
    Messages:
    30
    Location:
    Austria
    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
     
  7. thelonelycoder

    thelonelycoder Part of the Furniture

    Joined:
    Jan 23, 2014
    Messages:
    3,065
    Location:
    In the heart of Switzerland
    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.
     
  8. chris.at

    chris.at Occasional Visitor

    Joined:
    Jan 27, 2015
    Messages:
    30
    Location:
    Austria
    So my thoughts weren't so bad at this point, thank you for your confirmation! :)
     

Share This Page