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".
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"
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.
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.
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.
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.
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.
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