Install Configure Open VPN Server on Linux

The VPN is extremely often essential to working inside a company. With a home based job being this kind of popular draw to numerous industries, it is always necessary to have the ability to access company folders and hardware that exists in the LAN. When over and above that LAN, among the best ways to gain that access is using the help of a VPN. Many VPN solutions are very pricey, and/or tough to set up and manage. Fortunately, with the open source/Linux community, there's a solution that is certainly actually very easy to setup, configure, and manage. OpenVPN is the fact solution and here you will see how to create the server end of these system.
What Is Needed ?
I will probably be setting OpenVPN on a Ubuntu 11.04, using Public Key Infrastructure that has a bridged Ethernet interface. This setup allows for that quickest option to getting OpenVPN working, whilst a modicum of security.
  1. The initial step (outside having the os installed) is usually to install the essential packages. Since I will installing on Ubunutu, cellular phone is fairly straightforward:
  2. Open up a terminal window.
  3. Run sudo apt-get install openvpn to set up the OpenVPN package.
  4. Type the sudo password striking Enter.
  5. Accept any dependencies.
There is package left to set up - the package that permits the enabling of bridged networking. Setting within the bridge is straightforward, knowing how. But before the interface might be configured to manage bridged networking, just one package need to be installed. Do the following:
  1. Install the required package while using command sudo apt-get install bridge-utils.
  2. Edit the /etc/network/interfaces file to reflect the required changes (see below).
  3. Restart networking together with the command sudo /etc/init.d/networking restart .
Open within the /etc/network/interfaces file and make the mandatory that affect your networking interface, in accordance with the sample below:
auto lo
iface lo inet loopback
auto br0
iface br0 inet static
        bridge_ports eth0
        bridge_fd 9
        bridge_hello 2
        bridge_maxage 12
        bridge_stp off
Make sure to configure the bridge section (shown above) to fit the correct information to your network. Save that file and restart networking. Now it's time to start out configuring the VPN server.
Install Configure OpenVPN Server on Linux
Creating Certificates
The OpenVPN server will make use of certificate authority for security. Those certificates must first be created and after that placed in the correct directories. To do this, adopt these measures:
  1. Create a whole new directory with all the command sudo mkdir /etc/openvpn/easy-rsa/.
  2. Copy the mandatory files while using command sudo cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0/* /etc/openvpn/easy-rsa/.
  3. Change the ownership from the newly copied directory while using command sudo chown -R $USER /etc/openvpn/easy-rsa/.
  4. Edit the file /etc/openvpn/easy-rsa/vars and change the variables the following.
The variables to edit are :
export KEY_CITY="Louisville"
export KEY_ORG="Monkeypantz"
export KEY_EMAIL=""
Once the file continues to be edited and saved, we'll run several commands need to be entered to create the certificates :
cd /etc/openvpn/easy-rsa/
source vars
./pkitool --initca
./pkitool --server server
cd keys
sudo openvpn --genkey --secret ta.key
sudo cp server.crt server.key ca.crt dh1024.pem ta.key /etc/openvpn/
Client Certificates
The clients should have certificates so as to authenticate for the server. To create these certificates, perform following:
  1. cd /etc/openvpn/easy-rsa/
  2. source vars
  3. ./pkitool hostname
Here the hostname could be the actual hostname on the machine that is to be connecting for the VPN.
Now, certificates must be created for each host having to connecting to your VPN. Once the certificates have already been created, they'll need to be copied for the respective clients. The files that need to be copied are :
  • /etc/openvpn/ca.crt
  • /etc/openvpn/ta.key
  • /etc/openvpn/easy-rsa/keys/hostname.crt (Where hostname is the hostname of the client).
  • /etc/openvpn/easy-rsa/keys/hostname.key (Where hostname is the hostname of the client).
Copy the above mentined using a secure method, ensuring that they are copied for the /etc/openvpn directory.
Configuring VPN Server
It is time to configure the specific VPN server. The first step is always to copy a sample configuration file to cooperate with. This is done while using command sudo cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn/. Now decompress the server.conf.gz file with all the command sudo gzip -d /etc/openvpn/server.conf.gz. The configuration options to edit have been in this file. Open server.conf up in a very text editor (with administrative privileges) and edit these options:
dev tap0
up "/etc/openvpn/ br0"
down "/etc/openvpn/ br0"
push "route"
push "dhcp-option DNS"
push "dhcp-option DOMAIN"
tls-auth ta.key 0 # This file is secret
user nobody
group nogroup
If you're undecided about any with the options, here:
  1. The local address will be the IP address from the bridged interface.
  2. The server-bridge is essential in the case of a bridged interface.
  3. The server will push out of the IP address array of to clients.
  4. The push directives are options deliver to clients. 
Bringing The VPN Up And Down
Before the VPN commences (or restarted) a few scripts is going to be necessary to add the tap interface on the bridge (If bridged networking is just not being used, these scripts are certainly not necessary.) These scripts are able to be used by the executable for OpenVPN. The scripts are /etc/openvpn/ and /etc/openvpn/
#This is /etc/openvpn/
/sbin/ifconfig $DEV mtu $MTU promisc up
/usr/sbin/brctl addif $BR $DEV
#This is/etc/openvpn/
/usr/sbin/brctl delif $BR $DEV
/sbin/ifconfig $DEV down
Both of the scripts must be executable, that is done while using chmod command :
    sudo chmod 755 /etc/openvpn/
    sudo chmod 755 /etc/openvpn/
Finally, restart OpenVPN using the command sudo /etc/init.d/openvpn restart. The VPN server is actually ready to accept connections from clients .
Tag : Other
Back To Top