Pi and VPN

Associate
Joined
24 Jul 2009
Posts
2,072
Location
-
Hi, first of all, I think this can be done but I'm not 100% sure.

I have a Pi that isn't doing anything at the minute and I want a VPN connection. Is it possible to install a VPN on the Pi (PIA) and have it constantly running? If it is, can I connect my phone to this Pi so that all traffic is routed through the VPN first before going through my router? Also will I be able to switch between the Pi and router if I don't want my phone going through a VPN?

Hope that make sense.
 
Soldato
Joined
18 Oct 2002
Posts
2,827
Location
Stoke-on-Trent
Associate
OP
Joined
24 Jul 2009
Posts
2,072
Location
-
Thanks, it'll only be for web use mainly. How easy is it to switch between routing through VPN and non-VPN as I won't always need it. Would it require me to change the gateway each time?
 
Soldato
Joined
18 Oct 2002
Posts
2,827
Location
Stoke-on-Trent
Yes I believe the easiest way is to change the gateway as if you stop the vpn service on the pi, the tunnel will know the vpn is down and it will stop routing traffic altogether meaning you'll have no access to the internet.
 
Associate
OP
Joined
24 Jul 2009
Posts
2,072
Location
-
As I won't want this running all of the time, can I skip the the enable VPN at boot part and the VPN kill switch part?

For when I want it running, I would use 'sudo service openvpn start < vpn-name >' to start it and 'sudo service openvpn stop < vpn-name >' to stop it. Would this work? It would be easier than having to change the gateway each time.
 
Soldato
Joined
18 Oct 2002
Posts
2,827
Location
Stoke-on-Trent
As I won't want this running all of the time, can I skip the the enable VPN at boot part and the VPN kill switch part?

For when I want it running, I would use 'sudo service openvpn start < vpn-name >' to start it and 'sudo service openvpn stop < vpn-name >' to stop it. Would this work? It would be easier than having to change the gateway each time.

Yes this would work fine if you don't want it running all the time.
 
Associate
OP
Joined
24 Jul 2009
Posts
2,072
Location
-
Set it up and works perfect. I can enable and disable as I please.

Edit: It did work fine until I rebooted the Pi. Now each time I use the command 'sudo service openvpn start /etc/openvpn/Paris.conf' to start it, I am asked for a username and password despite me adding my username and password for Purevpn to the login file /etc/openvpn/login and adding this line to my VPN file Paris.conf. Sometimes it wont even work when entering the username of password. It does work when I use the test command 'sudo openvpn --config /etc/openvpn/Paris.conf' though without asking for a username or password.

auth-user-pass /etc/openvpn/login

Any ideas?
 
Last edited:
Soldato
Joined
18 Oct 2002
Posts
2,827
Location
Stoke-on-Trent
Set it up and works perfect. I can enable and disable as I please.

Edit: It did work fine until I rebooted the Pi. Now each time I use the command 'sudo service openvpn start /etc/openvpn/Paris.conf' to start it, I am asked for a username and password despite me adding my username and password for Purevpn to the login file /etc/openvpn/login and adding this line to my VPN file Paris.conf. Sometimes it wont even work when entering the username of password. It does work when I use the test command 'sudo openvpn --config /etc/openvpn/Paris.conf' though without asking for a username or password.

auth-user-pass /etc/openvpn/login

Any ideas?

Have you got anymore conf files in the openvpn directory?. If there are more than one than ive found openvpn will try to connect to each one and cause this issue with asking for a username/password. Make sure you've only got one conf file in the openvpn directory.
 
Associate
OP
Joined
24 Jul 2009
Posts
2,072
Location
-
Have you got anymore conf files in the openvpn directory?. If there are more than one than ive found openvpn will try to connect to each one and cause this issue with asking for a username/password. Make sure you've only got one conf file in the openvpn directory.

I did have yes, 5 to be exact as I was testing out different servers. I did see that when I was trying to connect to Ireland, it would show as France when I looked up the IP address. Fixed now though thanks by removing others and going over the guide again. Also used this one: https://www.novaspirit.com/2017/06/22/raspberry-pi-vpn-router-w-pia/
 
Back
Top Bottom