What is VPN? (Virtual Private Networks)

February 24, 2024
In an increasingly interconnected digital landscape, protecting our online privacy and security has become more important than ever. VPNs offer a powerful solution by creating a secure and encrypted connection between your device and the internet. The OpenVPN provides us with the Virtual Private Network solutions to secure data while accessing the internet.

 

How to install VPN:

To install VPN software, one must connect to the server using the command sudo with ssh <username>@<server>. It is also essential to know which operating system and codename are currently used on the server. The command lsb_release -a will help give details of the OS.

 

Install openVPN through repository:

OpenVPN provides different ways of installation. Most installations are done from the repository since it makes the update process much simpler and more error-proof in the future.

After that one can include the repository key and the repository itself in the sources.list file.

( wget -qO - "https://as-repository.openvpn.net/as-repo-public.gpg" | sudo apt-key add -

sudo apt-add-repository "deb http://as-repository.openvpn.net/as/debian bionic main" )

 

After adding the repository key and repository to the sources.list file, users can proceed to update the package list and subsequently install the openvpn-as package.

( sudo apt-get update && sudo apt-get -y install openvpn-as )

 

Configure TLS certificate:

 

- The OpenVPN AS installation script creates a self-signed TLS certificate to secure its web user interface. Because this certificate is self-signed, it will give security warnings when the web interface is opened. One can see this by visiting https://server.lab. To avoid this warning and eliminate any opportunity for man-in-the-middle attacks, one needs to configure the web service to use a different certificate and private key. These files have already been deployed on the server and can be found in /etc/ssl/private/.

 

The relevant configuration file is found at /usr/local/openvpn_as/etc/as.conf.

 

WireGuard VPN:

A Virtual Private Network (VPN) can help with sniffing for passwords sent over open WiFi networks, ISP injecting advertisements into web pages, or governments censoring politically inappropriate content.

 

Configuration of a WireGuard interface:

To achieve comprehensive configuration control of a WireGuard interface, you have the option to utilize the wg command-line tool. This tool enables you to configure the routing of network packets through the interface using commands such as ip addr and ip route. Alternatively, for a simpler and more user-friendly approach, you can opt for wg-quick. This convenient tool allows you to define an interface, its peers, and IP addresses using a single configuration file. By default, these configuration files are stored in /etc/wireguard.

 

VPN-internal IP address:

 

In the context of establishing a secure point-to-point connection between multiple computers, it is essential that each endpoint is capable of direct connection. To ensure security, each endpoint needs to generate a private key and select a VPN-internal IP address. For IPv4 addresses, it is recommended to choose addresses from the RFC1918-defined address spaces: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. It is important to avoid conflicts with private home or office networks and virtualized networking environments like Docker or KVM. Alternatively, for a more reliable approach, provided that all the software used for VPN communication is IPv6-ready, it is advisable to generate an IPv6 unique local address prefix and assign VPN IP addresses from that range.

Use case of Virtual Private Network:

 

A common scenario where Virtual Private Networks (VPNs) are frequently used is to enable access to a private local network through the public internet. This situation requires a gateway machine that is connected to both the private network and the public internet. The gateway serves as the platform for running VPN software and facilitates traffic routing between the physical and virtual private networks. On the other end of the VPN connection, there can be an individual client machine, such as a staff member's laptop, or another gateway that facilitates traffic exchange between private LANs at different office sites.

 

In order to maintain consistency, it is advisable to allocate addresses to the various machines based on the address scheme utilized in the remote LAN. Once the VPN is established, it is crucial to configure the gateways to properly forward packets between the VPN and their respective private LANs.

 

Throughout this configuration process, it is of utmost importance to prevent unintentional activation of direct packet forwarding from the public internet to either the LAN or the VPN. The simplest approach is to employ a firewall with a "default deny" rule for packet forwarding, and subsequently add rules that allow packet forwarding between the WireGuard and LAN interfaces.

 

 

wg-quick tool:

To ensure that all network traffic is routed through the VPN, it is necessary to adjust the Allowed IPs setting in the client configuration to include all IP addresses. Additionally, the gateway must be properly configured to enable packet forwarding, typically utilizing network address translation, from the VPN to its public internet interface. A helpful tool called wg-quick automatically adds an exception to the routing table, ensuring that the encrypted VPN packets destined for the gateway are not sent over the VPN itself.

 

 

Stay Tuned

The best articles, links, and news delivered once a week to your inbox.

DMCA.com Protection Status