Setup Linux And Windows Clients To Connect With OpenVPN Server In RHEL/CentOS 6/7

In the previous article, we learned to install and setup OpenVPN server and we also learn about the reason behind VPN and learned some basics about OpenVPN so continuing the glory of OpenVPN, in this article, we will learn to Setup OpenVPN Clients for Linux and windows machines In RHEL/CentOS 6/7.

Note: If you are a SUDO user then prefix every command with sudo, like #sudo ifconfig

If you want to read more article on OpenVPN then you may follow Given below links

Part 1:  How To Install And Setup OpenVPN Server On CentOS/RHEL 7?
Part 2: How To Install And Setup OpenVPN Server On CentOS/RHEL 6?
Part 4: How To Add/Create A New OpenVPN Client For OpenVPN Server In CentOS/RHEL 6/7
Part 5: How To Remove Revoke OpenVPN Server’s Clients From OpenVPN Server On RHEL/CentOS 6/7
Part 6: How To Remove OpenVPN Server from CentOS/RHEL 6/7

Prerequisites:

A Pre-Installed and running OpenVPN Server.

Scenario

OpenVPN Server: 192.168.1.188 – Already Running
Windows Client: 192.168.1.18
Linux Client: 192.168.1.245

So Let’s start

To get connect with OpenVPN server we need to create a file ending with .ovpn. These ovpn files can be used on any OS((regardless of the distribution or operating system). To setup, a client we need to create a file by copying the ca.crt, server.crt, and server.key files (created in Part 1) from /etc/openvpn/easy-rsa/ directory.

For this example, let’s say we are creating a file client.ovpn

Login into OpenVPN server and follow given instructions.

Step 1: Create an OVPN File

You may create this file at any location on OpenVPN server. For this example, I am creating this file below location

vim /home/kapendra/client.ovpn

You may name the file whatever you want. So, After opening the file append the following lines to the
Note: Change the Highlighted values according to your Scenario)

client
dev tun
proto udp
sndbuf 0
rcvbuf 0
remote 192.168.1.188 9091    --- VPN server IP and Port
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
auth SHA512
cipher AES-256-CBC
comp-lzo
setenv opt block-outside-dns
key-direction 1
verb 3

write and quit the file using :wq!

Step 2: Save the Key in ca.crt, server.crt, and server.key In File

Now to insert the values of ca.crt, server.crt, and server.key in client and you should follow the given below steps

 

echo "<ca>" >> /home/kapendra/client.ovpn 
cat /etc/openvpn/easy-rsa/pki/ca.crt >> /home/kapendra/client.ovpn 
echo "</ca>" >> /home/kapendra/client.ovpn 
echo "<cert>"  >> /home/kapendra/client.ovpn 
cat /etc/openvpn/easy-rsa/pki/issued/client.crt >> /home/kapendra/client.ovpn 
echo "</cert>" >> /home/kapendra/client.ovpn 
echo "<key>" >> /home/kapendra/client.ovpn 
cat /etc/openvpn/easy-rsa/pki/private/client.key >> /home/kapendra/client.ovpn 
echo "</key>" >>  /home/kapendra/client.ovpn 
echo "<tls-auth>" >> /home/kapendra/client.ovpn 
cat /etc/openvpn/ta.key >> /home/kapendra/client.ovpn 
echo "</tls-auth>" >> /home/kapendra/client.ovpn

 

You have your final client.ovpn would be at /home/kapendra/client.ovpn

Now Lets Connet Our Machine With OpenVPN Server and we need an OpenVPN client like given image

Setup Linux And Windows Clients To Connect With OpenVPN Server In RHEL/CentOS 6/7

For Windows Client

The first thing we need to do is to download or copy the client.ovpn file from /home/kapendra/client.ovpn using sftp or by using other methods. I  did use FileZilla. Now connect our windows client machine we need to download OpenVPN client and follow installation guide.

Setup Linux And Windows Clients To Connect With OpenVPN Server In RHEL/CentOS 6/7

Copy client.ovpn file to the location “C:\Users\kapen\OpenVPN\config” and start OpenVPN GUI on windows.

Setup Linux And Windows Clients To Connect With OpenVPN Server In RHEL/CentOS 6/7

After Starting OpenVPN GUI you will get Connected to your VPN server simply by clicking on connect 🙂

Setup Linux And Windows Clients To Connect With OpenVPN Server In RHEL/CentOS 6/7

For Linux Clients

We need to follow the same step to getting the client.ovpn file on your Linux machine. so down the client.ovpn on your system and run the following command

yum install openvpn

After installation Run the following command to get connected with OpenVPN server

nohup openvpn --config client.ovpn &

To Get you Linux client connect every time after reboot you make append following lines in  crontab

@reboot /usr/bin/openvpn --config /path/to/client.ovpn

This Was for now in next article, we will learn to Add new OpenVPN clients, Delete OpenVPN clients and uninstall OpenVPN server

You May Like These Also

Part 1:  How To Install And Setup OpenVPN Server On CentOS/RHEL 7?
Part 2: How To Install And Setup OpenVPN Server On CentOS/RHEL 6?
Part 3: Setup Linux And Windows Clients To Connect With OpenVPN Server In RHEL/CentOS 6/7
Part 4: How To Add/Create A New OpenVPN Client For OpenVPN Server In CentOS/RHEL 6/7
Part 5: How To Remove Revoke OpenVPN Server’s Clients From OpenVPN Server On RHEL/CentOS 6/7
Part 6: How To Remove OpenVPN Server from CentOS/RHEL 6/7