O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

OpenVPN: Building and Integrating Virtual Private Networks

Book Description

Learn how to build secure VPNs using this powerful Open Source application

About This Book

  • Learn how to install, configure, and create tunnels with OpenVPN on Linux, Windows, and MacOSX
  • Use OpenVPN with DHCP, routers, firewall, and HTTP proxy servers
  • Advanced management of security certificates

Who This Book Is For

Network administrators and any one who is interested in building secure VPNs using OpenVPN. It presumes basic knowledge of Linux, but no knowledge of VPNs is required. All basic VPN and relevant security concepts are covered.

What You Will Learn

  • Chapter 1 looks at what VPNs are, how they evolved during the last decade, why it is necessary to modern enterprises, how typical VPNs work. The chapter also covers some essential networking concepts.
  • Chapter 2 explains VPN security issues, including symmetric and asymmetric encryption, the SSL/TLS library, and SSL certificates.
  • Chapter 3 introduces OpenVPN. In this chapter, we learn about the history of OpenVPN, how OpenVPN works, and how OpenVPN compares to IPSec VPN applications.
  • Chapter 4 covers installing OpenVPN on both Windows, the Mac, Linux, and FreeBSD. It covers the installation on Linux from the source code and RPM packages. Installation on Suse and Debian is covered in detail.
  • In Chapter 5, an encryption key for OpenVPN is created and it is then used to setup up our first OpenVPN Tunnel between two windows systems in the same network. The key is then copied on a Linux system and this system is connected through a tunnel to the first windows machine.
  • Chapter 6 shows how to create x509 server and client certificates for use with OpenVPN. easy-rsa which comes with OpenVPN and is available for both Windows and Linux is used.
  • Chapter 7 reviews the syntax of the command line tool openvpn, which enables building tunnels quickly. The configuration options of openvpn are covered in detail with examples.
  • Chapter 8 shows how to make the example tunnels created earlier safer and persistent by choosing a reliable combination of configuration file parameters. It then covers how to configure firewalls on Linux and Windows to work with OpenVPN.
  • Chapter 9 focuses on using xca, the advanced Windows tool with which x509 certificates can be easily managed. Its Linux equivalent, Tinyca2, which can even manage multiple certificate authorities, is also covered.
  • Chapter 10 covers advanced OpenVPN configurations, including Tunneling through a proxy server, pushing routing commands to clients, pushing and setting the default route through a tunnel, Distributed compilation through VPN tunnels with distcc, and OpenVPN scripting.
  • Chapter 11 shows how to debug and monitor VPN tunnels. It covers standard networking tools that can be used for scanning and testing the connectivity of a VPN server.

In Detail

OpenVPN is a powerful, open source SSL VPN application. It can secure site-to-site connections, WiFi and enterprise-scale remote connections. While being a full-featured VPN solution, OpenVPN is easy to use and does not suffer from the complexity that characterizes other IPSec VPN implementations. It uses the secure and stable TLS/SSL mechanisms for authentication and encryption.

This book is an easy introduction to this popular VPN application. After introducing the basics of security and VPN, the book moves on to cover using OpenVPN, from installing it on various platforms, through configuring basic tunnels, to more advanced features, such as using the application with firewalls, routers, proxy servers, and OpenVPN scripting.

While providing only necessary theoretical background, the book takes a practical approach, presenting plenty of examples.

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

Table of Contents

  1. OpenVPN
    1. OpenVPN
    2. Credits
    3. About the Author
    4. About the Reviewers
    5. Preface
      1. What This Book Covers
      2. What You Need for This Book
      3. Conventions
      4. Reader Feedback
      5. Customer Support
        1. Errata
        2. Questions
    6. 1. VPN—Virtual Private Network
      1. Branches Connected by Dedicated Lines
        1. Broadband Internet Access and VPNs
      2. How Does a VPN Work?
        1. What are VPNs Used For?
        2. Networking Concepts—Protocols and Layers
        3. Tunneling and Overhead
      3. VPN Concepts—Overview
        1. A Proposed Standard for Tunneling
        2. Protocols Implemented on OSI Layer 2
        3. Protocols Implemented on OSI Layer 3
        4. Protocols Implemented on OSI Layer 4
        5. OpenVPN—An SSL/TLS-Based Solution
      4. Summary
    7. 2. VPN Security
      1. VPN Security
      2. Privacy—Encrypting the Traffic
        1. Symmetric Encryption and Pre-Shared Keys
        2. Reliability and Authentication
          1. The Problem of Complexity in Classic VPNs
        3. Asymmetric Encryption with SSL/TLS
      3. SSL/TLS Security
        1. Understanding SSL/TLS Certificates
        2. Trusted Certificates
        3. Self-Signed Certificates
          1. Certificates and VPNs
      4. Summary
    8. 3. OpenVPN
      1. Advantages of OpenVPN
      2. History of OpenVPN
        1. OpenVPN Version 1
        2. OpenVPN Version 2
      3. Networking with OpenVPN
        1. OpenVPN and Firewalls
        2. Configuring OpenVPN
        3. Problems with OpenVPN
      4. OpenVPN Compared to IPsec VPN
      5. Sources for Help and Documentation
      6. The Project Community
        1. Documentation in the Software Packages
      7. Summary
    9. 4. Installing OpenVPN
      1. Prerequisites
      2. Obtaining the Software
      3. Installing OpenVPN on Windows
        1. Downloading and Starting Installation
        2. Selecting Components and Location
        3. Finishing Installation
        4. Testing the Installation—A First Look at the Panel Applet
      4. Installing OpenVPN on Mac OS X (Tunnelblick)
        1. Testing the Installation—The Tunnelblick Panel Applet
      5. Installing OpenVPN on SuSE Linux
        1. Using YaST to Install Software
      6. Installing OpenVPN on Redhat Fedora Using yum
      7. Installing OpenVPN on RPM-Based Systems
        1. Using wget to Download OpenVPN RPMs
        2. Testing Installation and Installing with rpm
        3. Installing OpenVPN and the LZO Library with wget and RPM
        4. Using rpm to Obtain Information on the Installed OpenVPN Version
      8. Installing OpenVPN on Debian
        1. Installing Debian Packages
        2. Using Aptitude to Search and Install Packages
        3. OpenVPN—The Files Installed on Debian
      9. Installing OpenVPN on FreeBSD
        1. Installing a Newer Version of OpenVPN on FreeBSD—The Port System
          1. Installing the Port System with sysinstall
          2. Downloading and Installing a BSD Port
      10. Troubleshooting—Advanced Installation Methods
        1. Installing OpenVPN from Source Code
        2. Building Your Own RPM File from the OpenVPN Source Code
        3. Building and Distributing Your Own DEB Packages
        4. Enabling Linux Kernel Support for TUN/TAP Devices
          1. Using Menuconfig to Enable TUN/TAP Support
      11. Internet Links, Installation Guidelines, and Help
      12. Summary
    10. 5. Configuring an OpenVPN Server—The First Tunnel
      1. OpenVPN on Microsoft Windows
        1. Generating a Static OpenVPN Key
          1. Creating a Sample Connection
          2. Adapting the Sample Configuration File Provided by OpenVPN
          3. Starting and Testing the Tunnel
        2. A Brief Look at Windows OpenVPN Network Interfaces
      2. Connecting Windows and Linux
        1. File Exchange between Windows and Linux
          1. Installing WinSCP
          2. Transferring the Key File from Windows to Linux with WinSCP
          3. The Second Pitfall—Carriage Return/End of Line
        2. Configuring the Linux System
        3. Testing the Tunnel
          1. A Look at the Linux Network Interfaces
        4. Running OpenVPN Automatically
          1. OpenVPN as Server on Windows
          2. OpenVPN as Server on Linux
          3. Runlevels and init Scripts on Linux
          4. Using runlevel and init to Change and Check Runlevels
          5. The System Control for Runlevels
          6. Managing init Scripts
        5. Using Webmin to Manage init Scripts
        6. Using SuSE's YaST Module System Services (Runlevel)
      3. Troubleshooting Firewall Issues
        1. Deactivating Windows XP Service Pack 2 Firewall
        2. Stopping the SuSE Firewall
      4. Summary
    11. 6. Setting Up OpenVPN with X509 Certificates
      1. Creating Certificates
      2. Certificate Generation on Windows XP with easy-rsa
        1. Setting Variables—Editing vars.bat
        2. Creating the Diffie-Hellman Key
        3. Building the Certificate Authority
        4. Generating Server and Client Keys
      3. Distributing the Files to the VPN Partners
      4. Configuring OpenVPN to Use Certificates
      5. Using easy-rsa on Linux
        1. Preparing Variables in vars
        2. Creating the Diffie-Hellman Key and the Certificate Authority
        3. Creating the First Server Certificate/Key Pair
        4. Creating Further Certificates and Keys
      6. Troubleshooting
      7. Summary
    12. 7. The Command openvpn and its Configuration File
      1. Syntax of openvpn
        1. OpenVPN Command-Line Parameters
      2. Using OpenVPN at the Command Line
        1. Parameters Used in the Standard Configuration File for a Static Key Client
        2. Compressing the Data
        3. Controlling and Restarting the Tunnel
        4. Debugging Output—Troubleshooting
      3. Configuring OpenVPN with Certificates—Simple TLS Mode
      4. Overview of OpenVPN Parameters
        1. General Tunnel Options
        2. Routing
        3. Controlling the Tunnel
        4. Scripting
        5. Logging
        6. Specifying a User and Group
        7. The Management Interface
        8. Proxies
        9. Encryption Parameters
        10. Testing the Crypto System with --test-crypto
        11. SSL Information—Command Line
        12. Server Mode
          1. Server Mode Parameters
          2. --client-config Options
        13. Client Mode Parameters
          1. Push Options
      5. Important Windows-Specific Options
      6. Summary
    13. 8. Securing OpenVPN Tunnels and Servers
      1. Securing and Stabilizing OpenVPN
      2. Linux and Firewalls
        1. Debian Linux and Webmin with Shorewall
          1. Installing Webmin and Shorewall
          2. Preparing Webmin and Shorewall for the First Start
          3. Starting Webmin
          4. Configuring the Shorewall with Webmin
          5. Creating Zones
          6. Editing Interfaces
          7. Default Policies
          8. Adding Firewall Rules
        2. Troubleshooting Shorewall—Editing the Configuration Files
        3. OpenVPN and SuSEfirewall
        4. Troubleshooting OpenVPN Routing and Firewalls
          1. Configuring a Router without a Firewall
          2. iptables—The Standard Linux Firewall Tool
      3. Configuring the Windows Firewall for OpenVPN
      4. Summary
    14. 9. Advanced Certificate Management
      1. Certificate Management and Security
      2. Installing xca
      3. Using xca
        1. Creating a Database
        2. Importing a CA Certificate
        3. Creating and Signing a New Server/Client Certificate
        4. Revoking Certificates with xca
      4. Using TinyCA2 to Manage Certificates
        1. Importing Our CA
        2. Using TinyCA2 for CA Administration
        3. Creating New Certificates and Keys
        4. Exporting Keys and Certificates with TinyCA2
        5. Revoking Certificates with TinyCA2
      5. Summary
    15. 10. Advanced OpenVPN Configuration
      1. Tunneling a Proxy Server and Protecting the Proxy
      2. Scripting OpenVPN—An Overview
      3. Using Authentication Methods
      4. Using a Client Configuration Directory with Per-Client Configurations
      5. Individual Firewall Rules for Connecting Clients
      6. Distributed Compilation through VPN Tunnels with distcc
      7. Ethernet Bridging with OpenVPN
      8. Automatic Installation for Windows Clients
      9. Summary
    16. 11. Troubleshooting and Monitoring
      1. Testing the Network Connectivity
      2. Checking Interfaces, Routing, and Connectivity on the VPN Servers
      3. Debugging with tcpdump and IPTraf
      4. Using OpenVPN Protocol and Status Files for Debugging
      5. Scanning Servers with Nmap
      6. Monitoring Tools
        1. ntop
        2. Munin
      7. Hints to Other Tools
      8. Summary
    17. A. Internet Resources
      1. VPN Basics
      2. OpenVPN Resources
      3. Configuration
      4. Scripts and More
      5. Network Tools
      6. Howtos
      7. Openvpn GUIs