What's new

Tutorial Check VPN Client Status from Android phone

  • 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!

Jo Sidarta

Occasional Visitor
Hi,

Thanks to this thread and the developer of SSH Button app

I created a simple script that will allow you to check the router VPN client status from the Android phone.
I installed this on my family phone so that they can check whether the client VPN is running or not (against a specific smart tv) to ensure that they can watch certain regions of movies.

Steps:
1. Login to router through SSH
2. Create a new file and save it into a specific location (in my case: /jffs/scripts/chkVPN) - don't forget to chmod +x to the file
Bash:
#!/bin/sh
#This script will check VPN client status
#Usage: chkVPN <client number>
#E.g: chkVPN 1
#Returned results:
# - Exit 0 for running
# - Exit 1 for not running

status=$(nvram get vpn_client$1_state)

#If running, return 0 so that SSH-Button shows "OK" result
if [ $status -eq 0 ]
then
  echo "VPN $1 is not running - exit 1"
  exit 1
else
  echo "VPN $1 is running - exit 0"
  exit 0
fi

3. Download SSH Button app from Play Store
4. Create a new entry
For example to check VPN client 1, you would put the following command:
Code:
/jffs/scripts/chkVPN 1

SSH_Button_New Entry.jpg


5. Create a widget from this SSH Button and you will be able to see the returned result
When VPN is running:
connected.jpg

When VPN is not runnig:
not connected.jpg
 

Similar threads

Sign Up For SNBForums Daily Digest

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