Help: Setting up 3G/WiFi -> VPN -> WiFi

Hi!
Please, help me with setting up my GL-MT300A.

I have a goal to realize next two use cases:

  1. USB-modem -> OpenVPN -> WiFi (for a few devices)
  2. Any WiFi internet -> GL-MT300A (via WiFi) -> OpenVPN -> WiFi (for a few devices)

It works fine when:
3) USB-modem -> Wifi (for a few devices)
4) Home router -> GL-MT300A (via Ethernet) -> OpenVPN -> Wifi (for a few devices)

But I need 1) and 2)
I thought that most users connect router by one of these schemes, and there should be a detailed instruction for this, but unfortunately I did not find anything.

Please, help!

Hi,

As you said it works fine in 3) and 4), I didn’t see there is a problem for 1) and 2).

For 1), you can just enable openvpn in 3)

For 2), you can also connect as repeater and enable openvpn

Another option is to configure the switch on the GL-MT300A to turn on and off OpenVPN. You’ll also want to have the script (that checks the state of the switch) run at startup, so OpenVPN boots up when the router is reset. This way, you don’t have to manually go to the GLI interface to turn on OpenVPN.

Read this thread on how to get it done.

 

 

I reset all settings to factory default. I have firmware 2.24.
Then I connected to GL-MT300A via WiFi, changed the administrator password, SSID and WiFi password.
After reconnecting I plugged the modem and set up 3G in Internet settings.
At this point, everything is OK (I have Internet from 3G modem via GL-MT300A WiFi).

When I added openvpn, the router indicated that openvpn is connected successful, but the Internet on computer is lost.
Here are screenshots of the settings. What’s wrong?
Sorry if I did not make any obvious things.
Please, tell me what to do to make it work.

More screenshots:

And more:

So what with the settings for 3G->vpn->WiFi?
As I understand, these configurations are just a advertising, and no one really uses them :frowning:
I showed setting, they do not work. It remains only to throw the router in the trash…

From your screen shot, the openvpn is connected, isn’t it?

Maybe there is bugs, especially when you compile settings. But these are not for advertising, they does work.

Have you tried plugging in the computer to Ethernet LAN port?

I have successfully been using the GL-AR300M and GL-MT300A with OpenVPN using a tethered iPhone. The OpenVPN connections are bridged to both Wi-Fi and Ethernet.

Now I solved my problem with 3G->VPN->WiFi by selecting “wan” in Interfaces->VPN_CLIENT->Firewall Settings (screenshot setup_2_8.png).

I agree that use switch to turn on/off OpenVPN is a very good idea.

/etc/rc.button/BTN_1:
if [ “${ACTION}” = “pressed” ]; then
uci set glconfig.openvpn.enable=‘1’
uci commit glconfig
/etc/init.d/startvpn restart
/usr/bin/setvpnfirewall –-force
/etc/init.d/firewall reload
elif [ “${ACTION}” = “released” ]; then
uci set glconfig.openvpn.enable=‘0’
uci commit glconfig
/etc/init.d/startvpn stop
/usr/bin/setvpnfirewall –-disable
/etc/init.d/firewall reload
fi

I see that vpn successfully establishes a connection, but the internet stops working.
I think the problem again in the firewall settings or incorrect routing.
Is it even possible to configure VPN on/off for the “3G->VPN->WiFi” using such a simple script?

I compared the logs.
They are identical, except for a few lines:
Mon Jan 9 18:13:20 2017 daemon.notice netifd: Interface ‘VPN_client’ is enabled
Mon Jan 9 18:13:20 2017 daemon.notice netifd: Network device ‘tun0’ link is up
Mon Jan 9 18:13:20 2017 daemon.notice netifd: Interface ‘VPN_client’ has link connectivity
Mon Jan 9 18:13:20 2017 daemon.notice netifd: Interface ‘VPN_client’ is setting up now
Mon Jan 9 18:13:20 2017 daemon.notice netifd: Interface ‘VPN_client’ is now up
Mon Jan 9 18:13:20 2017 user.notice firewall: Reloading firewall due to ifup of VPN_client (tun0)

These lines appear only in the case of start-up vpn from the web-interface.
Any idea how to do it with a script?

I found another alzhao's post and made changes in /etc/rc.button/BTN_1:

#!/bin/sh
if [ “${ACTION}” == “pressed” ]; then
uci set glconfig.openvpn.enable=‘1’
uci commit glconfig
uci set network.VPN_client=interface
uci set network.VPN_client.proto=‘none’
uci set networ.VPN_client.ifname=‘tun0’
uci commit network
/etc/init.d/startvpn restart
/usr/bin/setvpnfirewall –force
elif [ “${ACTION}” == “released” ]; then
uci set glconfig.openvpn.enable=‘0’
uci commit glconfig
/etc/init.d/startvpn stop
/usr/bin/setvpnfirewall –disable
fi

It works.
Now I will check scheme WiFi->VPN->WiFi with switch button.

Glad you made it work.

Thank you!
And I checked WiFi->VPN->WiFi, it works. Just used WISP mode, connecting GLi to the main home router as a Client (another connection is Access Point). The only note is that when I turned VPN on and off using the switch button for the first time, the Internet stopped working. I opened the router settings: Interfaces->VPN_CLIENT and chose “Unmanaged” for Protocol.
After this everything is OK.

Hi gliuser

Thanks for the instructions for using the physical switch to enable/disable the VPN. I implemented your script and I can verify that it works. Unfortunately, I also encountered the problem with a lack of internet connection, but your suggestion of using the “unmanaged” protocol for the VPN_CLIENT did not fix the problem.

I’ll poke at this some more, but I appreciate any insight you may have. For the record, I can still manually enable/disable in the GLI GUI and it all works fine with full internet access.

 

Hi PhilS

Yes, enable/disable the VPN in the GLI GUI always works fine.

Also I checked many times physical switch to enable/disable the VPN and didn’t have any problem.

Disconnection is possible if connecting 3G-modem in a situation when scheme WiFi->VPN->WiFi is active, and vice versa.
In such situations, you should disable and then enable the VPN again. Besides, IMHO should avoid situations with two connections to the Internet simultaneously (WiFi as client + 3G-modem).

Thanks gliuser, but I’m not using 3G, only wifi. The same script should work, right?