Beginning
OpenVPN
2.0.9
Build
and
integrate
Virtual
Private Networks
using
OpenVPN
Markus Feilner
Norbert Graf
PUBLISHING
Table
of
Contents
Preface 1
Chapter 1: VPN—Virtual Private Network 7 Broadband Internet access and VPNs 9
How does a VPN work? 10
What are VPNs used for? 12
Networking
concepts—protocols andlayers
13Tunneling
and overhead 16VPNconcepts—overview 17
A proposed standard fortunneling 17 Protocols implemented on OSI layer2 18 Protocols
implemented
on OSI layer3 19Protocols
implemented
on OSI layer 4 20OpenVPN—a
SSL/TLS-based solution 21Summary
21Chapter
2: VPN Security 23VPN
security
23Privacy—encrypting
traffic 24Symmetric encryption
and pre-sharedkeys
25Reliability
and authentication 26The problem of
complexity
in classic VPNs 26Asymmetric
encryption
with SSL/TLS 27SSL/TLS
security
28HTTPS 29
Understanding
SSL/TLS certificates 30Trusted certificates 30
TableofContents
SSL/TLS certificates and VPNs 33
Generating certificates and
keys
34Summary 34 Chapter3: OpenVPN 35
Advantages
ofOpenVPN 35 History ofOpenVPN
37 OpenVPN Version 1 38 OpenVPNVersion 2 41The road to version 2.1 42
NetworkingwithOpenVPN 44
OpenVPN
and firewalls 46Configuring OpenVPN
47Problems with
OpenVPN
48OpenVPN compared
to IPsecVPN 49User spaceversus kernel space 51
Sources for helpanddocumentation 51
The
project
community 52Documentation in the software packages 52
Summary
53Chapter
4:Installing
OpenVPN on Windows and Mac 65Obtaining
the software 55Installing
OpenVPN
on Windows 56Downloading and startinginstallation 56
Selectingthe componentsand location 57
Finishing installation 59
Testing
the installation—a first look at thepanel applet
60Installing OpenVPN
on Mac OS X(Tunnelblick)
62Testing
the installation—the Tunnelblickpanel applet
64Summary 65
Chapter
5:Installing OpenVPN
on Linux and UnixSystems
67Prerequisites 67
Installing
OpenVPNon SuSE Linux 68Using
YaSTto install software 69Installing OpenVPN
on Red Hat Fedora using yum 72Installing
OpenVPN on RedHatEnterprise
Linux 75Installing OpenVPN on RPM-based systems 77
Using wget to download OpenVPN RPMs 78
Installing OpenVPN
and the LZOlibrary
with wget and RPM 79of
Installing OpenVPNon Debian and Ubuntu 82
Installing
Debianpackages
84Using Aptitude
to search and install packages 86OpenVPN—the
files installed on Debian 88Installing
OpenVPN
on FreeBSD 88Installing a newer version ofOpenVPN on FreeBSD—the ports system 91
Installingthe portsystemwithsysinstall 91
Downloading andinstallinga BSDport 92
Summary 94
Chapter
6:AdvancedOpenVPN
Installation 95Troubleshooting—advanced
installation methods 95Installing
OpenVPN fromsource code 96Building
anddistributing
.debpackages
102Building your own RPMfile 104
Enabling Linux kernel TUN/TAP support 106 Using menuconfig 107
Summary 109
Chapter7: Configuring an OpenVPN Server—The First Tunnel 111
OpenVPN
on MicrosoftWindows 112Generating
a staticOpenVPN key
113Creatinga sampleconnection - 115
Adaptingthesample configurationfileprovided by OpenVPN 117
Startingandtestingthe tunnel 119
A brief look at Windows
OpenVPN
network interfaces 121Connecting Windows and Linux 122
File
exchange
betweenWindows and Linux 123WinSCP 123
Transferringthekeyfile from Windows to Linux with WinSCP 124 The secondpitfall—carriagereturn/end of line 126
Configuring
the Linux system 127Testing the tunnel 129
A look at the Linux network interfaces 130
Running OpenVPN automatically 131
OpenVPNas a server onWindows 131
OpenVPNas aserveronLinux 133
Runlevels andinitscriptsonLinux 133
Using runleveland inittochangeand check runlevels 134 Thesystemcontrol for runlevels 135
Managing initscripts 136
TableofContents
Troubleshooting firewall issues 139
Deactivating
the Windows XP servicepack
2 firewall 139Stopping
the SuSE firewall 141Summary
142Chapter
8:Setting Up
OpenVPN with X.509 Certificates 143Creating
certificates 143Certificate generation on Windows Server 2008 with easy-rsa 144
Setting variables—editing vars.bat 145
Creating the Diffie-Hellmankey 146
Building the certificate authority 147
Generating serverand clientkeys 148
Distributing
the files to the VPN partners 152Configuring OpenVPN
to use certificates 154Using
easy-rsaon Linux 157Preparing
variables in vars 158Creating the Diffie-Hellmankey and thecertificate
authority
158Creating the firstserver certificate/key pair 159
Creating
furthercertificates and keys 161Troubleshooting
162Summary
163Chapter
9: The Command openvpn and ItsConfiguration
File 165Syntaxof openvpn 166
OpenVPN command-line parameters 166
Using OpenVPN atthe command line 167
Parameters used in the standard
configuration
file fora statickey
client 169Compressing
the data 169Controlling
andrestarting
thetunnel 172Debugging output—troubleshooting 173
Configuring OpenVPNwith certificates—simpleTLS mode 175 Overview of OpenVPN parameters 176
General tunnel
options
176Routing
179Controlling
thetunnel 181Scripting
182Modules 182
Logging 184
Specifying
a user and group 185Themanagement interface 186
Proxies 188
of
Testingthe crypto system with -test-crypto 190
SSL information—command line 191
Server mode 195
Server modeparameters 196
--client-configoptions 199
Client mode parameters 201
Pushoptions 202
Important Windows-specific
options 203New in Version 2.1 204 Connection profiles 204 Topology mode 205 Script-security 206
Port-sharing
206 Test 206 Summary 207Chapter 10: Securing OpenVPN Tunnels and Servers 209
Securingand stabilizing OpenVPN 209
Authentication 212
Using
authentication methods 213Authentication pluginsoverview 216
Authentication with tokens 217
Individual authentication with Pam-per-user 218
Linux and Firewalls 220 Debian Linux and Webminwith Shorewall 221
InstallingWebminand Shorewall 221
LookingatWebmin 222
PreparingWebmin and Shorewall for the first start 223
Preparingthe Shoreline firewall 224
TroubleshootingShorewall—editingtheconfigurationfiles 225
OpenVPN
and SuSEfirewall 228Routing
and firewalls 230Configuringa router withoutafirewall 230
iptables—the standard Linuxfirewalltool 230
Configuring
the Windows Firewall forOpenVPN
234Summary
238Chapter
11: Advanced CertificateManagement
239Certificate managementand security 239
Installing xca 240
Using xca 240
TableofContents
Importinga CA certificate 242
Creating and signing a newserver/client certificate 244
Revoking certificates with xca 248
Using
TinyCA2
to manage certificates 250ImportingourCA 250
Using TinyCA2for CA administration 251
Creatingnewcertificates andkeys 252
Exporting keys and certificates withTinyCA2 254
Revokingcertificates withTinyCA2 255
Other tools worth mentioning 255
Summary
256Chapter
12: OpenVPN GUI Tools 257OpenVPN
serveradministration: Webmin'sOpenVPN plugin
257ClientGUIsforLinux 260
KVpnc 260
GAdmin-OpenVPN-Client 262
NetworkManager
263Summary
264Chapter
13: AdvancedOpenVPN Configuration
265Tunneling
a proxyserverand protecting the proxy 266Scripting
OpenVPN—an overview 268Using a clientconfiguration directory with per-client
configurations
270 Individual firewall rules forconnecting
clients 273Distributed
compilation through
VPN tunnels with distcc 275Ethernet
bridging
withOpenVPN
277Automatic installation for Windows clients 279
Clustering
andredundancy
284Summary 285
Chapter 14: Mobile Securitywith OpenVPN 287
Anonymous
and uncensored InternetAccess 287OpenVPN
onWindows Mobile 289Embedded Linux- Maemo
292
Summary
294Chapter
15: Troubleshooting andMonitoring 295Testing networkconnectivity 295
Checking interfaces, routing, and connectivityon the VPN servers 298
Debugging
with tcpdump and IPTraf 303Using OpenVPN
protocol and status files fordebugging
305Scanning
servers with Nmap 307of Monitoring tools 308 ntop 309 Munin 310
Nagios
311 OpenVPNgraph 312Summary
313Appendix: Internet Resources and More 315