Book Image

Mastering OpenVPN

By : Jan Just Keijser, Eric F Crist
Book Image

Mastering OpenVPN

By: Jan Just Keijser, Eric F Crist

Overview of this book

Security on the internet is increasingly vital to both businesses and individuals. Encrypting network traffic using Virtual Private Networks is one method to enhance security. The internet, corporate, and “free internet” networks grow more hostile every day. OpenVPN, the most widely used open source VPN package, allows you to create a secure network across these systems, keeping your private data secure. The main advantage of using OpenVPN is its portability, which allows it to be embedded into several systems. This book is an advanced guide that will help you build secure Virtual Private Networks using OpenVPN. You will begin your journey with an exploration of OpenVPN, while discussing its modes of operation, its clients, its secret keys, and their format types. You will explore PKI: its setting up and working, PAM authentication, and MTU troubleshooting. Next, client-server mode is discussed, the most commonly used deployment model, and you will learn about the two modes of operation using "tun" and "tap" devices. The book then progresses to more advanced concepts, such as deployment scenarios in tun devices which will include integration with back-end authentication, and securing your OpenVPN server using iptables, scripting, plugins, and using OpenVPN on mobile devices and networks. Finally, you will discover the strengths and weaknesses of the current OpenVPN implementation, understand the future directions of OpenVPN, and delve into the troubleshooting techniques for OpenVPN. By the end of the book, you will be able to build secure private networks across the internet and hostile networks with confidence.
Table of Contents (17 chapters)
Mastering OpenVPN
About the Authors
About the Reviewers


Privacy and security on the Internet and in private networks is a growing concern and is increasingly common in the news, where there are breaches of each. Virtual private networks (VPN) were created out of a need for secured communications. The most popular and widely used open source VPN software today is OpenVPN. Mastering OpenVPN aims to educate you on deployment, troubleshooting, and configuration of OpenVPN and provide solid use cases for various scenarios.

What this book covers

Chapter 1, Introduction to OpenVPN, discusses the various types of Virtual Private Networks and some of their various strengths and weaknesses. PPTP, OpenVPN, IPSec, and other protocols are also discussed in this chapter.

Chapter 2, Point-to-point Mode, covers the OpenVPN roots, point-to-point mode, and the initially only supported mode. It also covers the tap mode in a bridged scenario and an uncommon configuration.

Chapter 3, PKIs and Certificates, explains the complex concept of X.509 certificates and PKIs with examples and a demonstration of a couple of utilities. It also covers how to create a certificate chain and deploy that chain to their VPN.

Chapter 4, Client/Server Mode with tun Devices, walks you through the most common deployment mode, a tun or routed, and its setup. It also discusses the passing of client-backed routes along with IPv4 and IPv6.

Chapter 5, Advanced Deployment Scenarios in tun Mode, covers policy-based routing and configuring OpenVPN to integrate your VPN clients with the rest of the LAN. Complex examples of tun mode are examined, showing that they are appropriate even in advanced scenarios.

Chapter 6, Client/Server Mode with tap Devices, discusses the often misused and less commonly deployed tap or bridged mode VPNs. Solid examples of broadcast and OSI layer 2 traffic are demonstrated in this chapter.

Chapter 7, Scripting and Plugins, helps you gain an understanding of the methods to extent the VPN, including authentication, routing, and protocol enhancements. This chapter helps an administrator create a local experience for a worker or a user on the move.

Chapter 8, Using OpenVPN on Mobile Devices and Home Routers, helps you learn how to use home router OSes and features to deploy OpenVPN. We understand that it's not just enterprise or commercial users looking to protect their privacy and data. Increasingly, home users desire to deploy secure connections to their home resources.

Chapter 9, Troubleshooting and Tuning, will help you become an expert in your OpenVPN deployment by learning how to troubleshoot problems and bugs. The ability to identify issues creates a solid and reliable installation and confidence in your users.

Chapter 10, Future Directions, gives you a brief history and lengthier discussion of the future direction of OpenVPN, and the mindset of the developers is revealed. It also helps you understand the reasoning and history behind the various decisions behind features and bugs.

What you need for this book

You should have the following entities for a complete experience of reading and following Mastering OpenVPN:

  • A Unix, Linux, or Mac OS X system

  • A Windows system

  • A server (Windows or Linux, whichever is preferred, Linux or FreeBSD suggested)

  • A solid understanding (101 or 201 level) of networking (UDP and TCP over IP)

An IRC client or a web browser is also helpful. When you run into trouble or have too many questions, pop in to #openvpn on, and look for @janjust or @ecrist. We look forward to talking to you!

Who this book is for

This book is really designed for anyone looking to deploy a VPN solution to any private or enterprise network. OpenVPN can be used for point-to-point tunnels, intra-network connections, and road warriors. The concepts covered in this book can be applied generally across more than just OpenVPN deployments, with the exception of configuration argument specifics.


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "You can specify a message digest as parameter to the --auth option."

A block of code is set as follows:

proto udp
port 1194
dev tun

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

proto udp
port 1194
dev tun

Any command-line input or output is written as follows:

#  mkdir -p /etc/openvpn/movpn

Note that first character (the prompt) is used to indicate a root-shell (#) or a user shell ($).

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Launch the OpenVPN GUI application, select the configuration basic-udp-client and click on Connect."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.


You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.