Home > Store

VPNs Illustrated: Tunnels, VPNs, and IPsec: Tunnels, VPNs, and IPsec

Register your product to gain access to bonus material or receive a coupon.

VPNs Illustrated: Tunnels, VPNs, and IPsec: Tunnels, VPNs, and IPsec


  • Sorry, this book is no longer in print.
Not for Sale


  • Copyright 2006
  • Dimensions: 7-3/8" x 9-1/4"
  • Pages: 480
  • Edition: 1st
  • Book
  • ISBN-10: 0-321-24544-X
  • ISBN-13: 978-0-321-24544-1

Virtual private networks (VPNs) based on the Internet instead of the traditional leased lines offer organizations of all sizes the promise of a low-cost, secure electronic network. However, using the Internet to carry sensitive information can present serious privacy and security problems. By explaining how VPNs actually work, networking expert Jon Snader shows software engineers and network administrators how to use tunneling, authentication, and encryption to create safe, effective VPNs for any environment.

Using an example-driven approach, VPNs Illustrated explores how tunnels and VPNs function by observing their behavior "on the wire." By learning to read and interpret various network traces, such as those produced by tcpdump, readers will be able to better understand and troubleshoot VPN and network behavior.

Specific topics covered include:

  • Block and stream symmetric ciphers, such as AES and RC4; and asymmetric ciphers, such as RSA and EIGamal
  • Message authentication codes, including HMACs
  • Tunneling technologies based on gtunnel
  • SSL protocol for building network-to-network VPNs
  • SSH protocols as drop-in replacements for telnet, ftp, and the BSD r-commands
  • Lightweight VPNs, including VTun, CIPE, tinc, and OpenVPN
  • IPsec, including its Authentication Header (AH) protocol, Encapsulating Security Payload (ESP), and IKE (the key management protocol)

Packed with details, the text can be used as a handbook describing the functions of the protocols and the message formats that they use. Source code is available for download, and an appendix covers publicly available software that can be used to build tunnels and analyze traffic flow.

VPNs Illustrated gives you the knowledge of tunneling and VPN technology you need to understand existing VPN implementations and successfully create your own.

Sample Content

Online Sample Chapter

Virtual Private Networks

Downloadable Sample Chapter

Download the Sample Chapter related to this title.

Table of Contents

Preface xiii

Part 1. Background 1

Chapter 1. Introduction 3

1.1 Purpose 3

1.2 Readers 4

1.3 Typographical Conventions 4

1.4 Source Code and Third-Party Programs 5

1.5 Testbed 5

1.6 Road Map 6

1.7 Summary 8

Chapter 2. TCP/IP Overview 9

2.1 Introduction 9

2.2 Layering 9

2.3 Encapsulation 11

2.4 Addressing 13

2.5 IP 20

2.6 UDP 22

2.7 TCP 24

2.8 ICMP 31

2.9 NAT and Private IP Addresses 35

2.10 PPP 40

2.11 IPv6 43

2.12 Routing 47

2.13 Summary 54

Exercises 55

Chapter 3. Cryptography Overview 57

3.1 Introduction 57

3.2 Symmetric Ciphers 58

3.3 Asymmetric Ciphers 69

3.4 Cryptographic Hash Functions, MACs, and HMACs 75

3.5 Digital Signatures 80

3.6 Certificates 83

3.7 Summary 87

Exercises 88

Chapter 4. Tunnels 89

4.1 Introduction 89

4.2 IP-in-IP Tunnels 92

4.3 PPPoE 95

4.4 GRE 100

4.5 PPTP 104

4.6 L2TP 109

4.7 MPLS 135

4.8 gtunnel 145

4.9 Summary 151

Exercises 152

Part 2. Tunnels and VPNs 153

Chapter 5. Virtual Private Networks 155

5.1 Introduction 155

5.2 PPTP 157

5.3 L2TP 158

5.4 Other VPNs 162

5.5 Summary 163

Exercises 163

Chapter 6. Secure Sockets Layer 165

6.1 Introduction 165

6.2 Cipher Suites 166

6.3 The SSL Protocol 167

6.4 SSL on the Wire 171

6.5 OpenSSL 191

6.6 The stunnel Program 196

6.7 SSL Security 204

6.8 Summary 205

Exercises 205

Chapter 7. SSH 207

7.1 Introduction 207

7.2 The SSHv1 Protocol 208

7.3 The SSHv2 Protocol 232

7.4 Building VPNs with SSH 260

7.5 Summary 266

Exercises 266

Chapter 8. Lightweight VPNs 267

8.1 Introduction 267

8.2 VTun 267

8.3 CIPE 272

8.4 Tinc 283

8.5 OpenVPN 292

8.6 Summary 302

Exercises 302

Part 3. IPSec 305

Chapter 9. IPsec 307

9.1 Introduction 307

9.2 An Overview of IPsec 308

9.3 Road Map for Part 3 308

9.4 Summary 309

Exercises 310

Chapter 10. IPsec Architecture 311

10.1 Introduction 311

10.2 Protocols 312

10.3 IPsec Modes 313

10.4 Security Associations 316

10.5 Combining Security Associations 318

10.6 Policies 320

10.7 IPsec Processing 321

10.8 Summary 323

Exercises 324

Chapter 11. AH 325

11.1 Introduction 325

11.2 The AH Header 326

11.3 Sequence Numbers 328

11.4 AH Processing 330

11.5 Transport Mode 331

11.6 Tunnel Mode 333

11.7 AH with IPv6 336

11.8 Summary 338

Exercises 338

Chapter 12. ESP 341

12.1 Introduction 341

12.2 The ESP Header 342

12.3 ESP Processing 344

12.4 Transport Mode 345

12.5 Tunnel Mode 348

12.6 ESP with IPv6 353

12.7 Summary 354

Exercises 355

Chapter 13. IKE 357

13.1 Introduction 357

13.2 ISAKMP 358

13.3 IKE 375

13.4 An Example Negotiation 388

13.5 Summary 393

Exercises 394

Chapter 14. IPsec Futures 397

14.1 Introduction 397

14.2 IPsec Architecture 398

14.3 AH 401

14.4 ESP 403

14.5 IKE 404

14.6 NAT Traversal 409

14.7 Summary 416

Exercises 416

Appendix A Source Code 419

A.1 Introduction 419

A.2 Cryptographic Routines 419

A.3 Library Code 423

Appendix B Miscellaneous Software 425

B.1 Netcat 425

B.2 tcpdump and Other Packet Sniffers 426

B.3 ssldump 429

B.4 PPP 431

Bibliography 435

Index 445


Untitled Document Introduction There is a revolution going on in enterprise networking. Until very recently, enterprises that needed to link computers in geographically dispersed locations had to build their own wide area networks (WANs). Usually this meant renting expensive and, by today's Internet standard, relatively slow frame relay circuits. A typical 56 Kb/s circuit could cost several hundred, or even over a thousand, dollars a month.

Today, the typical home computer user enjoys a broadband Internet connection having a 5 Mb/s download speed for a cost of about $40 per month. Commercial variants of this service, offering higher speeds and other amenities, are available for between $100 and $200 per month. Obviously, this significant increase in speed and decrease in cost represent a tremendous opportunity for enterprises, but they do introduce new problems.

The Internet is an open environment and, compared to leased lines, dreadfully insecure. Increases in bandwidth and decreases in cost are worthless if they mean that an enterprise's vital data can be intercepted by competitors, or that financial transactions are subject to manipulation by outsiders. This book discusses ways to overcome these problems by recreating the security of leased lines in a public medium such as the Internet.

The fundamental mechanism that allows us to have secure communications in the Internet is the notion of a tunnel. As we'll see, tunnels are a way of overlaying a logical or virtual network on top of a physical network. Once we have such a tunnel, we can secure it by encrypting and authenticating the network traffic that flows through it, thus recreating the security of private leased lines.

Of course, this simple description hides a substantial set of details and problems. We'll see that it's actually quite difficult to endow such tunnels with robust security. Much of the book is concerned with exploring solutions to these problems,and seeing why the successful solutions work and where the unsuccessful ones fail.

Source Code and Errata Availability Source code discussed in the text and other supporting material are available on my Web site athttp://home.netcom.com/~jsnader. The networking libraries and skeletons from Effective TCP/IPProgramming, which I mention and use occasionally in the text, are also available on the Web site.

My readers, it turns out, are much better at finding mistakes than I am. Although I go over the text carefully, checking that every i is dotted and every t crossed, errors still manage to evade me. Fortunately, most of these are caught by the careful and fastidious professionals at Addison-Wesley. Still, some errors will no doubt escape into the final published text. As these are discovered--usually by careful readers--I add them to an errata list for the book. This list is always available at my Web site.

Colophon As with my previous book, I produced camera-ready copy for this text using James Clark's splendid Groff typesetting suite (now maintained by Ted Harding and Werner Lemberg) and Rich Stevens' modified ms macros.I used the gpic, gtbl, and geqn preprocessors for the figures, tables, and mathematical notation, respectively. Some of the figures use gpic macros from Rich Stevens and Gary Wright. Indexing tools from Jon Bentley and Brian Kernighan were a huge help in the production of the index. I included the source code for the programming examples directly from their source files with Dave Hanson's loom utility. The text is set in the Palatino typeface.

As always, I welcome readers' comments, suggestions, and corrections. Please feel free to email me at the address below.

Jon C. Snader
Tampa, Florida
October 2005


Download the Index file related to this title.


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020