OpenVPN

Server Side

sudo apt install openvpn

To know more about it:

sudo apt info openvpn

Installing OpenVPN is easy but configuring it, is very challenging and that’s why OpenVPN org provide us with scripts and then we can go ahead and our special changes

wget <https://git.io/vpn> -O [openvpn.sh](<http://openvpn.sh/>)

Now let’s start the script:

chmod +x openvpn.sh

You need privileges when installing:

sudo ./openvpn.sh

Welcome to this OpenVPN road warrior installer!

Which IPv4 address should be used?
     1) 192.168.1.5
     2) 172.16.1.100
     3) 10.1.0.3
IPv4 address [1]: 1

This server is behind NAT. What is the public IPv4 address or hostname?
Public IPv4 address / hostname [Your-Public-IP]: 192.168.1.5

Which protocol should OpenVPN use?
   1) UDP (recommended)
   2) TCP
Protocol [1]:

What port should OpenVPN listen to?
Port [1194]:

Select a DNS server for the clients:
   1) Current system resolvers
   2) Google
   3) 1.1.1.1
   4) OpenDNS
   5) Quad9
   6) AdGuard
DNS server [1]: 2

Enter a name for the first client:
Name [client]: touk

OpenVPN installation is ready to begin.
Press any key to continue...

If you want to add more users, you have to run the script again

The needed port 1194 is going to be added on iptables automatically, if you are running UFW you won’t see the rule there and even if you create one in UFW it won’t take precedence

If you want to check for it’s status,

since OpenVPN package comes with the server and client package we will have to specify the service name like this:

sudo systelctl status openvpn-server@server

Or you can spot it from the interfaces in your system:

If you want to change anything, you can do that iside the file /etc/openvpn/server/openvpn.conf

CLIENT SIDE

sudo apt install openvpn

It was already installed, because this package comes within the distro installation

I need to get the server’s certificate on my client machine, because i already generated a client profile when i did my installation

It dropped it inisde /root -_-, because i run it with the sudo command which is necessary

I am going to copy it from a machine to another or you can use SCP

And then client OpenVPN expects it to .conf I will rename it:

mv touk.ovpn touk.conf

Let’s copy it to the client config ovpn file

Now let’s connect over the VPN!

sudo openvpn client config /etc/openvpn/client/touk.conf

And it will runt !

You can view that it created a virtual tunnel :

10.8.0.0/24 Is the default range for the OpenVPN

Logging is turned off, you turn that on the client config file and then you can view it inside /var/log/openvpn

Or since it is turned off, i can use the great journalctl

sudo journalctl -xeu openvpn@client

-xe: extended info if some lines are out of terminal size

-u: specify which service

ALWAYS ON OpenVPN: sudo cp /etc/openvpn/client/touk.conf /etc/openvpn/client.conf sudo systemctl start openvpn@client

VPN Server IP Address

VOILAA! Everything is working

Last updated