× NETGEAR will be terminating ReadyCLOUD service by July 1st, 2023. For more details click here.
Orbi WiFi 7 RBE973
Reply

How to connect automaticly as vpn client in readey nas 104

wizhack
Aspirant

How to connect automaticly as vpn client in readey nas 104

Hello i'm using a vpn server and i would like to know how to connect my ready nas automaticly when the nas boot, i'm using hide my a** as vpn service and using the hma script too.

For the moment i have to connect in ssh and ./hma-bla-bla.sh -d (-d for daemonize).

here is the script i'm using for the moment, i had to remove all "sudo" cmd because im connecting as root to my nas,i have to login and select the server manually.

 

Spoiler
#!/bin/bash

trap ctrl_c INT

function ctrl_c() {
echo
echo "Exiting script..."
echo
stty echo
exit 0
}

function showhelp()
{
echo "- Available switches:"
echo "./hma-openvpn.sh -h = Show help"
echo "./hma-openvpn.sh -d = Daemonize OpenVPN"
echo
echo "- Please ensure to have this packages installed:"
echo "  curl, openvpn, wget, dialog"
echo "  e.g.: yum install curl openvpn wget dialog"
echo "    or: apt-get install curl openvpn wget dialog"
echo
}

while getopts "dh" parm
do
        case $parm in
        d)
                daemonize=1
                ;;
        ?)      echo
        echo "HMA-OpenVPN Script"
        echo "=================="
        echo
        showhelp
        exit 0
        ;;
        esac
done


showtitle() {
clear
green="\e[36;5;82m"
stdcol="\e[0m"
echo
echo -e "$green =============================="
echo " |     __  ____  ______    __ |"
echo " |    / / / /  |/  /   |  / / |"
echo " |   / /_/ / /|_/ / /| | / /  |"
echo " |  / __  / /  / / ___ |/_/   |"
echo " | /_/ /_/_/  /_/_/  |_(_)    |"
echo " |                            |"
echo " |     HMA! OpenVPN Script    |"
echo " =============================="
echo
echo "-> https://hidemyass.com/vpn"
echo -e "-> https://support.hidemyass.com$stdcol"
echo
}

showtitle
showhelp

sleep 3
echo "- Getting HMA! Pro VPN serverlist..."
sleep 1
wget -q http://hidemyass.com/vpn-config/l2tp/ -O /tmp/serverlist.txt

LINES=$(cat /tmp/serverlist.txt)

IFS=$'\n\t'
dialog --backtitle "HMA! OpenVPN Script" \
--title "Select a server" \
--menu "Select a server" 17 78 15 $LINES 2>/tmp/hma-server
unset IFS

sleep 1
hmaserver=`cat /tmp/hma-server`
clear

dialog --backtitle "HMA! OpenVPN Script" \
--title "Select protocol" \
--radiolist "Use OpenVPN-TCP (port 443) or OpenVPN-UDP (port 53)?" 10 40 3 UDP "" on TCP "" off 2>/tmp/hma-proto
sleep 1

showtitle
hmaproto=`cat /tmp/hma-proto | tr '[:upper:]' '[:lower:]'`
echo "- Getting .ovpn template..."
echo
sleep 1
wget -O /tmp/hma-template.ovpn http://hmastuff.com/hma-template.ovpn

echo "proto $hmaproto" >> /tmp/hma-template.ovpn

if [ "$hmaproto" == "udp" ]; then
echo "remote $hmaserver 53" >> /tmp/hma-template.ovpn
hmaport=53
fi
if [ "$hmaproto" == "tcp" ]; then
echo "remote $hmaserver 443" >> /tmp/hma-template.ovpn
hmaport=443
fi

showtitle

function checkip()
{
ip=""
attempt=0
while [ "$ip" = "" ]; do
        attempt=$(($attempt+1))
        ip=`curl http://geoip.hidemyass.com/ip/ 2>/dev/null`
        if [ "$ip" != "" ]; then
                echo "- Your current IP is: $ip"
        fi
        if [ $attempt -gt 3 ]; then
                echo "- Failed to check current IP address."
                exit
        fi
done
}

checkip
sleep 1

echo
echo "- Starting OpenVPN connection to: $hmaserver : $hmaport ($hmaproto) ..."
sleep 1
echo

if [ "$daemonize" == "1" ]; then
openvpn --daemon --script-security 3 --config /tmp/hma-template.ovpn
echo
echo "Waiting 10 seconds for doing IP-check..."
sleep 10
echo
checkip
echo
echo "Disconnect via: sudo killall openvpn"
echo
else
openvpn --script-security 3 --config /tmp/hma-template.ovpn
fi

tput sgr0
exit 0

thanks for the help

basicly i would like the script try to connect when i have internet connection, when the power get back in the house for example, wait 1 minute after boot or try to ping google or any website before trying to connect.

Model: RN10400|ReadyNAS 100 Series 4- Bay (Diskless)
Message 1 of 3
JennC
NETGEAR Employee Retired

Re: How to connect automaticly as vpn client in readey nas 104

Hello wizhack,

 

This was posted in August, it appears that something has been changed and done from the backend. I guess it is best to wait for other community members to share their thoughts and experience.

 

Regards,

Message 2 of 3
JennC
NETGEAR Employee Retired

Re: How to connect automaticly as vpn client in readey nas 104

Hello wizhack,

 

Have you received any feedback from any of the members?

 

Regards,

Message 3 of 3
Top Contributors
Discussion stats
  • 2 replies
  • 7105 views
  • 0 kudos
  • 2 in conversation
Announcements