OpenVPN: how secure virtual private networks really work (2024)

Because OpenVPN devices are fully managed by the kernel, data transfers are invisible to the network, enhancing security and cross-platform compatibility.

I’m not going to talk about configuring OpenVPN in an AWS environment, for that you should read OpenVPN: Connecting VPCs between regions. We will try to go a bit deeper and learn exactly what’s going on under the hood.

I remember not too many years ago, we would ignore anything we’d hear about VPNs: those details are for the network team to worry about. But with the move to Cloud Computing Infrastructure as a Service models and the rise of DevOps, it’s coming much closer to home. I mean if, for instance, you’re working in a cloud environment like AWS, you will frequently encounter scenarios where you need to enable secured communication between VPC’s in different regions. The most obvious solution to that is some kind of virtual private network. And one of the more obvious virtual private network solutions is OpenVPN.

OpenVPN Introduction

OpenVPN is an open source VPN software solution licensed under GNU General public license (GPL) that enables secure point-to-point or site-to-site connections. OpenVPN can create interfaces from either layer 2 or layer 3 of OSI model using the industry standard SSL/TLS protocol, to provide secure connection and authentication mechanisms.

How OpenVPN works

OpenVPN: how secure virtual private networks really work (1)
The above diagram illustrates OpenVPN’s basic “client server mode” model. From one side, the OpenVPN server connects to the Internet, but at the same time, it maintains a secure communication channel with its clients. We’ll elaborate the working of TUN and TAP so as to understand the basic skeleton of any program attached to these interfaces. These program can be further extended to have OpenVPN kind of daemon or any other user defined behavior.

ll Internet traffic directed at an OpenVPN client is terminated at the server and transmitted to the client over a secure channel. Similar communication happens other way round, where any request originating from a OpenVPN Client is terminated at the server and then relayed to the Internet. This means that an OpenVPN client is known to the outside world only through the server’s identity, maintaining a higher level of privacy.

Communication between OpenVPN client and Server

Let us try to dig bit further and see how the communication channel connecting the OpenVPN client and server works. We’ll use a simple analogy. Usually a network interface in a computer has a physical device associated with it. For instance, ethernet interfaces have network cables attached that are used for physical data transfers. An OpenVPN connection is achieved through a virtual network interface backed by software.
This brings us nicely to the topic of TUN (“network TUNnel”) and TAP (“network TAP”). TUN and TAP are really virtual network interfaces implemented and managed by the kernel itself. So we can think of TUN/TAP as virtual ethernet interfaces.
OpenVPN: how secure virtual private networks really work (2)

The TUN interface

TUN is a virtual point to point network device whose driver was designed as low level kernel support for IP tunneling. It works at the protocol layer of the network stack.

The TAP Interface

TAP is a virtual Ethernet network device. TAP driver was designed as low-level kernel support for Ethernet tunneling. It works at the Ethernet Layer of OSI stack and aren’t limited to point to point connection as that of TUN devices.

Let’s go back to our analogy: when something is transferred through an ethernet interface, it’s sent through the cable. However, since TUN/TAP interfaces are virtual, data in transit can be available for just about any purpose to any program running in the user space.

OpenVPN implements a daemon which is attached to the TUN/TAP interfaces. So any data sent over a virtual interface is redirected by the kernel to the OpenVPN Daemon, which in turn implements the authentication and encryption mechanism.

How TUN and TAP work

TUN and TAP are fully managed by the kernel and allow user space applications to interact with them just like a real device. Any packets sent to these interfaces will be transmitted by the OS over the real network, remaining invisible to the user. Because it doesn’t require modification of the IP stack in the kernel space, this architecture is a key advantage of OpenVPN compared to other VPN solutions.
Let us try to understand the flow of data with virtual interfaces and a sample encryption application.
OpenVPN: how secure virtual private networks really work (3)
Let us assume two hosts, A and B, both configured with a virtual tap interface and an ethernet interface. Now we have an encryption application running in user space which performs some basic encryption. The encryption application has to keep track of two file descriptors:

  1. File descriptor obtained from attaching itself to the virtual interface, say tap_fd. When the program attaches to the tun/tap interface, it reads the data being sent from the interface from the special file descriptor.
  2. File descriptor received from opening a socket with the ethernet interface, say net_fd.

This application basically attaches and waits on some kind of select() on both the fd’s.
Now let us assume there is a communication channel over TCP established between the ethernet interfaces on Host A and Host B. The ethernet and tap interface at both ends are configured, up and running,

  1. A Telnet application uses the local virtual interface to send the data to the remote host.
  2. Since the encryption application is waiting for the tap_fd and net_fd file descriptors, it receives message over tap_fd descriptor and performs the required encryption.
  3. The sample client sends the encrypted message over the net_fd descriptor to be sent over the TCP channel.
  4. The ethernet interface (net_fd) at Host B receives the packet.
  5. Since the sample decryption server running at host B is also waiting on net_fd and tap_fd, it receives the packet at net_fd and performs the necessary decryption.
  6. After decryption, the sample server writes the data over tap_fd. When the data is written to the tap interface descriptor, kernel recognizes it as the message coming from the network or the wire, and executes it as if received from a normal ethernet interface.

Thus, the outside world only sees a normal TCP communication channel, but the actual data is sent in encrypted format and is never exposed.
The above flow of data provides a fairly simplistic view of how applications interact using TUN/TAP interfaces. The same logic is further extended by the OpenVPN application. OpenVPN allows the flexibility to use various client authentication and encryption mechanisms. The users, if they want, can use the built-in OpenSSL mechanism for authentication and encryption, or can go with an alternate approach using OpenVPN PAM – which provides a plugin module interface for exclusive or combined authentication.

With this blog I’ve tried to drop down one level to see what actually happens under the hood. You can find some additional background on this topic by reading Nitheesh Poojary’s excellent post, OpenVPN: Connecting VPCs between regions, which was written and published last summer. I hope this will help you better understand OpenVPN. I would really appreciate any comments or feedback you might have based on your own experience so we can all learn from each other.

OpenVPN: how secure virtual private networks really work (2024)

FAQs

Is OpenVPN really secure? ›

OpenVPN is one of the most secure open-source VPN protocols today. Virtual Private Networks (VPNs) use OpenVPN as it remains the standard secure VPN protocol popular to many users and compatible with most operating systems.

How does a virtual private network VPN help you stay secure? ›

A VPN creates a secure tunnel between a user's computer and the VPN server, which hides their online activity and location. VPN security enables users to protect their online privacy and prevent their internet service provider (ISP) from tracking their browsing activity.

What is OpenVPN and how does it work? ›

OpenVPN, or Open Virtual Private Network, is an open-source system that creates a private and secure tunnel between networks. It refers to multiple different but related things: The open-source OpenVPN protocol used to create encrypted tunnels between networks and establish a VPN connection.

Does a VPN actually protect you? ›

It's important to remember that VPNs do not work in the same way as comprehensive anti-virus software. While they will protect your IP and encrypt your internet history, but that is as much as they can do. They won't keep you safe, for instance, if you visit phishing websites or download compromised files.

Has OpenVPN ever been hacked? ›

Outdated VPN protocols

VPN protocols are sets of rules that define how data and traffic are routed between your device and the VPN server. Protocols such as OpenVPN, WireGuard, or IKEv2 have no known vulnerabilities and are considered secure.

Why is OpenVPN not secure? ›

By default, OpenVPN Access Server comes with a self-signed certificate to get you up and running. Your browser can't automatically verify a self-signed certificate. Also, an OpenVPN client program can't validate the server with that certificate.

What is the most secure VPN? ›

NordVPN is the most secure VPN on the market because of the most robust encryption technology, high-level security measures, and privacy-friendly jurisdiction in Panama. Additionally, it provides an excellent service for safe browsing, streaming, entertainment, and more for just $3.09/month.

When should a VPN not be used? ›

Why shouldn't I use a VPN?
  1. A VPN might reduce your connection speed even if your internet service provider isn't throttling your speed;
  2. Using a VPN on mobile will increase your mobile data usage;
  3. Some apps may require your IP to come from your country of residence. This is particularly common with banking apps.

What is the safest free VPN? ›

The Best Free VPNs of 2024
  • NordVPN - Best Full-Featured VPN with Free Offers.
  • Surfshark - Best VPN Free Trial.
  • Hotspot Shield - Fastest Free VPN.
  • PrivadoVPN - Best Free VPN for Unlimited Devices.
  • Atlas VPN - Best Free VPN for Privacy.
  • TunnelBear - Best Server Network.
Apr 26, 2024

Is OpenVPN an actual VPN? ›

The OpenVPN Community Edition (CE) is an open source Virtual Private Network (VPN) project. It creates secure connections over the Internet using a custom security protocol that utilizes SSL/TLS.

Is OpenVPN better than NordVPN? ›

NordVPN offers better streaming capabilities, more robust security, faster speeds, richer features, easier-to-use interfaces, and more accessible customer support. Contrastingly, OpenVPN isn't a full-service VPN, which explains its weaker security, speeds, features, and more.

Is OpenVPN no longer free? ›

No matter what solution you choose, you can use our free connections until you're ready to scale. Those VPN connections are free for life. We're that confident you'll trust OpenVPN to manage your network security.

Is there a downside to always using a VPN? ›

Slower connection

The encryption process and routing your traffic through remote servers can slow down your internet connection. However, premium VPN services usually have fast protocols and a powerful infrastructure that make the speed drop barely noticeable.

Can police see your VPN? ›

Whether police can track VPN traffic is a common concern among users seeking online privacy. The truth is: the police can't monitor encrypted VPN traffic. However, they can ask your Internet Service Provider (ISP) to provide connection or usage logs through a court order, which can lead them to your VPN provider.

Am I completely safe with a VPN? ›

A VPN may boast strong protocols and military-grade encryption, but that doesn't mean it's infallible. It can't prevent cookie tracking, viruses, or malware, and it can't protect against phishing scams. Data leaks could occur. But most pivotally, a VPN is only as secure as the company that runs it.

Is OpenVPN as safe as NordVPN? ›

If you are conscious about your security and are wondering what the most stable NordVPN protocol is, we recommend OpenVPN.

Can OpenVPN be detected? ›

Internet connections using the OpenVPN protocol can be easily identified by using DPI (Deep Packet Inspection) technologies and blocked with minor collateral damage. This result was presented in a technical paper published earlier this month by a team of researchers in the United States.

Does OpenVPN track you? ›

We are a Zero-Log service provider and Do Not keep records of your traffic, browsing, or activity while using our services. We do analyze website functionality for performance for purposes of improving our service offerings to our customers.

Is OpenVPN always encrypted? ›

Yes, the point of OpenVPN is that the traffic is encrypted (unless you disable all security in the server's config file) between the client (your Windows laptop) and the Ubuntu Server. Your traffic to the internet is not encrypted though.

References

Top Articles
Latest Posts
Article information

Author: Errol Quitzon

Last Updated:

Views: 6312

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.