StarshipEngineer
Posts: 3
Joined: Sun Feb 21, 2016 3:32 am

Automated OpenVPN Server Setup Script

Tue Feb 23, 2016 12:14 pm

I've put together a script that configures OpenVPN on the Raspberry Pi to turn it into a personal VPN server. It is located here:

https://github.com/StarshipEngineer/OpenVPN-Setup

I'm hoping that users can discuss, collaborate, and resolve issues and feature ideas here! I'd love to share the project with the community, give users an easier place to discuss things than GitHub comments, and provide another forum for feedback.

ccclapp
Posts: 14
Joined: Sun Jan 31, 2016 4:46 am
Location: Boston

Re: Automated OpenVPN Server Setup Script

Wed Feb 24, 2016 4:13 am

Ok, I am happy to be the 1st to chime in...
I am fairly new at RPi/scripting, (but do advanced home automation, etc). I needed VPN on a RPi to put at remote locations. I tried several how-to's here and elsewhere. Several are good, but all are outdated. After two days, (and 3-years of reader-comments/corrections) I never succeeded getting OpenVPN on a RPi up and running (I did get a PPTP VPN, which is significantly easier, but does not compare to OpenVPN).

Then I came upon this solution and tried it...f-ing fantastic!

This is literally a plug-n-play install, with occasional dialog boxes to fill in key config data. It took about 30 min (2nd time will be 10 min) to install VPN, create site certificate and client certs. Then it places the client cert (.oven file...forget the actual name, but its the one you need to install on your client computer/tablet/phone) in your Home/Pi directory on RPi to export to your client device. As I said,...fantastic!

I wrote to developer and encouraged he start this thread for comments/questions. Glad to leave the 1st.

judaca
Posts: 3
Joined: Wed Feb 24, 2016 7:05 am

Re: Automated OpenVPN Server Setup Script

Mon Feb 29, 2016 6:41 am

Installing is verry easy, but when i reboot my PI it fails to start the vpn server ....

ccclapp
Posts: 14
Joined: Sun Jan 31, 2016 4:46 am
Location: Boston

Re: Automated OpenVPN Server Setup Script

Mon Feb 29, 2016 7:30 am

...do you mean at the reboot which occurs during the install of after you've generated the client cert and are 100% done?

judaca
Posts: 3
Joined: Wed Feb 24, 2016 7:05 am

Re: Automated OpenVPN Server Setup Script

Mon Feb 29, 2016 8:09 pm

After 100% done

ccclapp
Posts: 14
Joined: Sun Jan 31, 2016 4:46 am
Location: Boston

Re: Automated OpenVPN Server Setup Script

Mon Feb 29, 2016 9:20 pm

on the latest version of jessie, the service starts on boot for me without issue.

Since the script is so easy to install, and has an uninstaller, you might uninstall/reinstall

as described in the readme, to get to the options dialog (to pick install/add client cert/uninstall) you do:

Code: Select all

cd OpenVPN-Setup
then
sudo ./openvpnsetup.sh
As you likely know, to verify the service is running you do:

Code: Select all

service openvpn status
to start/stop/restart do
sudo service openvpn start (or stop or restart)
I believe

Brewmaster9
Posts: 11
Joined: Thu Mar 03, 2016 11:11 am

Re: Automated OpenVPN Server Setup Script

Thu Mar 03, 2016 11:26 am

Hi,

Many thanks for the script. I've installed openvnp and checked that it run on reboot etc. However, I can't access the server (I've tried a number of clients to check). The client runs fine, but gets no replies from my server. I have set static ip, port forward rules on my router. It seems that port 1194 isn't open?

Regards
Graham

TeeSee64
Posts: 16
Joined: Fri Mar 07, 2014 10:01 am

Re: Automated OpenVPN Server Setup Script

Thu Mar 03, 2016 5:23 pm

Thank you for this script, very usefull.

Only I cant get the vpn server start on boot. When I reboot the RPI, I need to manualy start the server with this command: sudo service openvpn start

I have tried to un-install and re-install. Also tried to delete everything on my sd-card and re-install the vpn server, but no luck. When I start the server manualy, everything is working great.

I there another way to make the vpn server start at boot?

Thanks in advance!

Brewmaster9
Posts: 11
Joined: Thu Mar 03, 2016 11:11 am

Re: Automated OpenVPN Server Setup Script

Thu Mar 03, 2016 5:29 pm

That happened to me. Did you re-boot before before creating your client keys?
My server runs fine at boot, but port 1194 doesn't open.
TeeSee64 wrote:Thank you for this script, very usefull.

Only I cant get the vpn server start on boot. When I reboot the RPI, I need to manualy start the server with this command: sudo service openvpn start

I have tried to un-install and re-install. Also tried to delete everything on my sd-card and re-install the vpn server, but no luck. When I start the server manualy, everything is working great.

I there another way to make the vpn server start at boot?

Thanks in advance!

ccclapp
Posts: 14
Joined: Sun Jan 31, 2016 4:46 am
Location: Boston

Re: Automated OpenVPN Server Setup Script

Thu Mar 03, 2016 5:33 pm

Hi I'm just a user not the OP. However, I was impressed with how easily this installed, how easily these client certificates were created and how well it worked on my client machines. It has loaded at boot flawlessly for me.

I believe the README strongly recommends running the most current version of Jesse. That's what I am running and I've had no problems.

At the top of this thread is the link to the git-hub site. You might reach out to the ORP/developer there and suggest he reply on this thread.

He has been pretty responsive when I had a couple questions early on

TeeSee64
Posts: 16
Joined: Fri Mar 07, 2014 10:01 am

Re: Automated OpenVPN Server Setup Script

Thu Mar 03, 2016 6:09 pm

Brewmaster9 wrote:That happened to me. Did you re-boot before before creating your client keys?
My server runs fine at boot, but port 1194 doesn't open.
TeeSee64 wrote:Thank you for this script, very usefull.

Only I cant get the vpn server start on boot. When I reboot the RPI, I need to manualy start the server with this command: sudo service openvpn start

I have tried to un-install and re-install. Also tried to delete everything on my sd-card and re-install the vpn server, but no luck. When I start the server manualy, everything is working great.

I there another way to make the vpn server start at boot?

Thanks in advance!
Yes I reboot the RPI before creating client keys. And Im using the latest version of Noobs/Jesse on my model B RPI.

Port 1194 is open, maby you need to forward the port in your router? I had to set the Port Triggering in my router for port 1194 also.

Brewmaster9
Posts: 11
Joined: Thu Mar 03, 2016 11:11 am

Re: Automated OpenVPN Server Setup Script

Thu Mar 03, 2016 7:26 pm

Many thanks for the reply. I've checked both port forward and triggering settings and they are set up for 1194 and set to the MAC address of the pi in question. When I look at the ports on the pi, 1194 doesn't show as listening (22 for ssh etc are listed ok).

Regarding your boot issue, I've just installed on a fresh sd card from the latest NOOBS 1.8 and it re-boots fine. Wonder if your script has corrupted?

TeeSee64
Posts: 16
Joined: Fri Mar 07, 2014 10:01 am

Re: Automated OpenVPN Server Setup Script

Thu Mar 03, 2016 9:27 pm

SOLVED!:

I found a solution for my problem...

it is all in this blog post
https://2ellsblog.wordpress.com/2016/02 ... up-script/

With the 5 seconds delay build in as told in the blog post, it's working 100%. I can reboot the rpi and the vpn comes active.

Brewmaster9
Posts: 11
Joined: Thu Mar 03, 2016 11:11 am

Re: Automated OpenVPN Server Setup Script

Fri Mar 04, 2016 2:04 pm

Good news. Still can't seem to open port 1194 on mine.
TeeSee64 wrote:SOLVED!:

I found a solution for my problem...

it is all in this blog post
https://2ellsblog.wordpress.com/2016/02 ... up-script/

With the 5 seconds delay build in as told in the blog post, it's working 100%. I can reboot the rpi and the vpn comes active.

TeeSee64
Posts: 16
Joined: Fri Mar 07, 2014 10:01 am

Re: Automated OpenVPN Server Setup Script

Fri Mar 04, 2016 9:19 pm

Brewmaster9 wrote:Good news. Still can't seem to open port 1194 on mine.
TeeSee64 wrote:SOLVED!:

I found a solution for my problem...

it is all in this blog post
https://2ellsblog.wordpress.com/2016/02 ... up-script/

With the 5 seconds delay build in as told in the blog post, it's working 100%. I can reboot the rpi and the vpn comes active.
Maybe a stuppid question....
But did you reboot your router after you forward the ports?

Brewmaster9
Posts: 11
Joined: Thu Mar 03, 2016 11:11 am

Re: Automated OpenVPN Server Setup Script

Sat Mar 05, 2016 12:09 am

Yes, re-booted a couple of times.

KarsenH
Posts: 1
Joined: Sun Mar 06, 2016 4:17 am

Re: Automated OpenVPN Server Setup Script

Sun Mar 06, 2016 4:18 am

http://readwrite.com/2014/04/10/raspber ... b-browsing
This should help you set up a VPN server

metrekup
Posts: 2
Joined: Sun Mar 06, 2016 3:30 pm

Re: Automated OpenVPN Server Setup Script

Sun Mar 06, 2016 4:33 pm

Hi , i am tryin to install openvpn on raspberry pi b+ . While i installing vpn from http://readwrite.com/2014/04/10/raspber ... b-browsing manually, i have an error. There is no folder like under here :/usr/share/doc/openvpn/examples/easy-rsa/2.0 ,so i think that if i cant install with this way, i must use script. But script has an error. So i cant install openvpn anyway. Here is the output of the script:http://paste.ubuntu.com/15308993/
What must i do?
Sorry for my English

metrekup
Posts: 2
Joined: Sun Mar 06, 2016 3:30 pm

Re: Automated OpenVPN Server Setup Script

Sun Mar 06, 2016 4:38 pm

this script is not working. can anyone help me?
here is the output of the script:http://paste.ubuntu.com/15308993/

before using script , i tried install manually but there is no folder like that:/usr/share/doc/openvpn/examples/easy-rsa/2.0

Sorry for my English.

ccclapp
Posts: 14
Joined: Sun Jan 31, 2016 4:46 am
Location: Boston

Re: Automated OpenVPN Server Setup Script

Sun Mar 06, 2016 4:44 pm

FYI
I had initially tried to follow the tutorial you link to just above and found it to be out of date and with errors. After a couple days of trying I found this automated install ( which references the above tutorial as a source,so likely grabs and corrects from that). This automated install has been flawless for me

StarshipEngineer
Posts: 3
Joined: Sun Feb 21, 2016 3:32 am

Re: Automated OpenVPN Server Setup Script

Mon Mar 07, 2016 1:40 am

metrekup, That tutorial is a bit out of date. It was written a couple years ago to run on Raspbian Wheezy. This script is updated for Raspbian Jessie, including its different directory structure and some differences in packages. Most I have heard from have not had a problem getting their VPN up and running on Jessie with this script, although I am researching the port 1194 issue.

yiftah
Posts: 5
Joined: Mon Mar 07, 2016 12:40 am

Re: Automated OpenVPN Server Setup Script

Mon Mar 07, 2016 2:26 am

On this topic I also added a method to punch a hole for the VPN server in case you do not have a dedicated ip address to your home anyone interested?

Brewmaster9
Posts: 11
Joined: Thu Mar 03, 2016 11:11 am

Re: Automated OpenVPN Server Setup Script

Mon Mar 07, 2016 9:45 am

Thank you for having a look at port 1194 issue. For info, I'm using a Raspberry Pi 2.

Brewmaster9
Posts: 11
Joined: Thu Mar 03, 2016 11:11 am

Re: Automated OpenVPN Server Setup Script

Tue Mar 08, 2016 11:45 pm

Port 1194 issue solved (if it ever was an issue). This works on my Raspberry Pi 2.

Having tried to configure the server on a NOOBS 1.7/8 Raspbian installation, I decided to go back to basics and install the latest RasbianJessie iso. The steps that worked for me...

Static IP Set on Pi
Static IP reserved on router
Port forward 1194 to Raspberry Pi IP on router.

1. In raspi-config
Expand file system
Auto-login boot to command line (don't think GUI helps)
Change Password
Wait for Network at Boot (Enable long wait) This makes sure your local pi IP connects to the server on re-boot.
Enable ssh

When all the above is set up, script runs like a dream, using steps in tutorial. Openvpn client files downloaded using SFTP in Cyberduck to Mac.

Openvpn clients on iPhone (including cellphone 3g/4g access, iPad & Mac all tested and work 100%. The upload/download speed is good on Rpi2.

Thanks again for the script.

raztafari
Posts: 3
Joined: Wed Mar 23, 2016 8:31 pm

Re: Automated OpenVPN Server Setup Script

Wed Mar 23, 2016 8:42 pm

This guide worked for me to the point where i was going to connect.
Have made everything in the order requested of me.

The weird thing is that it connects to the server and now it's just saying "authenticating".... (It connects to my external ip address).

BUT when i change the ip address in the .ovpn file to the internal ip address (192.168.1.XXX of the server it connects straight away.

Have opened the port 1194 with udp.
And followed both guides on how to change the ip to static!
Even called and checked so that my ISP is not blocking anything.

Does anyone know what i can do?

Although thank you for the script!

Return to “Networking and servers”