Skip to content

Instantly share code, notes, and snippets.

@Lazza Lazza/README.md
Last active Sep 10, 2019

Embed
What would you like to do?
VPNGate Python script

vpngate.py

This script allows to use the free VPN service provided by VPNGate in an easy way. The user just needs to provide the desidered output country, and the script automatically chooses the best server.

After this step, OpenVPN is launched with the proper configuration. The VPN can be terminated by pressing Ctrl+C.

Usage

Run the script by providing the desired output country:

vpngate.py US

Both country codes and country names are supported, as listed on the VPNGate website, e.g.:

vpngate.py "United Kingdom"

Moreover, the script allows to input countries with any case (Italy, italy, ItALy all work) and with partial names:

  • Korea will work for Korea Republic Of
  • Russia will work for Russian Federation
  • ... and so on

Demo

Here is a short Youtube video showcasing an example usage:

YT video

Requirements

OpenVPN needs to be installed.

The script should run on any Linux distribution with the Python Requests module installed. The user running the script must be able to run sudo commands in order to start openvpn.

#!/usr/bin/env python
"""Pick server and start connection with VPNGate (http://www.vpngate.net/en/)"""
import requests, os, sys, tempfile, subprocess, base64, time
__author__ = "Andrea Lazzarotto"
__copyright__ = "Copyright 2014+, Andrea Lazzarotto"
__license__ = "GPLv3"
__version__ = "1.0"
__maintainer__ = "Andrea Lazzarotto"
__email__ = "andrea.lazzarotto@gmail.com"
if len(sys.argv) != 2:
print 'usage: ' + sys.argv[0] + ' [country name | country code]'
exit(1)
country = sys.argv[1]
if len(country) == 2:
i = 6 # short name for country
elif len(country) > 2:
i = 5 # long name for country
else:
print 'Country is too short!'
exit(1)
try:
vpn_data = requests.get('http://www.vpngate.net/api/iphone/').text.replace('\r','')
servers = [line.split(',') for line in vpn_data.split('\n')]
labels = servers[1]
labels[0] = labels[0][1:]
servers = [s for s in servers[2:] if len(s) > 1]
except:
print 'Cannot get VPN servers data'
exit(1)
desired = [s for s in servers if country.lower() in s[i].lower()]
found = len(desired)
print 'Found ' + str(found) + ' servers for country ' + country
if found == 0:
exit(1)
supported = [s for s in desired if len(s[-1]) > 0]
print str(len(supported)) + ' of these servers support OpenVPN'
# We pick the best servers by score
winner = sorted(supported, key=lambda s: float(s[2].replace(',','.')), reverse=True)[0]
print "\n== Best server =="
pairs = zip(labels, winner)[:-1]
for (l, d) in pairs[:4]:
print l + ': ' + d
print pairs[4][0] + ': ' + str(float(pairs[4][1]) / 10**6) + ' MBps'
print "Country: " + pairs[5][1]
print "\nLaunching VPN..."
_, path = tempfile.mkstemp()
f = open(path, 'w')
f.write(base64.b64decode(winner[-1]))
f.write('\nscript-security 2\nup /etc/openvpn/update-resolv-conf\ndown /etc/openvpn/update-resolv-conf')
f.close()
x = subprocess.Popen(['sudo', 'openvpn', '--config', path])
try:
while True:
time.sleep(600)
# termination with Ctrl+C
except:
try:
x.kill()
except:
pass
while x.poll() != 0:
time.sleep(1)
print '\nVPN terminated'
@ghost

This comment has been minimized.

Copy link

commented Jul 21, 2016

Hi there, I run with arch linux, with python 3 as the default python, it throws this error.

[geppie@geppie-arch ~]$ ./vpngate.py
File "./vpngate.py", line 22
print 'usage: ' + sys.argv[0] + ' [country name | country code]'
^
SyntaxError: Missing parentheses in call to 'print

what's needed to fix that?

@pranjalAI

This comment has been minimized.

Copy link

commented Jul 24, 2016

Hy @Geptun in python 3 print works as a function so you have to replace print 'usage: ' + sys.argv[0] + ' [country name | country code]'

with print ('usage: ' + sys.argv[0] + ' [country name | country code]')

@devwhatsapp

This comment has been minimized.

Copy link

commented Jul 29, 2016

Can you make this for windows ?

@Franc15

This comment has been minimized.

Copy link

commented Sep 2, 2016

like dat its cool

@MasterCATZ

This comment has been minimized.

Copy link

commented Sep 2, 2016

./vpngate.ph France
Found 5 servers for country France
5 of these servers support OpenVPN

== Best server ==
HostName: vpn609832782
IP: 78.235.96.205
Score: 9516
Ping: -
Speed: 0.0 MBps
Country: France

Launching VPN...
Fri Sep  2 23:26:31 2016 OpenVPN 2.3.10 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [MH] [IPv6] built on Feb  2 2016
Fri Sep  2 23:26:31 2016 library versions: OpenSSL 1.0.2g-fips  1 Mar 2016, LZO 2.08
Fri Sep  2 23:26:31 2016 WARNING: No server certificate verification method has been enabled.  See http://openvpn.net/howto.html#mitm for more info.
Fri Sep  2 23:26:31 2016 NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Fri Sep  2 23:26:31 2016 Socket Buffers: R=[87380->87380] S=[16384->16384]
Fri Sep  2 23:26:31 2016 Attempting to establish TCP connection with [AF_INET]78.235.96.205:1529 [nonblock]
Fri Sep  2 23:26:32 2016 TCP connection established with [AF_INET]78.235.96.205:1529
Fri Sep  2 23:26:32 2016 TCPv4_CLIENT link local: [undef]
Fri Sep  2 23:26:32 2016 TCPv4_CLIENT link remote: [AF_INET]78.235.96.205:1529
Fri Sep  2 23:26:32 2016 TLS: Initial packet from [AF_INET]78.235.96.205:1529, sid=0d106267 d8500a69
Fri Sep  2 23:26:32 2016 VERIFY OK: depth=0, CN=54nh715hprfx.org, O=t2akbbviuk f77c, C=US
Fri Sep  2 23:26:33 2016 Data Channel Encrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Fri Sep  2 23:26:33 2016 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Fri Sep  2 23:26:33 2016 Data Channel Decrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Fri Sep  2 23:26:33 2016 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Fri Sep  2 23:26:33 2016 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 2048 bit RSA
Fri Sep  2 23:26:33 2016 [54nh715hprfx.org] Peer Connection Initiated with [AF_INET]78.235.96.205:1529
Fri Sep  2 23:26:35 2016 SENT CONTROL [54nh715hprfx.org]: 'PUSH_REQUEST' (status=1)
Fri Sep  2 23:26:35 2016 PUSH: Received control message: 'PUSH_REPLY,ping 3,ping-restart 10,ifconfig 10.211.1.21 10.211.1.22,dhcp-option DNS 10.211.254.254,dhcp-option DNS 8.8.8.8,route-gateway 10.211.1.22,redirect-gateway def1'
Fri Sep  2 23:26:35 2016 OPTIONS IMPORT: timers and/or timeouts modified
Fri Sep  2 23:26:35 2016 OPTIONS IMPORT: --ifconfig/up options modified
Fri Sep  2 23:26:35 2016 OPTIONS IMPORT: route options modified
Fri Sep  2 23:26:35 2016 OPTIONS IMPORT: route-related options modified
Fri Sep  2 23:26:35 2016 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Fri Sep  2 23:26:35 2016 ROUTE_GATEWAY 37.59.36.254/255.255.255.0 IFACE=eth0 HWADDR=00:22:4d:7b:49:d0
Fri Sep  2 23:26:35 2016 TUN/TAP device tun0 opened
Fri Sep  2 23:26:35 2016 TUN/TAP TX queue length set to 100
Fri Sep  2 23:26:35 2016 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Fri Sep  2 23:26:35 2016 /sbin/ip link set dev tun0 up mtu 1500
Fri Sep  2 23:26:35 2016 /sbin/ip addr add dev tun0 local 10.211.1.21 peer 10.211.1.22
Fri Sep  2 23:26:35 2016 /etc/openvpn/update-resolv-conf tun0 1500 1559 10.211.1.21 10.211.1.22 init
Fri Sep  2 23:26:35 2016 /sbin/ip route add 78.235.96.205/32 via x.x.x.254
Fri Sep  2 23:26:35 2016 /sbin/ip route add 0.0.0.0/1 via 10.211.1.22

and then I lost connection to my box

@Lazza

This comment has been minimized.

Copy link
Owner Author

commented Sep 12, 2016

@devwhatsapp use Linux.

@MasterCATZ, which "box"? Are you running vpngate.py on a remote server via SSH? I am not sure that is going to work.

@matyapiro31

This comment has been minimized.

Copy link

commented Oct 30, 2016

You may use nmcli command.Using it, you can run command without sudo.

@hpc-nuist-ap

This comment has been minimized.

Copy link

commented Nov 19, 2016

What's wrong?

C:\Users\Xin Zhang>vpn.py "United Kingdom"
  File "C:\Users\Xin Zhang\vpn.py", line 45
    print (str(len(supported)) + ' of these servers support OpenVPN')
             ^
SyntaxError: invalid character in identifier
@fezu95

This comment has been minimized.

Copy link

commented Dec 2, 2016

I keep getting the following error message. Can someone tell me what is the issue?
`federico@federico-ThinkPad-X230 ~/Downloads $ ./vpngate.py italy

bash: ./vpngate.py: Permission denied
`

@Gouenji

This comment has been minimized.

Copy link

commented Jan 6, 2017

instead of ./vpngate.py italy
use
sudo vpngate.py italy

@chaitanyakush

This comment has been minimized.

Copy link

commented Jan 7, 2017

First make it executable by typing "chmod +x vpngate.py" in vpngate direcotery.

@chaitanyakush

This comment has been minimized.

Copy link

commented Jan 7, 2017

I am facing this error
Traceback (most recent call last):
File "./vpngate.py", line 38, in
desired = [s for s in servers if country.lower() in s[i].lower()]
IndexError: list index out of range

@gg4u

This comment has been minimized.

Copy link

commented Feb 3, 2017

Could you post an example on how to requests specific urls / domains against through a vpn server?
I don't want to tunnel all traffic.

@Lazza

This comment has been minimized.

Copy link
Owner Author

commented Jun 29, 2017

I've fixed a bug in the ordering criterion. Thanks to Eyal Foni for writing me about this issue.

@chrufru

This comment has been minimized.

Copy link

commented Aug 19, 2017

Hello Lazza,

i have Python 3.6.2. The Script is not working regardless as pranjalAI saying: the print option need to be in brackets (). So i have all the print functions go to work but at the end of the skript i have an error mesage: "TypeError: expected bytes-like object, not list"

After 2 hours i can't get the script to work on new python version. Please help. I'm abslolute newbe in phython. Here is the complete edited script:

#!/usr/bin/env python

"""Pick server and start connection with VPNGate (http://www.vpngate.net/en/)"""

import requests, os, sys, tempfile, subprocess, base64, time

author = "Andrea Lazzarotto"
copyright = "Copyright 2014+, Andrea Lazzarotto"
license = "GPLv3"
version = "1.0"
maintainer = "Andrea Lazzarotto"
email = "andrea.lazzarotto@gmail.com"

if len(sys.argv) != 2:
print ('usage: ' + sys.argv[0] + ' [country name | country code]')
exit(1)
country = sys.argv[1]

if len(country) == 2:
i = 6 # short name for country
elif len(country) > 2:
i = 5 # long name for country
else:
print ('Country is too short!')
exit(1)

try:
vpn_data = requests.get('http://www.vpngate.net/api/iphone/').text.replace('\r','')
servers = [line.split(',') for line in vpn_data.split('\n')]
labels = servers[1]
labels[0] = labels[0][1:]
servers = [s for s in servers[2:] if len(s) > 1]
except:
print ('Cannot get VPN servers data')
exit(1)

desired = [s for s in servers if country.lower() in s[i].lower()]
found = len(desired)
print ('Found ' + str(found) + ' servers for country ' + country)
if found == 0:
exit(1)

supported = ([s for s in desired if len(s[-1]) > 0])
print (str(len(supported)) + ' of these servers support OpenVPN')

winner = (sorted(supported, key=lambda s: float(s[2].replace(',','.')),
reverse=True)[0])

print ("\n== Best server ==")

pairs = list(zip(labels, winner))[:-1]
for (l, d) in pairs[:4]:
print (l + ': ' + d)

print (pairs[4][0] + ': ' + str(float(pairs[4][1]) / 10**6) + ' MBps')
print ("Country: " + pairs[5][1])

print ("\nLaunching VPN...")
_, path = tempfile.mkstemp()

f = open(path, 'w')
f.write(base64.b64decode(winner[-1]))
f.write('\nscript-security 2\nup /etc/openvpn/update-resolv-conf\ndown /etc/openvpn/update-resolv-conf')
f.close()

x = subprocess.Popen(['sudo', 'openvpn', '--config', path])

try:
while True:
time.sleep(600)

except:
try:
x.kill()
except:
pass
while x.poll() != 0:
time.sleep(1)
print ('\nVPN terminated')

@chrufru

This comment has been minimized.

Copy link

commented Aug 19, 2017

Hello Lazza,

i have found a converter script: "2to3"
but when i run your code to the converter, i get the same Error mesagge:

Launching VPN...
Traceback (most recent call last):
File "./vpngate.py", line 61, in
f.write(base64.b64decode(winner[-1]))
TypeError: write() argument must be str, not bytes

@nguyenkhacbaoanh

This comment has been minimized.

Copy link

commented Sep 5, 2017

chrufru: you must change argument of open in line 60 to "wb" and add b in front of string on line 62: All like this:
f = open(path, 'wb')
f.write(base64.b64decode(winner[-1]))
f.write(b'\nscript-security 2\nup /etc/openvpn/update-resolv-conf\ndown /etc/openvpn/update-resolv-conf')
f.close()

@nguyenkhacbaoanh

This comment has been minimized.

Copy link

commented Sep 5, 2017

someone can help me: I have launched VPN but it show me must entry password for sudo, when i finished, it just showed: "sudo: openvpn : commande introuvable"

@uyogesh

This comment has been minimized.

Copy link

commented Mar 9, 2018

Can I change my ip address periodically??

@stevensdotb

This comment has been minimized.

Copy link

commented Jul 8, 2018

Hi, I would like to use your code. How often is this project updated? What is the advantage and disadvantage when I use it and situations that I can find (failures, etc)?.
My best regards.

@stevensdotb

This comment has been minimized.

Copy link

commented Jul 8, 2018

Having python 3.x installed, use 2to3 package to convert the file for python 3.x
Line 50 for python 3 must be -> pairs = list(zip(labels, winner))[:-1]
Line 61 for python 3 must be -> f.write(base64.b64decode(winner[-1]).decode('utf-8'))

@FrancHR

This comment has been minimized.

Copy link

commented Jan 12, 2019

Can't get to work. I have different returns.
Sometimes is:
AUTH: Received control message: AUTH_FAILED
SIGTERM[soft,auth-failure] received, process exiting

in this case:
WARNING: Failed running command (--up/--down): could not execute external program

./vpngate.py US

Found 5 servers for country US
5 of these servers support OpenVPN

== Best server ==
HostName: vpn605585772
IP: 173.218.24.64
Score: 424095
Ping: 47
Speed: 16.242415 MBps
Country: United States

Launching VPN...
Sat Jan 12 17:59:12 2019 OpenVPN 2.4.3 arm-oe-linux-gnueabi [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [MH/PKTINFO] [AEAD] built on Jan  5 2019
Sat Jan 12 17:59:12 2019 library versions: OpenSSL 1.0.2m  2 Nov 2017, LZO 2.10
Sat Jan 12 17:59:12 2019 WARNING: No server certificate verification method has been enabled.  See http://openvpn.net/howto.html#mitm for more info.
Sat Jan 12 17:59:12 2019 NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Sat Jan 12 17:59:12 2019 TCP/UDP: Preserving recently used remote address: [AF_INET]173.218.24.64:995
Sat Jan 12 17:59:12 2019 Socket Buffers: R=[87380->87380] S=[16384->16384]
Sat Jan 12 17:59:12 2019 Attempting to establish TCP connection with [AF_INET]173.218.24.64:995 [nonblock]
Sat Jan 12 17:59:13 2019 TCP connection established with [AF_INET]173.218.24.64:995
Sat Jan 12 17:59:13 2019 TCP_CLIENT link local: (not bound)
Sat Jan 12 17:59:13 2019 TCP_CLIENT link remote: [AF_INET]173.218.24.64:995
Sat Jan 12 17:59:13 2019 TLS: Initial packet from [AF_INET]173.218.24.64:995, sid=3e78cfb9 5b8a9522
Sat Jan 12 17:59:13 2019 VERIFY OK: depth=2, C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Certification Authority
Sat Jan 12 17:59:13 2019 VERIFY OK: depth=1, C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Domain Validation Secure Server CA
Sat Jan 12 17:59:13 2019 VERIFY OK: depth=0, OU=Domain Control Validated, OU=PositiveSSL Wildcard, CN=*.opengw.net
Sat Jan 12 17:59:14 2019 Control Channel: TLSv1.2, cipher TLSv1/SSLv3 ECDHE-RSA-AES256-GCM-SHA384, 2048 bit RSA
Sat Jan 12 17:59:14 2019 [*.opengw.net] Peer Connection Initiated with [AF_INET]173.218.24.64:995
Sat Jan 12 17:59:15 2019 SENT CONTROL [*.opengw.net]: 'PUSH_REQUEST' (status=1)
Sat Jan 12 17:59:16 2019 PUSH: Received control message: 'PUSH_REPLY,ping 3,ping-restart 10,ifconfig 10.211.1.121 10.211.1.122,dhcp-option DNS 10.211.254.254,dhcp-option DNS 8.8.8.8,route-gateway 10.211.1.122,redirect-gateway def1'
Sat Jan 12 17:59:16 2019 OPTIONS IMPORT: timers and/or timeouts modified
Sat Jan 12 17:59:16 2019 OPTIONS IMPORT: --ifconfig/up options modified
Sat Jan 12 17:59:16 2019 OPTIONS IMPORT: route options modified
Sat Jan 12 17:59:16 2019 OPTIONS IMPORT: route-related options modified
Sat Jan 12 17:59:16 2019 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Sat Jan 12 17:59:16 2019 Data Channel Encrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Sat Jan 12 17:59:16 2019 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Sat Jan 12 17:59:16 2019 Data Channel Decrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Sat Jan 12 17:59:16 2019 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Sat Jan 12 17:59:16 2019 ROUTE_GATEWAY 192.168.8.1/255.255.255.0 IFACE=eth0 HWADDR=00:17:6b:33:4b:6c
Sat Jan 12 17:59:16 2019 TUN/TAP device tun0 opened
Sat Jan 12 17:59:16 2019 TUN/TAP TX queue length set to 100
Sat Jan 12 17:59:16 2019 do_ifconfig, tt->did_ifconfig_ipv6_setup=0
Sat Jan 12 17:59:16 2019 /sbin/ip link set dev tun0 up mtu 1500
Sat Jan 12 17:59:16 2019 /sbin/ip addr add dev tun0 local 10.211.1.121 peer 10.211.1.122
Sat Jan 12 17:59:16 2019 /etc/openvpn/update-resolv-conf tun0 1500 1559 10.211.1.121 10.211.1.122 init
**Sat Jan 12 17:59:16 2019 WARNING: Failed running command (--up/--down): could not execute external program**
Sat Jan 12 17:59:16 2019 Exiting due to fatal error
@rubibursdasdas

This comment has been minimized.

Copy link

commented Jan 25, 2019

Uh, somebody can help me?

C:\Users\Paula>D:\a\vpngate.py Japan
Found 24 servers for country Japan
24 of these servers support OpenVPN

== Best server ==
HostName: vpn341839515
IP: 153.129.202.42
Score: 1418757
Ping: 5
Speed: 194.085579 MBps
Country: Japan

Launching VPN...
Traceback (most recent call last):
File "D:\a\vpngate.py", line 65, in
x = subprocess.Popen(['sudo', 'openvpn', '--config', path])
File "C:\Users\Paula\AppData\Local\Programs\Python\Python37-32\lib\subprocess.
py", line 756, in init
restore_signals, start_new_session)
File "C:\Users\Paula\AppData\Local\Programs\Python\Python37-32\lib\subprocess.
py", line 1155, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] El sistema no puede encontrar el archivo especif
icado

@allin8

This comment has been minimized.

Copy link

commented Feb 25, 2019

@devwhatsapp use Linux.

@MasterCATZ, which "box"? Are you running vpngate.py on a remote server via SSH? I am not sure that is going to work.
./vpngate.py US with extension vpngate_US.sh ;) or other country

@allin8

This comment has been minimized.

Copy link

commented Feb 25, 2019

./vpngate.py US witth extesnions sh like vpngate_US.sh

@xenowing

This comment has been minimized.

Copy link

commented Apr 19, 2019

is this still working?

@chetanDhongade

This comment has been minimized.

Copy link

commented Apr 24, 2019

I modified script to work on the python3 and also include the function to select the desired server from the list. Below I provided a link to the screen shot of the image :
Imgur

feel free to take a look at the code:
vpngate.py

@pittu2752

This comment has been minimized.

Copy link

commented May 22, 2019

Hi, I need to add views to a website changing Ip for every get, how can I do this with openvpn?

@kia4king

This comment has been minimized.

Copy link

commented Jun 18, 2019

Any licence?

@Lazza

This comment has been minimized.

Copy link
Owner Author

commented Jun 18, 2019

The license is specified in the script metadata. 😄

@ajinkya8484

This comment has been minimized.

Copy link

commented Jun 26, 2019

someone can help me: I have launched VPN but it show me must entry password for sudo, when i finished, it just showed: "sudo: openvpn : commande introuvable"

make sure that you have openvpn installed in system
otherwise use
sudo apt-get install openvpn

@ajinkya8484

This comment has been minimized.

Copy link

commented Jun 28, 2019

@lizzardarcher

This comment has been minimized.

Copy link

commented Aug 6, 2019

Hello lazza, i've tried this code, but it ruins with following:

Found 40 servers for country korea
40 of these servers support OpenVPN

== Best server ==
### Traceback (most recent call last):
File "./VPNGate.py", line 49, in
pairs = zip(labels, winner)[:-1]
TypeError: 'zip' object is not subscriptable

is anything to do with it?

@Lazza

This comment has been minimized.

Copy link
Owner Author

commented Aug 9, 2019

What Python version are you using?

@lizzardarcher

This comment has been minimized.

Copy link

commented Aug 9, 2019

3.7 for now
I'll try some previous versions
Maybe it will help
""" I've tried 2.7 but it didn't help """

@JonnyBanana

This comment has been minimized.

Copy link

commented Aug 10, 2019

Hi there, I run with arch linux, with python 3 as the default python, it throws this error.

[geppie@geppie-arch ~]$ ./vpngate.py
File "./vpngate.py", line 22
print 'usage: ' + sys.argv[0] + ' [country name | country code]'
^
SyntaxError: Missing parentheses in call to 'print

what's needed to fix that?

to fix it, just enter the parentheses in the print command, for example
print ("\nLaunching VPN...")

this is because the code is written for python 2, while you use python 3

@Lazza

This comment has been minimized.

Copy link
Owner Author

commented Aug 10, 2019

I've tried 2.7 but it didn't help

It's normal that it doesn't work with Python 3, however it should work with Python 2.

@Arrmlet

This comment has been minimized.

Copy link

commented Aug 16, 2019

Hello I run the script but its not changing my ip.
TCP: connect to [AF_INET]135.180.78.77:1557 failed, will try again in 5 seconds: No route to host
When script is connecting:
I got this
Fri Aug 16 13:57:46 2019 SENT CONTROL [*.opengw.net]: 'PUSH_REQUEST' (status=1) Fri Aug 16 13:57:46 2019 AUTH: Received control message: AUTH_FAILED Fri Aug 16 13:57:46 2019 SIGTERM[soft,auth-failure] received, process exiting

@Lazza

This comment has been minimized.

Copy link
Owner Author

commented Aug 18, 2019

No route to host

Well, if that specific server is unreachable, connect to some other one. 😉

@nabobalis

This comment has been minimized.

Copy link

commented Sep 9, 2019

I also get the same issue as above about Auth failing but I do have a route to the server.

Mon Sep  9 10:28:39 2019 OpenVPN 2.4.6 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on May 14 2019
Mon Sep  9 10:28:39 2019 library versions: OpenSSL 1.1.1b  26 Feb 2019, LZO 2.10
Mon Sep  9 10:28:39 2019 WARNING: No server certificate verification method has been enabled.  See http://openvpn.net/howto.html#mitm for more info.
Mon Sep  9 10:28:39 2019 NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Mon Sep  9 10:28:39 2019 TCP/UDP: Preserving recently used remote address: [AF_INET]37.120.154.37:443
Mon Sep  9 10:28:39 2019 Socket Buffers: R=[131072->131072] S=[16384->16384]
Mon Sep  9 10:28:39 2019 Attempting to establish TCP connection with [AF_INET]37.120.154.37:443 [nonblock]
Mon Sep  9 10:28:40 2019 TCP connection established with [AF_INET]37.120.154.37:443
Mon Sep  9 10:28:40 2019 TCP_CLIENT link local: (not bound)
Mon Sep  9 10:28:40 2019 TCP_CLIENT link remote: [AF_INET]37.120.154.37:443
Mon Sep  9 10:28:41 2019 TLS: Initial packet from [AF_INET]37.120.154.37:443, sid=c62bf252 2beead48
Mon Sep  9 10:28:41 2019 VERIFY OK: depth=2, C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Certification Authority
Mon Sep  9 10:28:41 2019 VERIFY OK: depth=1, C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Domain Validation Secure Server CA
Mon Sep  9 10:28:41 2019 VERIFY OK: depth=0, OU=Domain Control Validated, OU=PositiveSSL Wildcard, CN=*.opengw.net
Mon Sep  9 10:28:42 2019 Control Channel: TLSv1.2, cipher TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384, 2048 bit RSA
Mon Sep  9 10:28:42 2019 [*.opengw.net] Peer Connection Initiated with [AF_INET]37.120.154.37:443
Mon Sep  9 10:28:43 2019 SENT CONTROL [*.opengw.net]: 'PUSH_REQUEST' (status=1)
Mon Sep  9 10:28:43 2019 AUTH: Received control message: AUTH_FAILED
Mon Sep  9 10:28:43 2019 SIGTERM[soft,auth-failure] received, process exiting
@Lazza

This comment has been minimized.

Copy link
Owner Author

commented Sep 9, 2019

Folks, if you have issues with specific servers please get in touch with VPNGate: https://www.vpngate.net/en/

@nabobalis

This comment has been minimized.

Copy link

commented Sep 9, 2019

So that is not something I have to set locally in the script? It is an upstream issue?

@Lazza

This comment has been minimized.

Copy link
Owner Author

commented Sep 9, 2019

The script simply reads the list located at https://www.vpngate.net/api/iphone/ and filters it by country. It cannot tell whether all nodes are working correctly or not.

You should not need to set anything locally.

@nabobalis

This comment has been minimized.

Copy link

commented Sep 9, 2019

Thanks for the help!

@Qurram555

This comment has been minimized.

Copy link

commented Sep 10, 2019

Hi All, How we can add certificates like ca.crt/client.crt and an option 'auth-nocache option' to protect the password to this module?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.