[Solved]Connect 3G on boot

Hi,
I installed openwrt/LEDE on my r6220 couple days ago.
I use Mobile Broadband/3G as my main connection.

I added a new interface in luci and named it 3g.

Now How can I make it connect to the internet using this interface on boot?
Every time the router is booted, I need to manually click on "Stop" then "connect".


then

I've read the following page.

I've added a new interface in luci instead of editing the wan interface.
but now don't understand how to make it connect automatically.

Also, is there a way to make it reconnect, if the connection drops somehow?

I've read the following and installed mwan3, but having difficulty configuring it correctly.
So your help would be appreciated.

There's no " NetworkMulti-WAN" in Luci

Is this what I want?
I just want it to reconnect if the connection drops.

This is very close to what I want. But didn't understand How I can do it myself.

Thanks for taking the time to read my post.

Have you tried:

If the force link option doesn't work then I think Mwan3 is your best bet.

I think you can just use ifup and ifdown manually on the interface. Maybe putting this to rc.local should help.

ifdown 3g
sleep 3
ifup 3g

There are several "challenges" involved here that a simple "bounce" of the interface (or, for that matter, the modem, which is probably what you need to "poke") may not solve.

  • Linux drivers often can't reliably tell if the link is up or not with a wireless modem
    • Many times you can't "ping" the first-hop router (T-Mobile US as one specific example)
  • Bringing up the modem doesn't mean that it has registered with the network
  • Being registered on the network doesn't always mean you can pass data traffic
  • Modems behave differently with respect to both data protocol (framed vs. raw, for example) and DHCP

Regrettably, there's no "good, clean" solution that I know of.

Several other threads on this board, though some under "4G" or "QMI", rather than "3G"

One "generic" Linux-based OS page that might be helpful is http://www.embeddedpi.com/documentation/3g-4g-modems/raspberry-pi-sierra-wireless-mc7304-modem-qmi-interface-setup It refers to some modem-supervision scripts that can be obtained from a link on that page. (I have not used those scripts myself.)

I also recall reading that "Modem Manager" had been ported once or twice to OpenWRT (as I recall the latest port was said to be reasonably full-featured), but I don't immediately see those links in my bookmarks.

Ah, found it. (I have not used this on OpenWRT):

as well as Google search returning several posts around Modem Manager on OpenWRT on the freedesktop mailing list, such as https://lists.freedesktop.org/archives/modemmanager-devel/2017-September/005699.html

1 Like

ifup 3g says "Interface 3g not found"
even ifconfig doesn't show the 3g interface after boot.

Thanks, I'll definitely look into this.
However, I was wondering if it is possible to do what thos "Stop" and "connect" button do in gui via command. In that case I could easily ad that in rc. And maybe right a script to check internet connection and do those things if no connection.
But not sure what it actually does.

I have dmsg and logread from both after and before pressing those buttons.
Let me know if those will be of any help.

There are two things you need to manage

  • The modem itself
  • The interface that the modem uses

Typically, one manages the modem, then resets/updates the interface once there is a connection. The modem takes commands over a device, and accepts/spews data over another (or a sub-channel). That data stream needs to be connected to an interface so that it can be used for networking.

Take a look at https://openwrt.org/docs/guide-user/network/wan/wwan/ltedongle for some insight into one way to handle this that works for some modems.

1 Like

I didn't quite understand that help text lol.
Let's see if this helps.

Edit: Nope, didn't help.

It seems I need to compile and build my own openwrt image. :frowning:
I can't do that yet, I used a beta prebuilt image from here:
http://downloads.openwrt.org/snapshots/targets/ramips/mt7621/

Is there any way to install modem manager on it?

If the issue is that you cannot install the package, upgrade to a stable version and the software should be available.

I would start with the instructions on the "LTE Modem" page I linked. At least as I understand it, you don't yet have connectivity through the modem. Once you have that up and running, then working on scripts (or switching to Modem Manager) makes sense.

Ok, I'll check that page.
By the way, the modem is working just fine without any scripts or anyhitng.
It's just, I have to Stop the inferface, then Connect evertime I reboot.
So, everything required to make the modem work, is already there. I just needed a way to automate the "Stop", "connect" buttons.

you mean modem manager will be listed in System > Software if I use a stable release?

If it's in the repisitory, yes.

When you are connected to internet then do ifconfig and see which interface is 3G device. In my post I referred to 3g because in LuCI you had 3G listed as an interface. You need to see the actual interface from the ifconfig command first. When you find the interface then put that interface to the ifdown and ifup commands and it will work.

Maybe put a little delay before executing those commands in rc.local. It maybe necessary to let the router register the device before it tries to find the interface. Looking at your original post, I think your 3g interface maybe listed as 3G and that is why it did not find 3g as an interface.

sleep 5 # wait for 5 seconds
ifdown $interface # $interface is your 3g interface
sleep 3
ifup $interface

Also for your question about STOP and CONNECT -- The stop command in LuCI refers to ifdown in command-line and CONNECT refers to ifup.

Hmm ... seems you have a lot of tips, already.
I think, the most standard way would be:

  • network -> interfaces -> your-3g-interface -> advanced-settings -> check "bring up on boot"
  • mwan3 parameters you find unter: network -> load balancing
    -- I'm not sure mwan3 is the right tool for your job, though, since you only have 1 WAN interface (your 3g modem) ... you could maybe do a simple hotplug script. Something along the lines of the following in a file like /etc/hotplug.d/iface/25-my-3g-modem:
if [ "$INTERFACE" = "modem" ] ; then
    if [ "$ACTION" = "ifdown" ] ; then
        sleep 5
        /sbin/ifup modem
    fi
fi

# replace modem with the name of your interface which you can see in /etc/config/network

OP's problem is that modem device doesn't show up in the /etc/config/network because when not connected it is not a physical/logical interface yet. The modem device does show up as /dev/tty/usb0 or something like that. This is the reason ifup and ifdown is not working. I have suggested to use usb_modeswitch to see if that works.

1 Like

Thanks a lot @ahmar16 ! with his help I was finally able to solve the problem.
It turned out that I needed to restart network to make it connect.
so I added

/etc/init.d/network restart

in my rc.local file and it solved the problem.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.