Tutorial Check VPN Client Status from Android phone

  • ATTENTION! You'll notice a Prefix dropdown when you create a thread. If your post applies to one of the topics listed, please use that Prefix for your post. When browsing the thread list you can use the Prefix to filter the view.
  • ATTENTION! As of November 1, 2020, you are not able to reply to threads 6 months after the thread is opened if there are more than 500 posts in the thread.
    Threads will not be locked, so posts may still be edited by their authors.
    Just start a new thread on the topic to post if you get an error message when trying to reply to a thread.

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
 

Latest threads

Sign Up For SNBForums Daily Digest

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