363_Web_App_FM.qxd 12/19/06 10:46 AM Page ii Syngress is committed to publishing high-quality books for IT Professionals and delivering those books in media and formats that fit the demands of our cus- tomers. We are also committed to extending the utility of the book you purchase via additional materials available from our Web site. SOLUTIONS WEB SITE To register your book, visit Once registered, you can access our Web pages. There you may find an assortment of value-added features such as free e-books related to the topic of this book, URLs of related Web sites, FAQs from the book, corrections, and any updates from the author(s). ULTIMATE CDs Our Ultimate CD product line offers our readers budget-conscious compilations of some of our best-selling backlist titles in Adobe PDF form. These CDs are the perfect way to extend your reference library on key topics pertaining to your area of exper- tise, including Cisco Engineering, Microsoft Windows System Administration, CyberCrime Investigation, Open Source Security, and Firewall Configuration, to name a few. DOWNLOADABLE E-BOOKS For readers who can’t wait for hard copy, we offer most of our titles in download- able Adobe PDF form. These e-books are often available weeks before hard copies, and are priced affordably. SYNGRESS OUTLET Our outlet store at features overstocked, out-of-print, or slightly hurt books at significant savings. SITE LICENSING Syngress has a well-established program for site licensing our e-books onto servers in corporations, educational institutions, and large organizations. Contact us at for more information. CUSTOM PUBLISHING Many organizations welcome the ability to combine parts of multiple Syngress books, as well as their own content, into a single volume for their own internal use. Contact us at for more information. Visit us at 421_Sec_Free_FM.qxd 12/22/06 1:30 PM Page i 421_Sec_Free_FM.qxd 12/22/06 1:30 PM Page ii Eric Seagren Wes Noonan Technical Editor Secure Your Network for Free USING NMAP, WIRESHARK, SNORT, NESSUS, AND MRTG 421_Sec_Free_FM.qxd 12/22/06 1:30 PM Page iii Syngress Publishing, Inc., the author(s), and any person or firm involved in the writing, editing, or production (collectively “Makers”) of this book (“the Work”) do not guarantee or warrant the results to be obtained from the Work. There is no guarantee of any kind, expressed or implied, regarding the Work or its contents.The Work is sold AS IS and WITHOUT WARRANTY.You may have other legal rights, which vary from state to state. In no event will Makers be liable to you for damages, including any loss of profits, lost savings, or other inci- dental or consequential damages arising out from the Work or its contents. Because some states do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you. You should always use reasonable care, including backup and other appropriate precautions, when working with computers, networks, data, and files. Syngress Media®, Syngress®,“Career Advancement Through Skill Enhancement®,”“Ask the Author UPDATE®,” and “Hack Proofing®,” are registered trademarks of Syngress Publishing, Inc.“Syngress:The Definition of a Serious Security Library”™,“Mission Critical™,” and “The Only Way to Stop a Hacker is to Think Like One™” are trademarks of Elsevier. Brands and product names mentioned in this book are trade- marks or service marks of their respective companies. KEY SERIAL NUMBER 001 HJIRTCV764 002 PO9873D5FG 003 829KM8NJH2 004 49HLPWE43W 005 CVPLQ6WQ23 006 VBP965T5T5 007 HJJJ863WD3E 008 2987GVTWMK 009 629MP5SDJT 010 IMWQ295T6T PUBLISHED BY Syngress Publishing, Inc. 800 Hingham Street Rockland, MA 02370 Secure Your Network for Free Copyright © 2007 by Elsevier. All rights reserved. Except as permitted under the Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher, with the exception that the program listings may be entered, stored, and executed in a computer system, but they may not be reproduced for publication. 1 2 3 4 5 6 7 8 9 0 ISBN-10: 1-59749-123-3 ISBN-13: 978-1-59749-123-5 Publisher:Andrew Williams Page Layout and Art: Patricia Lupien Acquisitions Editor: Gary Byrne Copy Editors: Michelle Melani and Audrey Technical Editors: Wes Noonan and Stephen Watkins Doyle Indexer: Richard Carlson Cover Designer: Michael Kavish For information on rights, translations, and bulk sales, contact Matt Pedersen, Director of Sales and Rights, at Syngress Publishing; email or fax to 781-681-3585. 421_Sec_Free_FM.qxd 12/22/06 1:30 PM Page iv v Lead Author Eric S. Seagren (CISA, CISSP-ISSAP,SCNP,CCNA, CNE-4, MCP+I, MCSE-NT) has 10 years of experience in the computer industry, with the last eight years spent in the financial services industry working for a Fortune 100 company. Eric started his com- puter career working on Novell servers and performing general net- work troubleshooting for a small Houston-based company. Since he has been working in the financial services industry, his position and responsibilities have advanced steadily. His duties have included server administration, disaster recovery responsibilities, business con- tinuity coordinator,Y2K remediation, network vulnerability assess- ment, and risk management responsibilities. He has spent the last few years as an IT architect and risk analyst, designing and evalu- ating secure, scalable, and redundant networks. Eric has worked on several books as a contributing author or technical editor.These include Hardening Network Security (McGraw- Hill), Hardening Network Infrastructure (McGraw-Hill), Hacking Exposed: Cisco Networks (McGraw-Hill), Configuring Check Point NGX VPN-1/FireWall-1 (Syngress), Firewall Fundamentals (Cisco Press), and Designing and Building Enterprise DMZs (Syngress). He has also received a CTM from Toastmasters of America. I would like to express my gratitude to several people who have helped me make this book a reality. First and foremost I would like to say thank you to Sandra and Angela, for their support, patience, and understanding during the entire process. I would like to thank Wes, for the quality and consistency of his constructive feedback. I would also like to thank Holla, for providing the original spark of an idea that eventually evolved into this book (specifically Chapters 2 and 7), and Moe, for being supportive when the opportunity pre- sented itself. 421_Sec_Free_FM.qxd 12/22/06 1:30 PM Page v vi Wesley J. Noonan (Houston,Texas) has worked in the computer industry for more than 12 years, specializing in Windows-based net- works and network infrastructure security design and implementa- tion. He is a Staff Quality Engineer for NetIQ, working on the company’s security solutions product line. Wes was the author of Hardening Network Infrastructure (McGraw-Hill) and was a con- tributing/coauthor for The CISSP Training Guide (Que Publishing), Hardening Network Security (McGraw-Hill), Designing and Building Enterprise DMZs (Syngress), and Firewall Fundamentals (Cisco Press). Wes was also the technical editor for Hacking Exposed: Cisco Networks (McGraw-Hill). He contributes to Redmond magazine, writing on the subjects of network infrastructure and security, and he maintains a Windows Network Security section called “Ask the Experts” for (http://searchwindowssecurity.,289620,sid45_tax298206,00.html). Wes has also presented at TechMentor 2004. Wes lives in Houston,Texas. Stephen Watkins (CISSP) is an Information Security Professional with more than 10 years of relevant technology experience, devoting eight of these years to the security field. He currently serves as Information Assurance Analyst at Regent University in southeastern Virginia. Before coming to Regent, he led a team of security professionals providing in-depth analysis for a global-scale government network. Over the last eight years, he has cultivated his expertise with regard to perimeter security and multilevel security architecture. His Check Point experience dates back to 1998 with FireWall-1 version 3.0b. He has earned his B.S. in Computer Science from Old Dominion University and M.S. in Computer Science, with Concentration in Infosec, from James Madison Technical Editors 421_Sec_Free_FM.qxd 12/22/06 1:30 PM Page vi vii University. He is nearly a lifelong resident of Virginia Beach, where he and his family remain active in their church and the local Little League. Stephen was the technical editor for Chapter 3. 421_Sec_Free_FM.qxd 12/22/06 1:30 PM Page vii viii Much of the code presented throughout this book is available for download from Look for the Syngress icon in the margins indicating which examples are available from the companion Web site. Companion Web Site 421_Sec_Free_FM.qxd 12/22/06 1:30 PM Page viii ix Contents Chapter 1 Presenting the Business Case for Free Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 The Costs of Using Free Security Solutions . . . . . . . . . . . . . .2 Training Costs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 Hardware Costs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 Consulting Costs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 Hidden Costs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 The Savings of Using Free Security Solutions . . . . . . . . . . . .6 Purchase Costs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 Maintenance Costs . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 Customization Costs . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 Comparing Free Solutions with Commercial Solutions . . . . .8 Strengths of Free Solutions . . . . . . . . . . . . . . . . . . . . . . .9 Weaknesses of Free Solutions . . . . . . . . . . . . . . . . . . . . .10 Evaluating Individual Solutions . . . . . . . . . . . . . . . . . . .12 “Selling” a Free Solution . . . . . . . . . . . . . . . . . . . . . . . . . . .16 Selling by Doing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Presenting a Proposal . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 Solutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . .21 Chapter 2 Protecting Your Perimeter. . . . . . . . . . . . . . . 23 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 Firewall Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 Firewall Architectures . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27 Screened Subnet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27 One-Legged . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28 True DMZ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30 Implementing Firewalls . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 Hardware versus Software Firewalls . . . . . . . . . . . . . . . .32 Configuring netfilter . . . . . . . . . . . . . . . . . . . . . . . . . . .32 Choosing a Linux Version . . . . . . . . . . . . . . . . . . . . .32 421_Sec_Free_TOC.qxd 12/22/06 2:31 PM Page ix x Contents Choosing Installation Media . . . . . . . . . . . . . . . . . . .33 Linux Firewall Operation . . . . . . . . . . . . . . . . . . . . .36 Configuration Examples . . . . . . . . . . . . . . . . . . . . . .42 GUIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55 Smoothwall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76 Configuring Windows Firewall . . . . . . . . . . . . . . . . . . .85 Providing Secure Remote Access . . . . . . . . . . . . . . . . . . . . .86 Providing VPN Access . . . . . . . . . . . . . . . . . . . . . . . . . .87 Using Windows as a VPN Concentrator . . . . . . . . . .89 iPig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93 OpenSSL VPN . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98 Providing a Remote Desktop . . . . . . . . . . . . . . . . . . . .108 Windows Terminal Services . . . . . . . . . . . . . . . . . . .109 VNC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113 Using the X Window System . . . . . . . . . . . . . . . . .119 Providing a Remote Shell . . . . . . . . . . . . . . . . . . . . . .125 Using Secure Shell . . . . . . . . . . . . . . . . . . . . . . . . .126 Using a Secure Shell GUI Client . . . . . . . . . . . . . . .128 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130 Solutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131 Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . .132 Chapter 3 Protecting Network Resources . . . . . . . . . . 133 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134 Performing Basic Hardening . . . . . . . . . . . . . . . . . . . . . . .134 Defining Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135 Access Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137 Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137 Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138 Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138 Hardening Windows Systems . . . . . . . . . . . . . . . . . . . . . . .139 General Hardening Steps . . . . . . . . . . . . . . . . . . . . . . .139 Users and Groups . . . . . . . . . . . . . . . . . . . . . . . . . .142 File-Level Access Controls . . . . . . . . . . . . . . . . . . . .147 Additional Steps . . . . . . . . . . . . . . . . . . . . . . . . . . .152 Using Microsoft Group Policy Objects . . . . . . . . . . . . .153 Account Lockout Policy . . . . . . . . . . . . . . . . . . . . .159 421_Sec_Free_TOC.qxd 12/22/06 2:31 PM Page x Contents xi Audit Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .160 User Rights Assignment . . . . . . . . . . . . . . . . . . . . .160 Hardening Linux Systems . . . . . . . . . . . . . . . . . . . . . . . . .164 General Hardening Steps . . . . . . . . . . . . . . . . . . . . . . .164 Users and Groups . . . . . . . . . . . . . . . . . . . . . . . . . .165 File-Level Access Controls . . . . . . . . . . . . . . . . . . . .168 Using the Bastille Hardening Script . . . . . . . . . . . . . . .172 Using SELinux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .173 Hardening Infrastructure Devices . . . . . . . . . . . . . . . . . . . .175 Patching Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176 Patching Windows Systems . . . . . . . . . . . . . . . . . . . . .177 Patching Linux Systems . . . . . . . . . . . . . . . . . . . . . . . .179 Personal Firewalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180 Windows Firewall . . . . . . . . . . . . . . . . . . . . . . . . . . . .180 Netfilter Firewall . . . . . . . . . . . . . . . . . . . . . . . . . . . . .187 Configuring TCP Wrappers . . . . . . . . . . . . . . . . . . . . .187 Providing Antivirus and Antispyware Protection . . . . . . . . .188 Antivirus Software . . . . . . . . . . . . . . . . . . . . . . . . . . . .189 Clam AntiVirus . . . . . . . . . . . . . . . . . . . . . . . . . . .189 Using Online Virus Scanners . . . . . . . . . . . . . . . . . .196 Antispyware Software . . . . . . . . . . . . . . . . . . . . . . . . .196 Microsoft Windows Defender . . . . . . . . . . . . . . . . .197 Microsoft Malicious Software Removal Tool . . . . . .200 Encrypting Sensitive Data . . . . . . . . . . . . . . . . . . . . . . . . .201 EFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209 Solutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209 Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . .212 Chapter 4 Configuring an Intrusion Detection System 215 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .216 Intrusion Detection Systems . . . . . . . . . . . . . . . . . . . . . . .216 Configuring an Intrusion Detection System . . . . . . . . . . . .217 Hardware Requirements . . . . . . . . . . . . . . . . . . . . . . .218 Placing Your NIDS . . . . . . . . . . . . . . . . . . . . . . . . . . .218 Configuring Snort on a Windows System . . . . . . . . . . . . .221 Installing Snort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .222 Configuring Snort Options . . . . . . . . . . . . . . . . . . . . .225 Using a Snort GUI Front End . . . . . . . . . . . . . . . . . . .231 421_Sec_Free_TOC.qxd 12/22/06 2:31 PM Page xi xii Contents Configuring IDS Policy Manager . . . . . . . . . . . . . .232 Configuring Snort on a Linux System . . . . . . . . . . . . . . . .240 Configuring Snort Options . . . . . . . . . . . . . . . . . . . . .240 Using a GUI Front End for Snort . . . . . . . . . . . . . . . .246 Basic Analysis and Security Engine . . . . . . . . . . . . .246 Other Snort Add-Ons . . . . . . . . . . . . . . . . . . . . . . . . . . . .254 Using Oinkmaster . . . . . . . . . . . . . . . . . . . . . . . . . . . .254 Additional Research . . . . . . . . . . . . . . . . . . . . . . . . . .256 Demonstrating Effectiveness . . . . . . . . . . . . . . . . . . . . . . .257 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .258 Solutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259 Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . .261 Chapter 5 Managing Event Logs . . . . . . . . . . . . . . . . . 263 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .264 Generating Windows Event Logs . . . . . . . . . . . . . . . . . . . .264 Using Group Policy to Generate Windows Events Logs 267 Generating Custom Windows Event Log Entries . . . . .274 Collecting Windows Event Logs . . . . . . . . . . . . . . . . .275 Analyzing Windows Event Logs . . . . . . . . . . . . . . . . . .277 Generating Syslog Event Logs . . . . . . . . . . . . . . . . . . . . . .279 Windows Syslog . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282 Generating Syslog Events . . . . . . . . . . . . . . . . . . . .282 Receiving Syslog Events . . . . . . . . . . . . . . . . . . . . .295 Linux Syslog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .297 Generating Syslog Events . . . . . . . . . . . . . . . . . . . .297 Encrypting Syslog Traffic . . . . . . . . . . . . . . . . . . . . .298 Receiving Syslog Events on a Linux Host . . . . . . . .311 Analyzing Syslog Logs on Windows and Linux . . . . . . .312 Windows Log Analysis . . . . . . . . . . . . . . . . . . . . . .313 Linux Log Analysis . . . . . . . . . . . . . . . . . . . . . . . . .321 Securing Your Event Logs . . . . . . . . . . . . . . . . . . . . . . . . .327 Ensuring Chain of Custody . . . . . . . . . . . . . . . . . . . . .328 Ensuring Log Integrity . . . . . . . . . . . . . . . . . . . . . . . .329 Applying Your Knowledge . . . . . . . . . . . . . . . . . . . . . . . . .331 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .333 Solutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . .333 Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . .335 421_Sec_Free_TOC.qxd 12/22/06 2:31 PM Page xii Contents xiii Chapter 6 Testing and Auditing Your Systems . . . . . . 337 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .338 Taking Inventory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .338 Locating and Identifying Systems . . . . . . . . . . . . . . . . .339 Nmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .341 Super Scanner . . . . . . . . . . . . . . . . . . . . . . . . . . . .347 Angry IP Scanner . . . . . . . . . . . . . . . . . . . . . . . . . .351 Scanline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .352 Special-Purpose Enumerators . . . . . . . . . . . . . . . . .355 Locating Wireless Systems . . . . . . . . . . . . . . . . . . . . . .357 Network Stumbler . . . . . . . . . . . . . . . . . . . . . . . . .358 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .361 Network Topology Maps . . . . . . . . . . . . . . . . . . . . .362 Access Request Forms . . . . . . . . . . . . . . . . . . . . . .364 Business Continuity and Disaster Recovery Plans . . .365 IT Security Policies/Standards/Procedures . . . . . . . .365 Vulnerability Scanning . . . . . . . . . . . . . . . . . . . . . . . . . . . .366 Nessus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .367 Running Nessus on Windows . . . . . . . . . . . . . . . . .368 Running Nessus on Linux . . . . . . . . . . . . . . . . . . .371 X-Scan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .375 Microsoft Baseline Security Analyzer . . . . . . . . . . . . . .379 OSSTMM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .382 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .386 Solutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . .386 Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . .387 Chapter 7 Network Reporting and Troubleshooting 389 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .390 Reporting on Bandwidth Usage and Other Metrics . . . . . .390 Collecting Data for Analysis . . . . . . . . . . . . . . . . . . . . . . . .392 Understanding SNMP . . . . . . . . . . . . . . . . . . . . . . . . . . . .394 Configuring Multi Router Traffic Grapher . . . . . . . . . .397 Configuring MZL & Novatech TrafficStatistic . . . . . . .400 Configuring PRTG Traffic Grapher . . . . . . . . . . . . . . .403 Configuring ntop . . . . . . . . . . . . . . . . . . . . . . . . . . . .412 Enabling SNMP on Windows Hosts . . . . . . . . . . . . . .418 421_Sec_Free_TOC.qxd 12/22/06 2:31 PM Page xiii xiv Contents Enabling SNMP on Linux Hosts . . . . . . . . . . . . . . . . .421 Troubleshooting Network Problems . . . . . . . . . . . . . . . . . .424 Using a GUI Sniffer . . . . . . . . . . . . . . . . . . . . . . . . . .425 Using a Command-Line Sniffer . . . . . . . . . . . . . . . .433 Additional Troubleshooting Tools . . . . . . . . . . . . . . . . . . . .438 Netcat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .439 Tracetcp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .439 Netstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .440 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .442 Solutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . .442 Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . .444 Chapter 8 Security as an Ongoing Process . . . . . . . . . 447 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .448 Patch Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .448 Network Infrastructure Devices . . . . . . . . . . . . . . . . . .452 Operating System Patches . . . . . . . . . . . . . . . . . . . . . .453 Application Patches . . . . . . . . . . . . . . . . . . . . . . . . . . .453 Change Management . . . . . . . . . . . . . . . . . . . . . . . . . . . .454 Change Causes Disruption . . . . . . . . . . . . . . . . . . . . . .454 Inadequate Documentation Can Exacerbate Problems . .455 Change Management Strategy . . . . . . . . . . . . . . . . . . .455 Antivirus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .459 Antispyware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .459 Intrusion Detection Systems . . . . . . . . . . . . . . . . . . . . . . .460 Vulnerability Scanning . . . . . . . . . . . . . . . . . . . . . . . . . . . .460 Vulnerability Management Cycle . . . . . . . . . . . . . . . . .461 Roles and Responsibilities . . . . . . . . . . . . . . . . . . . . . .463 Penetration Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .463 Obtaining the Support of Senior Management . . . . . . .464 Clarify What You Are Buying . . . . . . . . . . . . . . . . . . . .464 Policy Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .465 Physical Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .466 CERT Team . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .468 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .470 Solutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . .470 Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . .472 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475 421_Sec_Free_TOC.qxd 12/22/06 2:31 PM Page xiv Presenting the Business Case for Free Solutions Solutions in this chapter: ■ The Costs of Using Free Security Solutions? ■ The Savings of Using Free Security Solutions? ■ Comparing Free Solutions with Commercial Solutions ■ “Selling” a Free Solution Chapter 1 1  Summary  Solutions Fast Track  Frequently Asked Questions 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 1 Introduction You may be looking for inexpensive ways to solve a security problem and want to know more about the free tools that are available.This book will guide you to some of the best free solutions. In some environments, taking the initiative and implementing any type of security measures can get you in trouble; even with the best planning, problems can arise.This chapter will help you gain the support you need in order to implement a cost saving solution. Whether you are the person implementing the changes and need to “sell” the solution to your manager, or you’re the person making the decisions and need to understand the true implications of a particular “free” solution, this chapter will help you find solutions to your security problems.This chapter discusses some of the hidden costs associated with free solutions and clarifies what comes from those solutions.This chapter also addresses the fact that in most cases, an apples-to-apples comparison between a free package and a commercial product is not feasible. With all of this information, you should be in a good position to propose a solution and back up your choice with some compelling business arguments. The Costs of Using Free Security Solutions In the case of security solutions, few things in life are free.And while you may not pay for a security solution itself, there are costs associated with implementing a solution that are not obvious. In most cases, your security needs dictate which solutions are appropriate; if there is not a free solution available, you have to use commercial tools. Fortunately, there are a lot of high-quality free solutions available.The cross section included in subsequent chapters is aimed at providing a spectrum of solutions with a variety of sophistication levels. If you dive headlong into implementing a free solution without adequate knowledge and research, it could end up costing you more than if you had purchased a commercial solution. 2 Chapter 1 • Presenting the Business Case for Free Solutions 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 2 Training Costs Training costs are one of the biggest expenses when it comes to imple- menting a free solution. First are the direct training expenses (e.g., sending someone for classroom instruction).Your options may be limited when it comes to training for free software solutions. In most cases, training does not exist in a focused format (i.e., you probably won’t find a class on netfilter fire- walls). Instead, you may be able to find applicable training indirectly, such as in classes on general Linux use or administration. Another training cost is materials (e.g., books).Aside from this book, there will likely be areas where you want more specialized information. For example, if you are implementing a Snort intrusion detection system (IDS), this book walks you through setting up Snort.A small library covering the specific software you have deployed is a worthwhile investment. You will also incur training costs,such as not having access to an employee during training.This time away from work is an expense, because you are paying for an asset that isn’t available.The same is true if the employee is on-site and “self-training.” Hardware Costs A security appliance is a device that doesn’t require a computer and is only used for its intended purpose, while all of the free solutions require a system to run on. Luckily, the requirements are usually minimal; therefore, you can often use an old PC. However, connectivity requirements could make using the system in a nondedicated configuration a security risk. Rarely does a system require enough resources to make using the same host for any other function impractical (e.g., the Snort IDS logging capability can quickly eat up disk space, leaving little to no resources for other programs). If there are no old systems available, there are many online retailers offering older systems at affordable rates.A large portion of the cost for low- end PC’s is often for the operating system. Many retailers offer affordable sys- tems that either include Linux as the operating system, or come without an operating system installed.These allow you to purchase a relatively modern Presenting the Business Case for Free Solutions • Chapter 1 3 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 3 system cheaply, and then install your own OS on it.This can be a viable option for running security tools and providing user workstations. Consulting Costs You must carefully weigh and balance where you spend your money.Too little training and you will end up hiring consultants. Implementing, configuring, or fixing your free firewall can cost a lot, more than if you had bought a fire- wall. With small commercial firewalls costing around $500.00, it doesn’t take long before free isn’t so free. With that said, don’t be afraid to call a consultant if necessary. Having a well-paid consultant configure your free solution and make sure that it’s implemented using best practices is a steal compared to implementing some proprietary solutions.A consultant can also act as a trainer.You can shadow the consultant and see how and what is being done, and you can ask ques- tions and learn why things are done a certain way. In this way you can have your solution set up by someone who is knowledgeable and experienced, and provide training and guidance to the in-house personnel. If you have ever had to rely on consultants, you probably know they are not always a “good buy.” Sometimes they are not as knowledgeable as you were led to believe.The key is to communicate with the consulting firm, being very clear about what your needs are. A good consultant can save the day. WARNING You should always be careful when cutting consulting budgets. I have seen attempts to save money end up costing more. In almost all cases, getting a consultant in quickly is the best course of action and the most cost effective in the long run. If you find a skilled consultant you like, a monthly retainer might be a good investment. 4 Chapter 1 • Presenting the Business Case for Free Solutions 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 4 Hidden Costs What are all the costs of a free solution? For starters, power consumption. I had a Windows 98 system that was only being used as a print server. It occurred to me that the PC cost me approximately $7 per month in elec- tricity.With a dedicated print server costing only about $30.00 and using vir- tually no electricity, I would save money within five months by buying the print server.The Pentium II running Windows 98 was technically “free,” but paying for electricity to keep it running was not the most cost-effective choice. Some security tools are not offered as a commercial appliance, and some are (e.g., small, low cost firewalls that use far less power than a standard desktop PC are available from several manufacturers).Your cost for electricity will vary. Based on your electric bill, you can calculate with a high degree of accuracy what a given device costs. Another consideration is heating, ventilation, and air-conditioning (HVAC) costs. HVAC is basically the climate controls.Additional computers create additional heat, which costs more money for air conditioning.The same considerations apply as for power consumption. If a stand-alone appli- ance is not an option, the additional HVAC requirements are an unavoidable cost; however, in those cases where more efficient appliance-based solutions exist, they almost always produce less heat than a normal workstation.This also applies to the difference between an older computer and a newer com- puter. Newer systems that demand more power and cooling when they are being heavily utilized often incorporate energy-saving characteristics that are superior to those of the older systems. There is also the cost of real estate.A decommissioned full-sized tower PC takes up a lot more space than a new commercial appliance the size of a cigar box.You may have plenty of room now, but as the server room gets more and more crowded, space could become an issue.A keyboard, video, and mouse (KVM) switch might save more in space than it costs to buy.As the servers become increasingly tightly packed, good air flow and adequate cooling will be inhibited, and physical access to the systems for operation or maintenance will also be difficult. Inefficiency is another cost of free solutions with respect to the fact that the support staff are likely unfamiliar with the new free solutions. When a Presenting the Business Case for Free Solutions • Chapter 1 5 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 5 staff member performs a task on a new firewall, it takes longer to do than if they are familiar with the firewall.This inefficiency typically costs only the time to complete a task; however, if an outage or business disruption occurs, this delay could result in lost profit or business.These delays must also be accounted for when planning projects and other activities. Free solutions are usually produced by small organizations or by an indi- vidual.These solutions may do an excellent job in their assigned roles, but may not be well known.This could be a liability if the individual who con- figured your free solution leaves or is otherwise unavailable. If you have a PIX firewall that needs work, you probably would not have a hard time locating a resource. On the other hand, if you need someone to take over the adminis- tration of an obscure free solution, finding someone could be difficult.This difficulty could manifest itself as a hidden cost by increasing the delay before a problem can be addressed, having to pay a premium for a consultant, or any number of other inefficiencies. The Savings of Using Free Security Solutions The following section discusses how a free security solution can save you money.The primary savings is obvious: you didn’t pay for the product; how- ever, there are additional benefits.This section offers a detailed look into the benefits of using free software. By evaluating the expected savings and costs, you can form a more practical, accurate picture of what will be gained by implementing a free security solution. Purchase Costs The purchase cost is one of the single largest cost savings of using free soft- ware.The best example of this is with firewalls.A small Linksys or Netgear firewall costs around $20.00 to $50.00.They use almost no power, support port forwarding, perform Network Address Translation (NAT), act as a Dynamic Host Configuration Protocol (DHCP) server, and are stateful packet filters. Suppose you use Linux and netfilter to run a firewall for free. Odds are it will cost more to pay for the employee’s time to set up the Linux firewall 6 Chapter 1 • Presenting the Business Case for Free Solutions 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 6 than the Linksys would cost to buy. Firewalls are one of the best examples of how readily available affordable commercial solutions can be. You can still save money on purchases. Some types of products, particu- larly IDSes, network analysis and reporting tools, and commercial virtual pri- vate network (VPN) solutions can cost staggering amounts of money.When comparing prices, come as close as possible to comparing like products. Using the most expensive “deluxe” software suite available as the price for decision making is misleading.The free solution will not have the same features and capabilities as the commercial version. Look at the features you think you need as a starting point for which commercial products would be viable options. Use the costs of those products as your basis for determining what the free solution will save you. Maintenance Costs Maintenance can be expensive; it is not uncommon for a yearly maintenance contract to cost 10 percent of the purchase price.This price will also fluc- tuate, as almost all vendors have various support tiers with varying response times and service level agreements (SLAs).The reality is, however, if you opt for the free solution and spend the 10 percent on training instead, you would probably have a very high level of responsiveness from your own in-house staff. Ensuring an equivalent level of responsiveness and availability from the vendor would likely cost you a large sum.Your own support staff could prob- ably go to the office or address the issue remotely far more quickly than all but the largest and most well-established vendors. Even if a vendor can have someone on site in two hours, sometimes getting a live person to return your call and schedule the emergency appointment takes time.You can probably reach your own staff as quickly, if not more so.The level of service you expect should be factored in when estimating the cost savings available by not having to purchase a maintenance contract. Customization Costs Customization is an area that can offer huge gains or be inconsequential, depending on your circumstances. If you purchase a commercial product, you may find that there is no way it can be customized for your environment. If Presenting the Business Case for Free Solutions • Chapter 1 7 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 7 some degree of customization is available, it is rarely free. Often, the hourly rate for such services is at a premium, the assumption being you must really want or need the desired functionality if you are willing to pay to add it. With some free solutions, this customization can be affordable, or even free, if you have the expertise. However, not all free software is customizable. Just because it’s free does not always mean it is open source. Open source software is software where the source code (i.e., the programming code used to make it run) is freely available. When software is open source, you can download the source code and edit it to your heart’s content.You can add as few or as many custom features as you want. Obviously, this is an advantage that not everyone will need or have the means to take advantage of. Depending on the software package in question, some are programmed using different programming languages, so even if you have a resource who knows enough to be able to customize the program, they might not know the particular programming language that is required. Customization is also something you don’t know you need until you are well into the implementation phase. If you know your customization needs ahead of time you can investigate and weigh the costs accordingly. Generally speaking, even if the cost is the same to customize the free solution as a com- parable commercial solution, the level of customization that is possible is often (but not always) equivalent or better with the free solution. Comparing Free Solutions with Commercial Solutions When it comes to making an informed decision as to whether to purchase a commercial solution or implement a free solution, there are some additional non-dollar-related considerations to take into account. First and foremost, compare like functionality. Don’t compare the deluxe version of the commer- cial product to the free version; they won’t have the same features or learning curve, or require the same hardware. Ultimately, by making the most informed and well-reasoned comparison possible, the best solution will be chosen. 8 Chapter 1 • Presenting the Business Case for Free Solutions 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 8 Strengths of Free Solutions One advantage free solutions often have over their commercial counterparts is that of development speed.This varies from one product to another; not all free products have quick development cycles.The open-source packages often have very fast development cycles and can address the latest security issue more quickly than their commercial counterparts. If you want to stay on the cutting edge, free software (especially open-source software) might be a better path than commercial solutions. Previously, we discussed customization as a cost savings with some free software.This is because often you can do the customizing yourself instead of paying the vendor to do it for you. Customization is worth mentioning as a strength of its own, above and beyond the cost savings.Again, not all free soft- ware is customizable. Sometimes the best software in a particular category uses closed code and there is no way for you to perform any customization. But one of the greatest strengths of the open-source movement is that everyone has the freedom to edit, customize, and improve the software. A potential strength of free solutions is the speed with which they can be implemented (which is different than the development speed). When I speak of the implementation speed of free software I am referring to the time it takes to get the software loaded and working.This includes not only installa- tion, but also the red tape sometimes involved in making significant purchases. For example, suppose you are trying to form a business partnership that will be beneficial to your organization.The nature of the arrangement is such that time is of the essence; the sooner the partnership is completed the better.The partnership involves network connectivity to facilitate the exchange of infor- mation.After reviewing the plans of how it would be done, your potential partner is hesitant to go through with it, because you lack adequate firewall protection. Maybe your current Internet connection is filtered with a con- sumer-level home router/firewall and you need a separate demilitarized zone (DMZ) with some advanced NATing rules and better logging.You could contact a vendor, wait for a response, get a quote on the price, and pass that to your manager for approval.After your manager approves the purchase, you hand it to accounting and they make the purchase and arrange shipping. Once it arrives, you must install and configure the new firewall and then test Presenting the Business Case for Free Solutions • Chapter 1 9 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 9 it.A faster approach would be to grab the old PC from the closet, download and install Linux on it, and configure the firewall. If your environment allows it, implementing the free solution could be much faster. In environments where there are restrictions on permitted vendors, permitted software, per- mitted hardware, and so on, getting approval for a free solution could be more difficult and time consuming than a commercial solution. Ultimately, your environment will dictate whether implementation speed can truly pan out as an advantage or not. You might think that all free software is produced by some kid after school and will be unstable and lacking the quality control of a commercial software development project. While this is certainly true some of the time, at other times it could not be farther from the truth.The fact is that the larger, well-established open-sourced projects can have hundreds of programmers reviewing, revising, scrutinizing, and modifying the code. Very few commer- cial companies have the same amount of resources to put into a single soft- ware product.This means that in many cases you are getting software that has been through more peer review and testing than the commercial equivalent. This is not always true; in many cases the free software has very little quality control and you, as the user, are really doing the testing. Basically, this means that the quality of free solutions will have a lot of variance.To increase the odds that you are not trying to implement buggy software, do your home- work. If you stick to mature products that have a proven track record you will certainly improve your odds.Avoiding new releases that implement major architectural changes may help as well. If the current release of a product you are using incorporates newly added support for the latest chipset, it might be wise to wait for that release to be tested a little more before deploying it in your environment. For an excellent and lengthy article on the merits of free software, refer to In reality, some of the free offerings are not fit to be run in any sort of critical role, while others can do so with aplomb. Ultimately, not all free software is “cheap” software; some of the free offerings are of very high technical quality. Weaknesses of Free Solutions The single biggest drawback to implementing a free solution in a production environment is one of support, or lack of support. When you download 10 Chapter 1 • Presenting the Business Case for Free Solutions 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 10 something for free from the Internet, there is generally no phone number to call and ask questions.This is sometimes mitigated by high quality documen- tation, and in some cases extensive online user forums where you can ask questions and receive help from the creator of the package or other users. On the other hand, high-quality documentation is the exception rather than the norm, and many of the free utilities have little in the way of documentation. This consideration is one of the biggest concerns for management. Generally speaking, the more mission critical the role of the security software is, the more hesitant you should be about implementing a solution with minimal support. If you are a company that depends on the Internet, you should require a higher level expertise from in-house technical staff before imple- menting a free Linux firewall, compared with another company that makes money in a storefront and only uses the Internet to surf the Web.This isn’t to say that the support cannot be adequate with free software or that you shouldn’t use free solutions to fulfill critical needs, only that you need to do so knowingly and after careful consideration and planning. The management capabilities of free software solutions are typically not as robust as they are with commercial offerings.Your particular product will determine if this is a real consideration or not. Most often the presence or absence of management capabilities is more noticeable with free IDSes, antivirus, and antispyware offerings.The common denominator here is that these products require frequent updates in order to maintain their value and do their job effectively.An enterprise-class antivirus program will offer a lot of control and features around signature updates, such as when and how to perform the updates and how to handle things when a virus is detected.The free solutions are generally more limited, often requiring the scanning or updating process to be performed manually, and responding to a positive detection may have to be an interactive process, rather than an automated one. Another area where the free solutions are also sometimes lacking is reporting. While some offer excellent reporting, many others offer little to no reporting capability. In most cases, you will be able to manually configure some type of reporting on your own using freely available utilities. Even if you can arrange for some automated logging or reporting to be generated, it won’t be as simple or quick as it would be if it were a commercial product Presenting the Business Case for Free Solutions • Chapter 1 11 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 11 that supported that functionality natively.As you begin considering free solu- tions, you will want to also consider not only the logging capabilities you want, but those you need. In many cases, if you are in a highly regulated industry, such as banking, or healthcare, the lack of adequate logging capa- bility is the determining factor that leads to a decision to go with commercial software. If you have auditors you need to satisfy, you will want to research the audit trail you will be able to generate carefully, before coming to a strategic decision on your solution. Previously, we touched on the fact that the free solutions are often not well known, and how this can translate into a hidden cost in consulting fees. This liability can go beyond consulting fees. If you were hiring a new employee and specified that they need to know Cisco equipment, you could undoubtedly find someone in short order. If you specified you wanted them to be familiar with some little-known free solution you have implemented, you could have a very hard time finding someone.That’s not to say that they couldn’t be trained, but again, there are costs and disadvantages associated with that.The familiarity (or lack thereof ) could also cause the time it takes to implement a solution to be longer than with a more widely understood technology. Speed of implementation was mentioned as a potential asset, but it can easily be a liability if there is no one available who understands the solution. Ultimately, there are advantages to using industry standard solutions over less widely deployed offerings. Evaluating Individual Solutions As you do your research, you will need to determine if the free solution is the best solution.There are a whole host of factors which will go into making this determination.The following list briefly summarizes the steps needed to make a determination as to whether or not a free solution is the best solution for you. 1. Identify Your Options This can be the hardest part of the process, knowing what free alternatives exist. Hopefully this book will help, but there are also on-line sites to help you find free software. One of the largest sites housing open source software is check out 12 Chapter 1 • Presenting the Business Case for Free Solutions 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 12 can find a more programmer-oriented site containing only software that runs on Linux at directory of free software is located at similar directory of free software for Microsoft Windows is located at Finally, a CD containing some “top picks” of free software for use on Windows is located at 2. Research Each Option Typically, this will mean doing searches on the software.Take note of how many problems people have, and if they have been fixed. Check the developer’s Web site and documen- tation. See if the documentation is well-crafted and complete.This is when you will weed out the majority of candidates and hopefully be left with a list of quality choices. 3. Compare Products The previous step is meant to sort out the best free solutions.This step is aimed at comparing the best free solutions against their commercial counterparts.This is where you may rule out some products as too expensive or to hard to use. Metrics to use for comparison include: ■ Functionality The product must meet your business needs to be considered. Pay attention to volumes.The product might do what you want, but not on the scale you want it to. Consider if the product will work with other utilities or if it uses propri- etary and closed source methods, protocols, or algorithms. These traits may act as limiters and hinder flexibility later on. ■ Cost This is one of the major reasons you are considering a free solution.Try and be as accurate as possible in your esti- mates of the true costs, including things such as purchase cost, maintenance, training, upgrades, and so on. ■ Momentum How well established is the product? Remember this is a consideration for free software and commercial soft- ware.The more well established the software is, the better the odds the creators will be around in the future.A larger more well-established project will also likely have better community Presenting the Business Case for Free Solutions • Chapter 1 13 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 13 support and reliability. Included in the overall momentum is to look at how active the project is.You don’t want to invest a lot of time and energy in a product that is likely to just die off and fade away. ■ Support What does support cost? Is it available? How timely is the support? What format does support take (online forums, e-mail, phone, and so on). ■ Performance Which solutions are the best performers? This includes speed, efficiency, and reliability.A powerful software package that crashes every hour isn’t a viable option. ■ Usability Is the product user friendly? If the learning curve is very high, your training costs will rise. If the product doesn’t have a feature or function you like, can you customize it and make it more user friendly? ■ Security Even for a security tool, you must consider the security implications. Is the product secure? Will it be handling secure data? Are you opening up any new security risks? What type of auditing and logging can it produce? ■ Legal and License Issues Be sure and review the license agreement closely. Many times the free software is not free if you are a business, or there are special restrictions on the number of installations or other criteria. When in doubt have your legal counsel review the license agreement for you. ■ Individual Criteria These are any special needs or require- ments unique to your environment. What’s good for other organizations might not work for you. 4. Perform Detailed Testing At this stage, you have hopefully nar- rowed the playing field down to just one or two selections. It’s time to put these products through a real test and see if they do what their manufacturers claim they do.This can be done in a lab or possibly on the production network, depending on the risks involved and the nature of the product.You will need to evaluate how best to perform your detailed testing based on your circumstances. 14 Chapter 1 • Presenting the Business Case for Free Solutions 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 14 5. Come to a Conclusion After all this research, you can make a decision on what you think the best solution is. Whether you are the final approver or you need to forward your recommendation to someone else for approval, at this point you should have all the facts collected in order for a good decision to be made. Remember, the preceding steps leave a lot of room for flexibility.They may be performed in a more or less structured fashion.You might not for- mally cover all the steps, but in one form or another, those steps should occur. The more thoroughly you document the steps, the more you will be in a better position to justify your choices. Now that we have discussed the many ways that the cost of a free solution may be higher or lower than the commercial equivalent, let’s look at an example. Suppose your manager wants you to provide a reporting mechanism to see who is using the majority of the Internet bandwidth.Your manager also wants to know what the user(s) in question are using the bandwidth for. You search around and learn about a product called nGenius Performance Manager, which is made by Netscout ( to your research, it will do what you want and more.The graphs and charts it can produce are excellent, and it provides an extremely granular look into the traffic flowing across your network. In the free department, you’ve looked at ntop, and it seems pretty neat, not as granular, but still offering a respectable amount of data and reporting for free.You call up netscout and get some list pricing for the nGenius equipment.The server licenses have a scaled price structure according to the software’s capabilities, so you inquire about the most eco- nomic server license they offer, which is $20,000.00 list.You will need at least a single probe to sniff and collect data, which is another $5,000.00.You will need to run this on a server, and the old one probably won’t work, so there’s another $2,000.00.The yearly maintenance contract will be 10 percent of the purchase price, meaning another $2,500.00, bringing the grand total to $29,500.00, less any price breaks from list you might get. If you then went to your boss and used the $30,000.00 price tag to justify why you should implement a free traffic reporting and analysis tool, your pre- sentation wouldn’t be telling the whole story. First off, none of the free prod- Presenting the Business Case for Free Solutions • Chapter 1 15 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 15 ucts come close to the power and functionality of nGenius, so you are not comparing like products.There are other less expensive alternatives, which would represent a much more accurate comparison to use as a cost savings example. Second, even if money were no object, deploying an enterprise-class solution like nGenius is probably not the best choice.Along with the impres- sive array of features comes a fairly steep learning curve.After implementing such a solution, your in-house staff might have more difficulty learning how to use it than they would with one of the free (and simpler) solutions.Third, you may not need the level of detail and sophistication that nGenius offers. If ntop or a comparable free solution can offer all the reporting and metrics that you are looking for, deploying a more complex solution may not be wise. ntop may be the best choice for your organization, but presenting that choice as a $30,000.00 cost savings is far from accurate. nGenius is the Cadillac of network analysis tools. It has a staggering array of features and an impressive level of customization you can perform without getting into actual programming. If I had the budget and the need, it is the product I would use.That being said, is ntop just as powerful? Not even close. But, in a small organization, the added features nGenius has to offer would likely never be used. With a price tag of free, ntop or one of the many other free alternatives is likely to do everything that is needed, and with a much smaller learning curve. “Selling” a Free Solution If you are in a position where you can implement a new security solution without having to receive anyone else’s approval, you probably don’t need to read this section. If on the other hand, you have to get someone to sign off on your plan, this should be helpful. If you do need approval, you are basically gong to try and “sell” your solution, much like a salesman, highlighting the benefits, and realistically noting any disadvantages to your proposed solution. Remember, the objective of presenting a solution is not to “win” by getting to do things your way.The objective is to provide the decision makers with the most complete and accurate information so that the best decision can be made.Your own judgment of the environment and your target audience will play a large part in what constitutes the best approach for you to take. We 16 Chapter 1 • Presenting the Business Case for Free Solutions 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 16 hope some helpful guidelines as to how to approach gaining approval can help improve your odds of success. Selling by Doing One method of demonstrating the power and effectiveness of a given solution is to actually demonstrate the solution. If the environment allows, and you have the resources, it might be feasible to install the software in question, gen- erate the reports, and present the facts, along with a demonstration of what the software can do.You don’t want to do anything that is inappropriate; if the change control procedures don’t allow such spontaneity, you will need to revise your approach.Assuming you have the freedom to do so, saying the software generates graphs and reports and traffic usage, broken up by protocol and the computer in question, rarely has the same impact as seeing that same graph. Not only does it provide factual real evidence of the utilities value, it also demonstrates your initiative and forethought. WARNING Let’s be perfectly clear here; we’re not advocating that you go and implement some solution without proper management approval when policy says you shouldn’t. You need to evaluate your environment and factor in things such as climate, policy, risks, and benefits to determine if it’s wise to implement something without getting all the proper approvals ahead of time. Again, in some environments this would be perfectly okay, and your manager would be elated at your ingenuity and initiative, while in others you could end up looking for a new job. As always, exercise good judgment and when in doubt take the conserva- tive approach. Presenting a Proposal If you do not have the luxury of implementing something and then asking for “approval,” you will need to create a proposal with all of the relevant information.You can certainly do both, including the sample data from the utility in the proposal.The truth is,“presenting a proposal” sounds very Presenting the Business Case for Free Solutions • Chapter 1 17 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 17 formal, and it can be, but it doesn’t have to be. Some organizations have much more formal procedures in place than others. Presenting your proposal may be as structured as using a standardized template with forms to fill out and submit, and meetings with PowerPoint presentations. It could also just as easily mean talking with your manager over lunch and telling him what you would like to do. Regardless of the format you employ for your proposal, there are certain common elements you will want to touch upon, verbally or on paper. If you address all these issues as accurately as possible, the odds of your venture being a success should be greatly improved.At a minimum, try and have informa- tion and answers covering the following areas concerning your proposed solution: ■ Costs, Training, and Implementation What will it take? How much will it cost? How long will it take to implement? How much training will be required and of what type? How much will the training cost, and how long will it take? What hardware might be needed, and what will it cost? Will it impact the user experience? If so, how? ■ Performance What will it do? What are the real capabilities, not just sales hype? Generating actual samples from your environment, or if you can find something online, would go a long way here. Hard data is always better than a sales blurb. What are the technical limita- tions? ■ Assumptions What other factors must be in place for this to work as planned? Will you need assistance with the implementation? Will an outside consultant be needed? ■ Caveats What are the drawbacks? What makes your solution less attractive? What are potential problems that might arise? 18 Chapter 1 • Presenting the Business Case for Free Solutions 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 18 Summary Not all facets of implementing free security solutions are free.There are always costs of one type or another, which vary in magnitude and relevance based on your individual circumstances. Ultimately, you don’t want to be yet another person who fell victim to the open-source or freeware hype.These are the people who read or heard about a “free” product and rushed to implement it without doing adequate research, thus ending up with a mess that is expensive to make work or to clean up. With the proper research and planning, free solutions can provide you with some very powerful security solutions without spending a lot of resources.The real value lies in finding free software that is the simplest solution available that can still meet your needs. Solutions Fast Track The Costs of Using Free Security Solutions  Training costs can quickly skyrocket, especially for classroom-based training.  Consulting costs are not always something to be avoided.At times they can provide a very efficient way to implement a given solution while at the same time providing some sorely needed training and documentation.  Intangibles can also add up. While items such as HVAC, power costs, and space requirements are not likely to break the bank, these are still considerations you should be aware of in order to make informed decisions. The Savings of Using Free Security Solutions  The biggest savings is that there are no software costs.  No maintenance costs Presenting the Business Case for Free Solutions • Chapter 1 19 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 19 Comparing Free Solutions with Commercial Solutions  You can usually implement a free solution quicker than a commercial product, based on the time it takes to make and receive the purchase.  A free solution’s primary weakness is support. Without a toll-free number to call, you are left to educate yourself or pay someone with the appropriate skills to assist.The often sparse or non-existent documentation can sometimes be a major hindrance to a successful implementation.  Many of the free solutions are also open source, allowing you unequaled flexibility to customize, alter, change, or even rewrite the software in question. “Selling” a Free Solution  Be informed of the pros and cons of the solution, and be honest about your data. Remember that it’s not a contest to implement a particular solution, but rather the objective is to be well informed so that the best solution can be chosen.  Real life examples are always better than theory.A sample graph of data from your current network (policy allowing) is always going to drive home the point better than a bullet that says the product will produce the graph. 20 Chapter 1 • Presenting the Business Case for Free Solutions 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 20 Q: How do I know when I have found the best solution? A: The solution that is “best” today might not be tomorrow.The selection of free software is rapidly changing. While there are certain leaders who will likely continue to be top picks for the foreseeable future, many other free solutions will come and go.The only way to make a good decision is to “do your homework,” and if possible, consult an expert in the area you are interested in. Q: If some of these free tools are so good, why doesn’t everyone use them? A: In the case of a large organization, the features or functionality the free solutions lack are vital, so a commercial solution may be the only option for some. For smaller organizations for which a free solution can satisfy their needs, it typically comes down to not knowing what the options are. No one is paying to advertise free products in computer magazines, so generally only the more experienced and knowledgeable information technology (IT) people know about all the available products. Q: Is free software really free? A: Not in every sense of the word. While the software itself may cost nothing, you have to consider the costs of the hardware required to run the software, the training required to implement the software, and the potential maintenance costs (in terms of man-hours and actual dollars) when considering a free solution.After you add all of this up, some free solutions can be very “cost-effective,” even if not truly free. Presenting the Business Case for Free Solutions • Chapter 1 21 Frequently Asked Questions The following Frequently Asked Questions, answered by the authors of this book, are designed to both measure your understanding of the concepts presented in this chapter and to assist you with real-life implementation of these concepts. To have your questions about this chapter answered by the author, browse to and click on the “Ask the Author” form. 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 21 421_Sec_Free_01.qxd 12/22/06 12:15 PM Page 22 Protecting Your Perimeter Solutions in this chapter: ■ Firewall Types ■ Firewall Architectures ■ Implementing Firewalls ■ Providing Secure Remote Access Chapter 2 23  Summary  Solutions Fast Track  Frequently Asked Questions 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 23 Introduction When it comes to securing networks, the first items that come to mind are firewalls, which are the primary gatekeepers between an organization’s internal network and the outside world. While a properly implemented fire- wall can be one of the most effective security tools in your arsenal, it shouldn’t be the only tool.The adage “defense-in-depth” means that you should have multiple layers of security. Using a defense-in-depth configura- tion, if one component of your defense failed or was defeated, there would still be a variety of other fallbacks to protect your network. With the avail- ability of increasingly affordable firewalls such as the popular Linksys cable/digital subscriber line (DSL) router, using the free firewall alternatives may not be as attractive for some. With a little effort, however, you will find the free alternatives are more configurable, allowing greater flexibility and control than the “home office” grade offerings. This chapter focuses on securing your network perimeter. Remember that although the most common way to implement a firewall is between an internal network and the outside world (often the Internet), you should not limit yourself to placing firewalls only on the network edge.A firewall should be in any place you want to restrict the flow of traffic. With the current trend of security breaches originating from the inside of the network (often employees or ex-employees), companies are increasingly relying on firewalls to isolate and filter traffic between portions of the internal network. This chapter reviews some basic firewall concepts and briefly discusses the different architectural ways to implement a firewall. Most of this chapter dis- cusses the installation and configuration of free firewalls to run on both Windows- and Linux-based systems. Finally, once the network edge has been adequately secured, we discuss how to create controlled, secure paths through the perimeter for remote connectivity, including administrative access or remote office/work from home scenarios. Firewall Types No discussion of firewalls would be complete without a discussion of the dif- ferent types of firewalls.This is particularly true in this context, because it allows you to better understand exactly where in the spectrum the free firewall 24 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 24 offerings lie. In the networking sense, a firewall is basically any component (software or hardware) that restricts the flow of network traffic.This is a suffi- ciently broad definition to allow for all of the various ways people have chosen to implement firewalls. Some firewalls are notoriously limited in capability and others are extremely easy to use. Within the realm of firewalls there are many different ways to restrict net- work traffic. Most of these methods vary in the level of intelligence that is applied to the decision-making process. For example, to permit or deny traffic based on which network device is the sender or recipient, you would use a packet-filtering firewall. In reality, even the simplest packet filtering firewalls can typically make decisions based on the source Internet Protocol (IP) address, the destination IP address, and the source and/or destination port number. While this type of firewall may sound overly simplistic, consider if you have a server running a Web site for use on the Internet. In all likelihood, the only traffic that you need to allow to the server uses a destination port of Transmission Control Protocol (TCP) 80 or 443; thus, you could configure your firewall to permit only that traffic.These ports are used for HTTP and HTTPS, respectively. Because the server is available for the Internet, you can’t filter traffic based on the source address or source port, which will be dif- ferent for each connection. The primary drawback with a simple packet filter is that the packet-filtering firewall has to rely on very primitive means to determine when traffic should be allowed (e.g., synchronous [SYN] or acknowledgement [ACK] bits being set). While this was adequate in the early days of the Internet when security was not as big of a concern, it won’t work any more. It is trivial to set the bits on the packet using freely available software to make the traffic look like it is a reply to another connection.Thus the stateful inspection firewall was born of necessity.This type of firewall monitors all connections (inbound or outbound), and as the connection is permitted (based on the firewall’s configured rules) it enters this connection into a table. When the reply to this connection comes back, even if the reply uses a port that the firewall was not previously config- ured to permit, it can intelligently realize the traffic is a response to a permitted session and permit the traffic. Unfortunately, as the firewalls get better so do the methods hackers use to circumvent them. Suppose you have configured your firewall perfectly and Protecting Your Perimeter • Chapter 2 25 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 25 there are no holes: every permitted port is one you expressly want to allow. Using the previous example, no traffic is allowed to the Web server except Web traffic. Sounds good, but the problem is, if the firewall is completely secure, the server might not be. Flaws in the Web server software could allow the attacker to send the server an HTTP request that is 10,000 characters long, overflowing the buffers and allowing the attacker to execute the code of his choice.The packets used to transport the 10,000-character HTTP request are all legal TCP packets as far as the firewall is concerned: therefore, it would permit them to pass through to the Web server.The next step in firewall evo- lution serves to combat this type of attack.These types of firewalls are applica- tion gateways, or layer 7 firewalls. This type of firewall not only filters network traffic based on the standard network parameters, but they also understand the higher layer protocol infor- mation contained within the packet, in this example HTTP.The firewall itself knows what a legitimate HTTP request looks like and can filter out a mal- formed or malicious request even though, from a network perspective, it might otherwise be a permitted packet.There is a downside to this type of approach, which is that the firewall must be programmed with all the same intelligence needed to filter normal traffic, plus the firewall must fully understand the proto- cols it is inspecting.This means additional programming for any protocol you want the firewall to understand. Most of the major commercial application gateways offer support for the major protocols such as HTTP,File Transfer Protocol (FTP), and Simple Mail Transfer Protocol (SMTP). With all of this information circulating in your head, you’re probably wondering which type is available for free. Generally speaking, you can find many free varieties of firewalls that perform some type of stateful inspection. Application layer gateways are not readily available for free. In reality, few organizations have the funds to use application gateways extensively. One ramification of not using an application gateway is that you need to ensure that the service that is exposed to un-trusted traffic is configured as securely as possible and that the server itself is hardened against attack. Keeping the service patches up-to-date will help reduce the odds that an application-level attack will be successful. 26 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 26 Firewall Architectures The most securely configured firewall in existence will not provide much protection if a network was not designed properly. For example, if the firewall was installed into an environment that allows an alternate network path that bypasses the firewall, the firewall would only be providing a false sense of security.This is an architectural error that would render the firewall useless. In short, where the firewall is implemented is every bit as important as how it is implemented.The first step to installing anything is always planning. What follows is a discussion of the most common firewall architectures, in increasing order of security. Remember, these sections are discussing firewall architectures independent of the firewall type. For example, you could use a packet-filtering firewall, a stateful inspection firewall, or an application gateway in any of the designs discussed in the next section. Screened Subnet A screened subnet is the simplest and most common firewall implementation. Most small businesses and homes use this type of firewall (see Figure 2.1). This design places the firewall on the edge of your network, dividing every- thing (from the firewall’s point of view) into internal and external, with nothing in between. Figure 2.1 Screened Subnet Firewall Protecting Your Perimeter • Chapter 2 27 Trusted Network i.e., Internal Web Server Users Untrusted Network i.e., Public Internet Internet Firewall 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 27 The screened subnet firewall (or edge firewall) is as straightforward as you can get. Internet users who need access to an internal server (e.g., Web, FTP, SMTP,and so on) must traverse the firewall to do so. Internal users needing access to those same servers would be able to access them directly. Internet traffic not destined for any Web-based server would be blocked at the firewall to prevent attacks on internal systems.All internal users must also traverse firewalls to access the Internet.This is the same type of firewall architecture you would have at home with a small network behind a Linksys router.This configuration has several advantages.The primary advantage is simplicity.With only two interfaces, the Access Control Lists (ACLs), which are the filters that define the criteria for permitting or denying traffic, are much simpler. Although this configuration is cost-effective and simple to implement, it is not without its drawbacks. In this arrangement, the hacker has several chances to penetrate your network. If he or she can find a security hole in the firewall, or if the firewall is improperly configured, he or she might be able to gain access to the internal network. Even if the firewall is executed flawlessly, the hacker has a second opportunity to gain access. If the hacker can compromise any available Web-based services and take control of the servers, he or she would then have an internal system from which to launch additional attacks. Finally, if the servers are critical to the business function, by allowing the internal users to access them without going through the firewall, you may loose some audit capability that the firewall might otherwise offer. By far the biggest security weakness in this configuration is that if you are exposing any Web- based services: the servers hosting those services will be attacked frequently, and a compromise of one of those servers may expose your entire network. One-Legged The one-legged demilitarized zone (DMZ) still has the advantage of cost, because you are building a DMZ using only a single firewall (see Figure 2.2). Commonly, the firewall interfaces are called Internal or Inside, External or Outside, and DMZ. 28 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 28 Figure 2.2 One-Legged DMZ With this type of configuration you get to keep the low cost benefit, but add some isolation to your Internet-based servers. Internal users must traverse the firewall to access the servers or the Internet. External users must traverse the firewall to access the Web-based services.The real strength of this type of con- figuration is that if the servers that are hosting the Web-based services are com- promised, the hacker still needs to contend with the firewall to continue attacking the internal network.As an added feature, because all users (internal or external) must traverse the firewall to access the Web-based servers, you may gain a higher degree of auditing from the firewall logs. If you wanted to provide even further isolation, assuming you have the available interfaces on the firewall, you could implement a separate DMZ for each Web-based server you needed. The only real disadvantages to this configuration are complexity, and to a small degree, cost.As you add interfaces to the firewall, the configuration will become more complex. Not only does this complexity add to the time and labor for configuration and maintenance, it also increases the chance that an error could be made in the configuration.As you add interfaces there will often be additional costs associated with them. In most cases this cost will be minor and far less than an additional firewall, but with some high-speed interfaces, they can become very costly. Lastly, though many would consider it minor, with this configuration, if the firewall itself is defeated, the entire network is open to attack. Of course the solution to such paranoid thinking is costly. Protecting Your Perimeter • Chapter 2 29 Trusted Network i.e., Internal Users Untrusted Network i.e., Public Internet Internet Firewall DMZ Web Server 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 29 True DMZ The true DMZ is generally considered the most secure of firewall architec- tures. With this design, there is an external and internal firewall. Between the two is sandwiched any Internet accessible devices (see Figure 2.3). Figure 2.3 True DMZ Internet traffic is only permitted to a server in the DMZ, and only on the port that server is listening on. For example, if you had a Web server in the DMZ and an FTP server in the DMZ, traffic with a destination port of 80 would only be permitted to the Web server. For users accessing the same servers, the same rules would apply. Internal users would have to have permis- sion through both firewalls to access the Internet. Obviously, this type of design costs more, typically double, but that cost buys you increased security. In a true DMZ, if the Web server is compromised the hacker is still trapped between two firewalls. For those who want to go the extra mile, the inside and outside fire- walls can be of different types (e.g., Cisco Private Internet Exchange [PIX] and Linux netfilter). In this way, a hacker that finds a security hole in one firewall is unlikely to be able to apply the same techniques to the other firewall. With all of the basics out of the way, you will be in a better position to make informed decisions when it comes time to propose and implement a firewall solution for your network. Bear in mind, while this chapter covers the basics of firewalls, there are entire volumes (such as Designing and Building Enterprise DMZs by Syngress Publishing, 2006) that explore the topic of fire- wall architectures, DMZ design, and implementation. 30 Chapter 2 • Protecting Your Perimeter Web Server DMZTrusted Network i.e., Internal Users Untrusted Network i.e., Public Internet Internet Firewall Firewall 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 30 Tools & Traps… Accidents Happen I saw a corporate firewall/DMZ with a connection that allowed traffic to completely bypass their Internet firewall. I do not know why this hap- pened, because the organization was not lacking properly trained net- working professionals. These types of errors could occur because someone didn’t analyze the implications of the changes adequately. Perhaps it was a “rush” to install some connectivity, or an emergency repair, or even a “temporary” fix. All of these things would indicate poor change control procedures. It is also possible that someone didn’t realize the complete layout of the network when they made the connection in question, which could indicate inadequate network documentation among other things. In any case, these were trained professionals who should have known better, but accidents happen to the best of us. Implementing Firewalls When it comes to selecting a firewall there are a host of factors to consider. For commercial offerings there is the up front cost in addition to ongoing maintenance costs, which in some cases can be considerable. For free offer- ings, however, one of the first considerations is what OS you want to run the firewall on.This will impact how it is managed, and while the capabilities of the firewalls are likely similar, the implementation details will be very dif- ferent. Most firewalls (commercial and free) run on either Windows or Linux. Some commercial offerings run on their own base system (e.g., Cisco PIX). With some firewalls the underlying Linux system has been so heavily modi- fied it is now considered proprietary. In the case of a Linux firewall, you also have the option of installing the firewall software on a CD-ROM or pen drive.These steps are discussed in more detail in the following sections, along with specific configuration examples for setting up a free firewall on both Linux and Windows. Protecting Your Perimeter • Chapter 2 31 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 31 Hardware versus Software Firewalls Another consideration is whether the firewall decision-making logic is run as software that sits on top of another functional system, or if the firewall is a dedicated piece of hardware. In the case of a Cisco PIX firewall, the smallest models are the size of a small cigar box and there is no OS other than the PIX software.This is a dedicated hardware device used to perform the firewall function, also called a firewall appliance.The other alternative is that the firewall is not a dedicated box, but a software component. Many popular firewalls take this approach as well, such as a checkpoint firewall that can be installed on top of a Windows system. Of these two approaches, if you want a free solution the choice is made for you. I know of no free hardware-based firewalls, so you will be using a software firewall. Configuring netfilter When it comes to Linux-based firewalls, there is only one choice, which is netfilter.This is partially because it was the best option available for the longest time. Since version 2.4, however, netfilter has been built into the Linux kernel. Even many commercial firewalls are running a modified Linux OS with netfilter inside their own custom cases. Netfilter is the underlying software that makes up the built-in firewall on Linux systems.The netfilter component reads the contents of the network packets and decides to permit or deny network traffic. Many times people incorrectly refer to the firewall as iptables, or prior to that, ipchains. In fact, iptables is the software command that is used to configure the rules that netfilter uses to make decisions to permit or deny traffic, and ipchains is the previous version of iptables. Even after you have settled on using Linux as your base OS for your firewall, there are some additional choices to make before you start any configuring. Choosing a Linux Version While all versions of Linux share some common characteristics, there will be differences. Depending on the specific Linux distribution, the differences could be significant and each distribution will likely offer some different sets of software packages.An excellent source of information on the different dis- tributions is site includes a brief summary of 32 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 32 what the distribution is trying to accomplish, and includes links to the home page and download locations. Because there are so many free versions of Linux available, it doesn’t cost anything but the time to download and install several different versions and see which one you like. In the following exam- ples I use a base system of Fedora core 5, which is the free version of the Red Hat Enterprise Linux that many companies use. I chose this distribution because it is one of the oldest and most well-established Linux distributions, and therefore extensive support documentation is available if you need it. If you just want to see if Linux is something you want to work with, try a live CD such as SLAX. When it comes to choosing the specific version of Linux you want to use, this decision must be made in parallel with choosing an installation media, because not all versions are supported on all media. Choosing Installation Media One of the more interesting features that Linux has over Windows is that it can be run from a variety of media. While windows is notoriously difficult to configure to run from a CD-ROM, there are Linux distributions that are capable of running off of a traditional hard disk install, CD-ROM, a Universal Serial Bus (USB) drive, or even a floppy disk. Each media type offers some security pros and cons, and not every distribution will be available on every media type. If you need the features of a specific distribution that doesn’t come on the media you prefer, you may need to make a compromise.You will need to research the different media options and choose one that fits in your environment. We will review some of the pros and cons of each. Full Install The full intall is the traditional install to a system’s hard disk. Much like Windows, you boot up an install CD and walk through a guided install pro- cess. Most of the Linux distributions installed on the hard disk offer graphical user interface (GUI) install programs that walk you through the installation steps.There is no great advantage to using this type of distribution other than that the size of the hard disk allows you to install a lot of extra software. For a firewall, you generally want to keep the software running to a minimum to enhance security, so this shouldn’t be a very big consideration.This type of installation also has the advantage that it will be easy to modify and alter the configuration if needed. Protecting Your Perimeter • Chapter 2 33 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 33 On the down side, this type of installation has all of the same disadvan- tages of a Windows bastion host. Namely that the entire system is sitting on the hard drive and if a hacker manages to compromise the root account, they will be able to install a virus or Trojan on the system that can survive future reboots.This type of install isn’t any better or worse than if you were using Windows for your bastion host OS. Despite these concerns, this is the most common type of Linux firewall installation and most versions of Linux install the firewall components by default.This means if you download a version of Linux you like and install it to a hard disk, you will have a firewall waiting to be configured when you’re done. TIP In the event that you discover your firewall has been compromised, it is considered best practice to wipe the system clean and rebuild it from scratch. Unfortunately, unless you have some means of isolating all changes that were made, you cannot ensure that it is safe to leave the system operational. One of a hacker’s first steps is often to install a back door so that they can easily gain access to the device in the future. These backdoors include techniques such as modifying various systems commands so that detecting the back door is difficult. For this reason, rather than risk leaving a system operational that may be compromised, a complete format and reinstall is recommended. CD-ROM While you can get windows running off of a bootable CD-ROM or live CD, it takes a lot more work than it does with Linux.There are many versions of Linux designed specifically to run from a CD-ROM, allowing you to turn virtually any machine into a firewall, router, or general-purpose PC.There is an obvious security advantage to having all of your configuration information on read-only media. Even if a hacker manages to compromise the system, all it takes is a reboot and it can be restored to its previous condition.The system can still fall victim to a virus or Trojan, but only until it is rebooted. Further, if the firewall system has a hardware failure such as a failed central processing 34 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 34 unit (CPU), all you would need to do to restore your firewall would be to move the CD to a new system and reboot. The primary advantage to a CD-ROM-based installation is also the pri- mary disadvantage. If you burn the entire OS and configuration settings to a CD, any time you need to make adjustments you would need to burn a new CD-ROM.The cost of the CD media probably isn’t an issue, but such a con- figuration may hinder your ability to remotely administer the system, which would be limited to making changes to the running configuration. Changes that remained after a reboot would require someone local to insert the CD- ROM containing the new configuration. If you needed to implement and test changes that required a reboot to take effect, this type of the setup would make things more difficult. Finally, due to simple space limitations on a CD- ROM, you may not be able to fit all of the needed software or functionality on a CD-ROM.That being said, if the firewall rules are relatively static and don’t require frequent adjustment, a live CD could be a very attractive option. USB Drive If the space limitations are acceptable, a Linux-based firewall booting from a USB disk may offer the best compromise in security and flexibility. Having the operating systems and firewall software on a pen drive offers the same type of flexibility that a CD-ROM-based system provides, with increased storage capacity over that of a CD-ROM. If you purchase a USB disk that includes a physical write protect switch, you can make changes on the fly, like a live system, and then write protect the disk against modification when you are done.As the storage capacity of USB drive increases, you will be able to use a USB-based distribution that includes increasingly greater functionality. One key consideration with this type of media is that not all systems will sup- port booting from a USB disk. While almost all newer systems support this option, many of the older systems that you may wish to install a free firewall on do not. Floppy Disk Although the functionality is typically very limited, there are many versions of Linux that can fit on a 3.5” floppy disk.The primary advantage of these distri- butions is their low resource requirements. Often, these systems only require 8 Protecting Your Perimeter • Chapter 2 35 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 35 or 16 megabytes of memory and a 486 processor to function.The ability to toggle the write protect switch on the floppy can also provide a high degree of configuration flexibility and security. Considering the unreliable nature of floppy disks, it probably wouldn’t be appropriate for use if an outage cannot be tolerated.At the very least you should have duplicate floppy disks available in the event of a failure.Another disadvantage to these is functionality. Generally, these floppy-based distributions are single-purpose devices and lack much in the way of functionality.Another consideration is that due to the space restric- tions on a floppy disk, these floppy-based distributions are almost always com- mand line only, with no GUI for configuration or management. Linux Firewall Operation Before discussing the specific commands used to configure the Linux firewall, we will cover some basic Linux firewall vocabulary and how the firewall operates. Netfilter contains the firewall logic, and iptables is the program that is used to modify the rules that the firewall uses. (See the netfilter home page at These rules (or ACLs) define the rules used to permit or deny packets and how to react to denied packets.The current iptables use both tables and chains. Tables are the blocks of processing where various actions are performed on the packets. Different tables process different chains. Chains are a set of rules (or ACLs).There are four built-in tables: nat, mangle, filter, and raw, each of which processes different chains (see Figure 2.4). Figure 2.4 Netfilter Tables and Chains 36 Chapter 2 • Protecting Your Perimeter Nat Table Mangle Table Filter Table Raw Table PREROUTING Chain POSTROUTING Chain OUTPUT Chain INPUT Chain FORWARD Chain OUTPUT Chain PREROUTING Chain OUTPUT Chain PREROUTING Chain POSTROUTING Chain INPUT Chain FORWARD Chain OUTPUT Chain 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 36 The following tables and chains are not listed in any particular order, as a given packet may be impacted by multiple tables and chains as it is processed. The primary built-in chains are INPUT, OUTPUT, and FORWARD. In addition to these, you can create your own user-defined chains. Capitalizing the names of the chains is a common convention, but is not required. A brief summary of the roles the tables and chains play is included for reference. ■ Nat Table This table is referenced with a packet that is used to create a new connection. ■ PREROUTING This chain is processed as soon as a packet is received and before any routing decisions are made. ■ POSTROUTING This chain is processed before a packet is sent to an interface but after any routing decisions have been made. ■ OUTPUT This chain is processed for packets generated locally. ■ Filter Table This is the default table that is used when the iptables command is used to modify the rules, and the command does not specify an alternate table.This is where the bulk of a firewall’s pro- cessing is consumed. ■ INPUT This chain is processed for packets destined for the local system. ■ FORWARD This chain is processed for packets passing through the local system. ■ OUTPUT This chain is processed for packets generated by the local system. ■ Mangle Table This table is used for any specialized packet alter- ations that are needed. Examples are performing Network Address Translation (NAT) or manipulating various bits within the packet. ■ PREROUTING This chain is processed on incoming packets before a routing decision is made. ■ POSTROUTING This chain is processed last before a packet is sent to an interface. Protecting Your Perimeter • Chapter 2 37 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 37 ■ OUTPUT This chain is processed before a routing decision is made for packets generated locally. ■ INPUT This chain is processed for packets destined for the local system. ■ FORWARD This chain is processed for packets passing through the local system. ■ Raw Table This table is primarily used for packets that are exempt from connection tracking, and if required, are called before any other netfilter table. ■ PREROUTING This chain is processed as soon as a packet is received. ■ OUTPUT This chain is processed for packets generated locally. After you have reviewed all the various tables and chains, it’s worth dis- cussing the overall packet flow.The key to remember is that not all packets traverse all chains.To further muddy the waters, packets will traverse different chains depending on whether they are sourced from the netfilter host, des- tined for the netfilter host, or just passing through the netfilter host. Remembering this will save you time when troubleshooting your firewall rules in the future. Refer to Figure 2.5 for a diagram depicting the packet flow through netfilter. Targets are the actions that should be taken when a packet matches a given rule.A target is specified using the –j syntax (for jump).The primary targets used for a firewall are ACCEPT and DROP. ■ ACCEPT The packet is accepted and processed by the rest of the TCP/IP stack. ■ DROP The packet is dropped, and no notice is given to the sender. While this does not honor the TCP/IP protocol specifications, it is considered the most secure option, because it denies a hacker useful information about the firewall.This behavior also has a negative side effect, which is if a system is trying to initiate a connection to a port that is blocked by a firewall, the connection attempt must time out before the initiating host gives up. If you use REJECT, the Internet 38 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 38 Control Message Protocol (ICMP) port will allow the initiating system to abort the connection attempt immediately. ■ LOG This allows you to perform kernel logging, which appears in the syslog log. Further options allow you to specify the log level and a descriptive prefix for the log entry. ■ RETURN Processing continues in the previous chain at the rule just after the last rule processed in that chain. ■ QUEUE This is a special target that will hold (or queue) a packet for processing by a userspace process. Figure 2.5 Netfilter Packet Flow Protecting Your Perimeter • Chapter 2 39 Nat PREROUTING Chain Nat POSTROUTING Chain Nat OUTPUT Chain Filter INPUT Chain Filter FORWARD Chain filter OUTPUT chain Raw PREROUTING Chain Raw OUTPUT Chain Mangle PREROUTING Chain Mangle POSTROUTING Chain Mangle INPUT Chainmangle FORWARD chain Mangle OUTPUT Chain Routing Decision Local Process Routing Decision Forwarded Packet Packet to Local Host Packet from Local Host 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 39 Unlike some firewalls, netfilter allows you to apply multiple rulesets (chains) to the same interface.Although it may seem minor, this option cre- ates a lot of powerful possibilities. For example, suppose you have an ACL and you want to permit all packets originating on the network except those from, which is a host that a third-party uses and is not a completely trusted system.You want packets sourced from with a destination port of 22, 25, 53, 80, and 443 to be permitted, while all other packets are blocked (see Figure 2.6). Figure 2.6 Cisco ACL In Figure 2.5, each line of the ACL is numbered for easy reference.The order of the rules is critical for proper operation of the firewall. Cisco pro- cesses each line in the ACL and compares the rule with the packet in ques- tion. If it finds a match, it performs the indicated action and then stops any further processing of the ACL.This means if you reversed the order of rules 7 and 8, all packets from would be permitted.This type of arrangement also means that a packet with a source IP address of has to be compared against rules 2–7 before being accepted by rule # 8. With seven rules this will happen quickly, but if the ACL is lengthy this extra overhead could be CPU-intensive. Netfilter’s ability to move through multiple chains for the same packet allows you to design your chains for greater efficiency (see Figure 2.7). 40 Chapter 2 • Protecting Your Perimeter 1 somerule 2 access-list 100 permit tcp host any eq 22 3 access-list 100 permit tcp host any eq 25 4 access-list 100 permit tcp host any eq 53 5 access-list 100 permit tcp host any eq 80 6 access-list 100 permit tcp host any eq 443 7 access-list 100 deny ip host any any 8 access-list 100 permit ip any 9 somerule 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 40 Figure 2.7 Netfilter Chains Using netfilter and iptables, you created rule # 2, which says that the source address is for processing the CUSTOM chain.You can create the CUSTOM chain with the iptables –N CUSTOM command. Within the CUSTOM chain, you check for the five permitted destination ports (rules 2.1–2.5) and then reject everything else (rule 2.6). Rule # 2.7 has no matching criteria and will therefore match on any packet and instruct the packet to return to the FORWARD chain where processing can continue. FORWARD chain rule # 3 permits all other packets from the network.This means that packets not sourced from only have to be checked against rule # 2 and can then move through the chain(s) instead of being checked against all the rules.The actual rules as they would appear in iptables can be seen with the iptables –L command. # iptables -L Chain INPUT (policy DROP) target prot opt source destination Chain FORWARD (policy DROP) target prot opt source destination CUSTOM tcp -- anywhere ACCEPT tcp -- anywhere Chain OUTPUT (policy DROP) target prot opt source destination Protecting Your Perimeter • Chapter 2 41 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 41 Chain CUSTOM (1 references) target prot opt source destination ACCEPT tcp -- anywhere tcp dpt:ssh ACCEPT tcp -- anywhere tcp dpt:smtp ACCEPT tcp -- anywhere tcp dpt:domain ACCEPT tcp -- anywhere tcp dpt:http ACCEPT tcp -- anywhere tcp dpt:https DROP all -- anywhere RETURN all -- anywhere anywhere Another advantage is that because rule # 2 sent you to another chain, you can make certain assumptions that you wouldn’t otherwise be able to. For example, in the CUSTOM chain you could replace iptables -A CUSTOM -p tcp -s --dport 22 -j ACCEPT with iptables -A CUSTOM --dport 22 -j ACCEPT. This is because the packet would not be in the CUSTOM chain without matching the –p tcp and –s (source IP address). If you want to tweak the CUSTOM chain even more, the RETURN target in rule # 2.7 isn’t strictly required. If the packet reaches the end of a user-defined chain without having a match, it will RETURN to the previous chain by default. If a packet reaches the end of a built-in chain without a match, it will use the policy target (typically DROP). Now that you have a feel for the flexibility and power of iptables and netfilter, let’s look at some practical configuration examples. Configuration Examples The next step is to demonstrate how to configure the netfilter firewall.This is a critical step, and the firewall should only be installed and configured after the underlying OS has been installed, updated, and hardened.These instruc- tions assume you are working with an otherwise secure system and now need to configure the firewall functionality. 42 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 42 To make sure the firewall is enabled, you can run chkconfig --list, which lists all of the services and the run levels they are configured to start in. For example, you get the following output: chkconfig –-list | grep iptables iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off This output tells you that iptables will start in run levels 2–5.You can set it to run in run levels 2–5 by using the chkconfig –level 2345 iptables on command. If you are using a GUI window manager, you probably have another graphical application to see this information. For example, in Fedora Core 5, you can navigate to System | Administration | Security Level and Firewall, which opens the screen shown in Figure 2.8. Figure 2.8 Fedora Core Firewall GUI You can enable or disable the firewall by going to the Firewall Options tab and selecting Enabled or Disabled.This particular interface in Fedora Core 5 also allows you to perform limited configurations of the firewall rules (e.g., by checking the Trusted Service SSH, a rule would be added to allow inbound connections on TCP port 22). Because any graphical interface pro- vided will likely vary from one distribution to another, we use the command line to configure the firewall. Protecting Your Perimeter • Chapter 2 43 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 43 Deleting Rules and Chains With many Linux distributions, the netfilter firewall will come enabled, but with an empty ruleset. In others, it might come with the firewall enabled and a very liberal ruleset in place. Let’s start configuring a Linux firewall by deleting any default rules that are present.You can use iptables –L (or --list) to list the current rules.An empty default ruleset should look like this: iptables –L Chain INPUT (policy ACCEPT) Target prot opt source destination Chain FORWARD (policy ACCEPT) Target prot opt source destination Chain OUTPUT (policy ACCEPT) Target prot opt source destination If there are any default rules present, they can be deleted using the iptables –F command.The –F option means to flush, which is equivalent to using -- flush.This will clear all rules out of any existing chains. If distribution has any additional chains created beyond the default, you can delete a custom chain by using the iptables –X customchain command. Creating your own user- defined chain is accomplished using the iptables –N customchain command. In addition to the individual rules within a chain, the built-in chains have a default policy associated with them.This policy tells netfilter what to do if a packet reaches the end of the chain without finding a match. While the default policy is to ACCEPT, it is better to change this to DROP by using the –P option, which sets the default policy for that chain, as follows: iptables –P INPUT DROP iptables –P FORWARD DROP iptables –P OUTPUT DROP Permitting Traffic to and from the Firewall Now that you have a clean slate and a default policy of DROP,the first thing you will want to do is make sure that management traffic is permitted to the firewall itself.This is done first, because once you have enabled the firewall 44 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 44 with a default policy of DROP,you will not be able to manage the firewall remotely until you have configured the firewall rules to permit the manage- ment traffic.This traffic is processed against the INPUT chain, because the destination is the netfilter host itself.To allow secure shell (SSH) connections to the firewall, use the following command: iptables –A INPUT –p tcp –s -–dport 22 –j ACCEPT In this example, you are appending (-A) a rule to the INPUT chain to allow traffic from the network to a destination port of TCP 22. With no other configurations, all other traffic through or to the firewall would be dropped.This will show up in the rule listing as follows: iptables –L INPUT Chain INPUT (policy DROP) Target prot opt source destination ACCEPT tcp -- anywhere tcp dpt:ssh Although the aforementioned rules will permit the inbound SSH session, there is currently no rule to permit the reply traffic for the SSH session. If you were to change the default policy for the OUTPUT chain to ACCEPT, this would permit the reply packet, but we will instead address this more securely in the next few examples. If you also wanted to allow access to the firewall with a destination of TCP port 80, you could use the same syntax with –A to append the rule, which would put the new rule for port 80 after the rule for port 22.You could also use –I for insert, as in the iptables –I INPUT 1 –p tcp –s --dport 80 –j ACCEPT command.This would insert the new rule in the INPUT chain as rule # 1, meaning the rule for port 80 would come before the rule for port 22. Remember, this is still permitting only half of the conversation; you still need to permit the outbound reply packets. It is sometimes useful to list the chains with rule numbers using the iptables –L --line-numbers command. For outbound traffic (i.e., traffic generated by the firewall), you need to create rules in the OUTPUT chain.To enable syslog traffic from the firewall to a remote syslog server (, you would enter the following: iptables –A OUTPUT –p udp –d --dport 514 Protecting Your Perimeter • Chapter 2 45 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 45 This assumes you are using the default UDP syslog port of 514. Because syslog over UDP is a one-way conversation, you will not need to permit any inbound replies to the syslog traffic.The OUTPUT chain is where you need to permit replies for permitted traffic that you allowed inbound in the pre- ceding examples.You could create rules to permit SSH and HTTP specifi- cally, but there is also a way to permit all traffic that is a reply to a permitted session.You can enter iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT This will instruct netfilter to permit any outbound traffic that is part of an established session (ESTABLISHED).The RELATED keywork is similar, but it is for traffic that is part of a different session, but where the session is related to an established session. Some protocols will open additional ports (such as FTP) as part of their normal behavior. For those that netfilter understands, it can see the request for the additional port and permit that new session. TIP iptables commands that manipulate the chains or rules themselves use uppercase letters: –A append, –D delete rule, –I insert, –R replace, –L list, –F flush, –N new, –X delete chain Lowercase options are used for specifying rule parameters: –s source address, –p protocol, –d destination address, –j jump, –i in-interface, –o out-interface Simulating the Windows Firewall Now let’s configure the firewall.The built-in firewall on Windows XP is enabled by default with service pack 2 or better.The standard configuration is to allow outbound connections from the host system, and deny inbound con- nections unless they are explicitly configured.The Windows firewall also allows any traffic that is a reply to traffic that the host originally generated outbound.After you execute the iptables –F command to flush out all of the previously configured rules, the following commands would configure the Linux host similarly: 46 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 46 iptables –P OUTPUT ACCEPT iptables –P INPUT DROP iptables –P FORWARD DROP iptables –A INPUT –m state -–state ESTABLISHED,RELATED –j ACCEPT The --state extensions track the current status of the connections. By spec- ifying ESTABLISHED or RELATED, the firewall allows packets that are part of a currently established session, or packets that are starting a new session, but where the session is related to an existing session (such as an FTP data ses- sion). If you were hosting a service on this system, such as a Web server, you would need to configure the INPUT chain appropriately.This configuration would afford any Linux system a minimum level of firewall security with vir- tually no impact to its overall functionality. Simulating a Home Network Router With the basics of iptables configuration out of the way, let’s tackle a more practical example. For a typical firewall, there is very little traffic destined to or from the firewall itself. In general, the only traffic that would fit this profile would be administrative sessions to configure the firewall itself.The vast majority of a firewall’s traffic is passing through the firewall, and will thus be checked against the FORWARD chain.The following examples would con- figure the Linux firewall with the same access controls as a typical home net- work router such as a Linksys or Netgear router/firewall.This example assumes that is the internal network on interface eth0 and the external interface is eth1. iptables –P OUTPUT ACCEPT iptables –P INPUT DROP iptables –P FORWARD DROP iptables –A INPUT –p tcp –s –i eth0 -–dport 80 –j ACCEPT iptables –A FORWARD –s –i eth0 –o eth1 –j ACCEPT iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT Protecting Your Perimeter • Chapter 2 47 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 47 NOTE Always remember that if you have configured the default policy for a chain to DROP (for example, iptables -P FORWARD DROP) that you will need to include an explicit rule to permit the return traffic. This can be done by using the following command: iptables -A -m state --state ESTABLISHED,RELATED -j ACCEPT So if you wanted to permit the return traffic for a FORWARD chain, you would enter iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT Many hours of troubleshooting Linux firewalls have been spent by overlooking a rule that permits the return traffic. The INPUT chain allows port 80 to go to the firewall itself from the internal network. Many the home routers have a Web interface for config- uring them, and while your configuration may not need this port open to the firewall, it is included here to help emphasize how the different chains are used. It is important to specify the input interface (using –i) so that the source IP cannot be spoofed by an external attacker. In this way, you ensure that even if a packet was generated with the proper source IP,if it came in on the outside interface (eth1) it would not match the rule and would thus not be permitted.The FORWARD rule allows any outbound traffic from the internal network to the external network.This configuration is simple to implement; however, the IP range is a private IP range and is not routable on the Internet.Thus, this range wouldn’t allow traffic from the internal network to the Internet quite yet.To make this Linux firewall a useful replacement for a home network router, you need to enable NAT, which allows all of the systems on your internal network to appear as a single IP address when communicating on the Internet. Let’s review NAT in its various incarnations. In principle NAT is simple, but in a complex environment, it can get confusing.As always, good docu- mentation can help keep things straight. Basically, NAT means that the NAT device (in this case the Linux netfilter firewall) will change the IP address in a packet and retransmit that packet. Depending on your needs, you can alter the 48 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 48 source IP address (source NAT [SNAT]), the destination IP address (destina- tion NAT [DNAT]), or both (double NAT). For example, take a home router.The objective behind the NAT capability is to allow all of the internal hosts to communicate on the Internet using the single public IP provided by your Internet Service Provider (ISP). (In this case, SNAT is being used.) As each of the hosts on your private network make a connection to an Internet server, the firewall is altering the source address to look like the public IP from your ISP.By doing this, the return traffic can find its way back to the firewall and be retranslated and sent to the originating host (see Figure 2.9). Figure 2.9 SNAT In Figure 2.9, the internal host has a private IP address of The public address of the firewall is, which is provided by the ISP.If a host on the private network wants to make a connection to using a Web browser, the connection is sent with source address to a destination address of fire- wall alters the source address to its own public IP address of and sends the packet on its way.When the server replies to destination, the fire- wall again edits the packet, this time inserting a new destination of of this takes place and is transparent to the host and the server. When multiple hosts are using SNAT, the firewall tracks which connections belong to which private hosts using the port numbers. While the destination port of the Web server remains static Protecting Your Perimeter • Chapter 2 49 Private Network S= D D S= D D = Public Internet D = 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 49 (typically port 80 for the Web), the source port is usually a random port above 1024. By tracking the source port, the firewall knows which address belongs to which session. In the event that two hosts attempt to use the same source port, the NAT device edits the source port of one of the connections and replaces it with another random source port. When the return traffic is received, it translates the source port back, just like it did for the IP address. Because this method of NAT relies heavily on using the source port number, it is sometimes referred to as port NAT (PNAT). To add the SNAT functionality to the example firewall, use the following command: iptables –t nat –A POSTROUTING –o eth1 –j SNAT -–to-source The –t option is used to specify the table you want to modify, and the –A option specifies that you are going to append this rule to the POSTROUTING chain. By specifying the outbound interface, you are ensuring that the SNAT only occurs as traffic leaves the private network, meaning only in the proper direction. NOTE SNAT can only be performed in the nat table. However, the rules for SNAT can only go in the POSTROUTING chain of the nat table. This means that any time you use SNAT, your rule will contain –t nat –A POSTROUTING. The jump target SNAT is self explanatory.The --to-source option specifies what IP address we want to use as the new source address. SNAT assumes we have a static IP address to SNAT the outgoing packets to. While this is likely the case in a corporate environment, a more appropriate solution to more closely mimic the configuration of a home router would be to use the MAS- QUERADE command: iptables –t nat –A POSTROUTING –o eth1 –j MASQUERADE The masquerade command does not require an IP specification, and will use the IP address of the firewall interface.You might be wondering why you 50 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 50 wouldn’t use the masquerade target all of the time instead of the SNAT target. Because the source IP is static, the SNAT target will cause the NAT calculations to be performed once for a given session. Subsequent packets belonging to that session are handled the same way as the first. With the mas- querade target, each packet is checked for the source IP to use, which requires more overhead than with SNAT.This is why SNAT is preferable if you have a static source IP address, and masquerade is your only option if you do not have a static source IP address to use. Additional Commands By this point, you should have a relatively solid grasp of how to configure a Linux firewall. So far we have covered all of the core commands to permit and deny the traffic.Another useful command for your Linux firewall deals with logging packets. If you want to log everything passing through the fire- wall, use the iptables –A FORWARD –j LOG command. While simple, this would likely generate an excessive amount of logging traffic.You also might want some additional control of how the logging occurs.There are some additional options to provide this functionality. Of particular note are the --log-level and --log-prefix options. The --log-level option allows you to specify what logging level is used for the LOG rule.The effect this log level has depends on how you have your kernel logging configured (via syslog or syslog-ng). When you combine the custom logging level of iptables with the syslog configuration, you can have syslog act in any manner of ways based on the firewall logs, including sending e-mails for certain events.The --log-prefix option allows you to insert up to a 29-letter string in front of the log entry.This can be useful for trou- bleshooting purposes. Some examples of information you could place in log prefix would be the name of the chain that generated the log entry such as iptables –A FORWARD –j LOG --log-prefix “from FORWARD chain.”(For more information on event logging, refer to Chapter 7,“Network Reporting and Troubleshooting.”) Protecting Your Perimeter • Chapter 2 51 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 51 NOTE While a packet that matches an ACCEPT or DROP rule will stop traversing any other chains, this is not true of packets that match a log rule. After matching the log rule, the packets continue through any appropriate chains to be processed. Keep this in mind, so that you can configure an additional rule and action for the packet if desired. Now that you can create a working ruleset for netfilter, you will want to save it.There are two commands of note: one for saving the configurations and one for loading a saved configuration.You can use the iptables-save com- mand to generate output that is the current active ruleset. By default, it will generate the output only to the stdout, meaning it will display in the console. To save this output, redirect it to a file.To redirect the current ruleset to a file called /etc/ruleset, you would type iptables-save > /etc/ruleset. If you want to save the current packet counts and rule counts, use the iptables-save –c > /etc/ruleset command. Individual tables can be saved separately by specifying the –t option using the iptables-save –t mangle > /etc/ruleset command. Restoring a ruleset is accomplished using the iptables-restore command. Like iptables-save, the restore function takes only two optional arguments.The –c option will cause iptables to load the saved packet and byte counts, over- writing the current count values.The default behavior when using iptables- restore is to flush the ruleset before loading the saved ruleset, thus all previous rules are lost. If you wish to override this behavior, you can use the –n option, in which case the rules will be added to the existing ruleset, and will only overwrite if there is a duplicate rule.You can use the iptables-restore < /etc/ruleset command to pipe the saved configuration to iptables-restore. Command Summary The following is a brief summary of the most useful iptables commands for easy reference, along with some examples to make the command usage more clear. Bear in mind this is not an exhaustive list of commands; it only repre- sents the most important commands for configuring your firewall. For a com- plete list, refer to the iptables man page. 52 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 52 ■ –A appends a rule to a chain. iptables –A INPUT –p icmp –j ACCEPT will add the rule to permit ICMP at the bottom of the INPUT chain in the FILTER table. ■ –D deletes a rule from a chain. iptables –D INPUT –p icmp –j ACCEPT will delete the matching rule from the INPUT chain. ipta- bles –D INPUT 3 will delete the third rule from the top in the INPUT chain. ■ –I inserts a rule in a chain. iptables –I INPUT 5 –p icmp –j ACCEPT will insert this rule as the fifth rule in the INPUT chain ■ –R replaces a rule in a chain. iptables –R INPUT 4 –p icmp –j ACCEPT will replace the fourth rule in the INPUT chain with this new rule. ■ –L lists the rules. iptables –L will list all rules and iptables –L INPUT will list all rules in the INPUT chain only. iptables –t nat –L will list all the rules in the nat table only. ■ –F will flush (delete) the rules. iptables –F will delete all rules in all chains. It will not delete chains, only the rules inside the chains. ■ –Z will zero the packet and byte counters. iptables –Z will delete all of the counters. iptables –Z FORWARD will delete all of the counters in the FORWARD chain only. ■ –N will create a new chain. iptables –N CUSTOMCHAIN1 will create a new chain named CUSTOMCHAIN1. ■ –X will delete a chain. iptables –X CUSTOMCHAIN1 will delete the custom chain named CUSTOMCHAIN1. ■ –P will change the policy for a chain. iptables –P INPUT ACCEPT will change the policy for the INPUT chain to ACCEPT. The policy for a chain does not need to be limited to ACCEPT or DROP; it could use a custom chain for a target, if desired. Protecting Your Perimeter • Chapter 2 53 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 53 Option Summary ■ –p specifies the protocol to match (works with “!”). iptables –A FOR- WARD –p tcp will add a rule to match any TCP packet to the FOR- WARD chain. iptables –A FORWARD –p ! tcp will match any packet that was not TCP. ■ –s specifies the source address to match (works with !). iptables –A FORWARD –s will match any packet with a source address of iptables –A FORWARD –s ! will match any packet that did not have a source address of ■ –d specifies the destination address to match (works with !). iptables –A FORWARD –d will match any packet with a desti- nation address of ■ –i specifies the network interface that the traffic was received on (works with !). iptables –A FORWARD –i eth0 will match any packet entering the eth0 interface. ■ –j specifies the target. iptables –A FORWARD –p tcp –j DROP would create a rule at the bottom of the FORWARD chain that will DROP any TCP packet. ■ –o specifies the network interface that the traffic was sent out of (works with “!”). iptables –A FORWARD –o eth1 would match any packet leaving on the eth1 interface. ■ –t specifies the table to manipulate. iptables –t nat –A POSTROUTING –p tcp –j DROP will add a rule to the bottom of the POSTROUTING chain in the NAT table, to DROP any TCP packet. If you don’t specify the –t option, iptables assumes you are working with the filter table. ■ –v specifies to be verbose. iptables –L –v lists all of the rules and includes packet counts per chain and per rule. ■ --line-numbers specifies that the rule list should be numbered: 54 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 54 iptables –L --line-numbers This option makes it easier to know what number to use for the com- mands that take a rule number as an argument, such as insert, delete, replace, and so on. ■ -m will match packets based on certain protocol-specific criteria. Because the match options are protocol specific, -p (tcp/udp/icmp) must be used with –m. Some common examples include: ■ -m --sport allows you to match packets based on the TCP or User Datagram Protocol (UDP) source port. ■ -m --dport allows you to match packets based on the TCP or UDP destination port. ■ -m multiport allows you to match packets based on multiple port numbers within the same rule. iptables –A FORWARD –p tcp -m multiport --dport 22,25,53 –j DROP would DROP any TCP packet with a destination port of 22, 25, or 53. ■ -m state --state will allow you to match packets based on the state of the connection. iptables –A FORWARD –p tcp –m state --state NEW –j LOG would LOG any TCP packets that were being used to initiate a new connection. There are four recognized states: NEW, ESTABLISHED, RELATED, and INVALID. Netfilter and iptables give you powerful packet-filtering and manipulation capabilities for free. With Linux distributions available for free download, a firewall is within any company’s reach. Because of this, deploying firewalls internally to protect highly sensitive systems or data is becoming increasingly viable. If you want to obtain a Linux firewall without having to install Linux, try any of the many live CDs that are available. Some excellent choices are be Knoppix or Slax. GUIs While the console commands that are used to manipulate and configure net- filter are not terribly complicated, they can sometimes get very lengthy.As the Protecting Your Perimeter • Chapter 2 55 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 55 length of the command line grows, the chances of an accidental error increase.Alternatively, you may not like working on the command line, in which case there are a wide variety of GUI and menu-driven interfaces avail- able for netfilter. In most cases, these menu-drive interfaces use your input to create the appropriate iptables commands, and alleviate you having to know the various switches and options to use.There are a large number of GUIs available to configure your netfilter firewall.These GUIs are listed in the fol- lowing section in approximate order of ease of use.All else being equal, we have demonstrated the GUIs that are available on a wide variety of platforms over an equal quality choice that only works with one distribution. In gen- eral, simpler also means less full featured, so be aware that if you are trying to create a complex ruleset, some GUIs may not have the needed functionality. Security Level Configuration You can start the iptables GUI provided with Red Hat-based Linux distribu- tions by navigating to System | Administration | Security Level and Firewall.You can also call the program directly by running system-config-secu- ritylevel from a terminal window.While the interface looks nice, it is limited in what it can configure. Basically, all you can do with this GUI is permit or deny certain ports. Fedora Core 5 configures the INPUT and FORWARD chains to jump to a custom chain named RH-Firewall-1-INPUT.There is no ability to differentiate between ports permitted in the INPUT chain or the FORWARD chain, because all rules configured through the GUI are applied to this custom chain. Some services are predefined for you. Placing a check next to SSH and clicking OK and then Yes to commit the changes will create the following rule in the RH-Firewall-1-INPUT chain: iptables –A RH-Firewall-1-INPUT –p tcp –m state --state NEW –m tcp --dport 22 –j ACCEPT By expanding Other ports on the Firewall Options tab, you can enter a custom port number (see Figure 2.10.) 56 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 56 Figure 2.10 Custom Ports Click Add, and enter the desired port number in the dialog box. Use the drop-down menu to select TCP or UDP for the protocol and click OK (see Figure 2.11). Figure 2.11 Custom Port Dialog This creates a rule identical to the SSH rule.There are no other configura- tion options. While this interface is adequate for a home PC that isn’t running any services, it probably will not be adequate for a corporate firewall. If you need to configure access based on the interface in use or need to configure any NAT rules, you will need to use a different GUI. While you probably won’t need this particular GUI as a corporate firewall, it is still useful to be familiar with it if you are running any Linux systems as workstations. Protecting Your Perimeter • Chapter 2 57 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 57 Lokkit Lokkit is an ncurses-based menu for configuring your netfilter firewall. Lokkit is available for most major distributions and can be installed by default on some (such as Fedora Core 5).To start Lokkit, type lokkit in a terminal window.The first lokkit screen is shown in Figure 2.12. Figure 2.12 Lokkit Main Screen You can navigate the menus using the Tab key and the space bar to toggle the equivalent of radio buttons, such as the Enable and Disabled options shown here. If you select Enabled on this screen, the default ruleset is applied.To edit any custom settings, press Tab until the Customize button is highlighted and then press Enter.The customization screen is shown in Figure 2.13. Lokkit does provide a little more flexibility than the Security Level Configuration GUI discussed previously; however, it is still limited. By selecting an interface in Trusted Devices, all traffic from that interface will be permitted.This would typically be used to select the inside interface and des- ignate it as trusted.You do have the option of enabling MASQUERADE.The interface you select is the one that will NAT outbound traffic; therefore, you would generally select your external interface. Some predefined services are 58 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 58 available, and you can enter your own service information in the “Other ports” section. Once you are satisfied with your choices, press OK and then Enter.This will take you back to the main screen, where you press OK and then Enter to apply the changes. Figure 2.13 Lokkit Customization Screen If you attempt to configure an interface for MASQUERADE, it must also be marked as trusted, or Lokkit will generate an error. Bear in mind that although MASQUERADE is limited, it has enough flexibility to configure a firewall similar to a typical home firewall/router device.This makes Lokkit a handy little utility to have in your repertoire should you need to configure a simple firewall quickly.The value of this utility is also increased, because it is available for a wide number of Linux distributions. Firestarter Firestarter is a GUI front end for netfilter and iptables that is designed to make it simple for average users to configure their firewalls and protect themselves. Firestarter runs on many Linux distributions, and the installation is supported by many automated package management systems (such as yum, apt-get, and portage). Firestarter is an excellent choice if your needs are relatively simple for Protecting Your Perimeter • Chapter 2 59 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 59 your firewall configuration.To install it manually, downloaded it from www.fs- Once it is installed, the first time you start the GUI interface you will need to perform some initial configuration. Follow these steps to configure firestarter: 1. Start the Firestarter GUI. In Fedora Core 5 this is done by navigating to Applications | System Tools | Firestarter.This will start the Firewall wizard. Click Forward on the Welcome to Firestarter screen. 2. On the next screen, select your Internet-connected (i.e. external) network device from the “Detected device(s):” dropdown box (see Figure 2.14), and place a checkbox in the “IP address is assigned via DHCP” box.This is similar to the way a home router/firewall would be configured. When satisfied, click Forward. Figure 2.14 Firestarter Network Device Setup 3. The next screen is the “Internet connection sharing setup” screen (see Figure 2.15), which is basically where you enable NAT. If you want to NAT all of the outbound packets to the external IP address, place a check in the “enable internet connection sharing” checkbox. When this checkbox is enabled, you can select the local area network device (i.e. the inside interface). If you only have two interfaces, it should be selected by default. When finished, press Forward. 60 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 60 Figure 2.15 Firestarter Internet Connection Sharing Setup 4. On the final screen, leave the “Start firewall now” box checked and click Save.This will install a service to start Firestarter each time the system boots up. Firestarter will also change the default action for the chains to DENY; therefore, you must explicitly configure any ports you want to permit through the firewall. The main Firestarter GUI is shown in Figure 2.16.As you can see, it has a straightforward interface.The Status tab gives you high- level information such as sent and received data counters per inter- face, and a list of active connections. When you click the Stop Firewall button, all of the iptables chains are flushed and the default action is changed to ACCEPT.This can be useful for troubleshooting issues to see if they are related to your firewall configuration. The “Events” tab lists recent blocked connection attempts.The “Policy” tab is where you configure certain rules to permit desired traffic (see Figure 2.17). Protecting Your Perimeter • Chapter 2 61 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 61 Figure 2.16 Firestarter GUI Figure 2.17 Firestarter Inbound Policy 62 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 62 For example, if there was a Web server running on the Linux host, you could use the “Policy” tab to permit inbound connections to TCP port 80. The “Editing” dropdown box allows you to choose between inbound and outbound rules to edit. For the Web server example, we selected “Inbound traffic policy.”The policy group you select when you click Add Rule determines where the policy is placed.The function of the various policy groups is outlined below. ■ Allow Connections From Host This is used to configure a given IP address, hostname, or network. When you enter the IP informa- tion and create a rule in this policy group, all traffic from the config- ured source is permitted. ■ Allow Service The allow service policy group is used to permit individual services.You can configure the source to be anyone including a specific IP,or network, or all local area network (LAN) clients.The LAN clients option permits the service through the fire- wall with a source address that is on the same subnet as the inside network adapter. ■ Forward Service This option is used only when you are NATing. This allows the firewall to forward a specific port or range of ports, so that a service hosted on an internal NAT’ed device can receive inbound connections from the external network. The “Outbound traffic policy” window shows a different set of policy groups (see Figure 2.18).There are also the additional radio buttons to select “Permissive by default,”“blacklist traffic,” or “Restrictive by default, whitelist traffic.” If you select the permissive option (the default), all outbound connec- tions will be allowed and any rules you create will be DENY rules.This is the same default behavior of most home firewalls. If you select the restrictive con- figuration, the default target for the table is DENY, and any rules you create will be PERMIT rules. Protecting Your Perimeter • Chapter 2 63 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 63 Figure 2.18 Firestarter Outbound Policy The function of the different policy groups toggle between “allow” and “deny,” based on whether you select restrictive or permissive mode.The policy groups are outlined here: ■ Allow/Deny Connections To Host This policy group is used to globally permit or deny outbound access to a given host, IP address, or network range.This policy uses the destination to match the rule. You can use this policy group in permissive mode to list certain Web sites you do not want anyone to have access to. ■ Allow/Deny Connection from LAN Host This policy group is used to permit or deny all access from a particular host, IP address, or network range.This policy uses the source to match the rule. ■ Allow/Deny Service This policy group permits or denies traffic based on its destination port and source. When you are using permis- sive mode, this policy group can be used to block all access to the BitTorrent ports.The traffic source can be anyone; the firewall itself, LAN clients, or an arbitrary IP,hostname, or network range. 64 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 64 Configuring the policies will satisfy the bulk of what you need to accom- plish, but there are some additional configuration options available by navi- gating to Edit | Preferences. Selecting Interface | Events allows you to configure some useful options.The “Skip redundant entries” checkbox only makes one event entry for sequential event entries.This helps prevent the event windows from being flooded by repetitive alerts.You also have the option of entering certain hosts or ports as being exempt from triggering the event log.After making your selections, click Accept. Another preferences setting of note is under Firewall | Network Settings.This allows you to enable Internet connection sharing (the same as during the initial wizard), and enable the firewall host as a Dynamic Host Configuration Protocol (DHCP) server.This allows you to configure the Linux host similarly to a home firewall, which generally acts as a DHCP server in addition to performing NAT and acting as a firewall.The ICMP fil- tering window also allows you to filter ICMP packets. By default, the permit and deny rules configured by Firestarter apply to TCP and UDP,but not ICMP.This screen allows you to permit the desired types of ICMP traffic. Generally speaking, it is better not to allow any ICMP from the Internet to your firewall or internal network unless absolutely necessary. One final setting you want to configure is under Firewall | Advanced Options. In the broadcast traffic section, check both options under Broadcast traffic. In general, you should not permit broadcast traffic to go through your firewall, as doing so poses a security risk.You also want to check the option to “Block traffic from reserved addresses on public interfaces,” which is a common filtering tactic. Because the “private” addresses outlined in RFC1918 should not be routed through the Internet, there is never a reason to receive traffic sourced from any of those addresses on your outside inter- face. If you do, it is almost always a hacker attempting to bypass a poorly con- figured firewall. Short of any advanced packet mangling, there isn’t much you can’t accomplish using Firestarter as your configuration tool. If you need to imple- ment a more advanced configuration, use an alternate tool, or generate the configuration using Firestarter and use those chains as a starting point to add your own more advanced options. Protecting Your Perimeter • Chapter 2 65 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 65 Easy Firewall Generator Easy Firewall Generator is not a GUI per se, but it does help simplify your netfilter configuration and avoid the need to be familiar with the iptables syntax. By using the Web page at gen/index.php, you can enter the relevant information and click the Generate Firewall button.As you select options, if additional information is needed click the Generate Firewall button and the page will refresh and provide the additional input fields. When all of the required information has been entered, the page will change to a text page that can be copied and pasted for iptables to read as a saved configuration. On Fedora Core 5 the ipt- ables configuration is stored in /etc/sysconfig/iptables.Although this method requires you to replace the default iptables configuration file used by your distribution, it is fairly painless, and it supports all of the same basic function- ality as Firestarter. Firewall Builder Firewall Builder is the most complete GUI offering for managing netfilter firewalls with features and capabilities comparable to some commercial fire- wall products.As is almost always the case, this functionality and capability come at a price: as far as netfilter GUIs are concerned, Firewall Builder is not the easiest to configure and use. If you want or need its superior management capabilities, however, the extra effort is well worth it. (Download firewall builder from Firewall Builder manages netfilter firewalls as well as ipfilter, OpenBSD PF,and (commercially) Cisco PIX firewalls. Firewall Builder runs on many popular operating systems including Red Hat, Mandrake, SUSE, FreeBSD, Mac OS X, and Windows XP. Firewall Builder operates differently than all of the GUIs covered so far. It uses an object-based approach. Essentially, you must define an object to repre- sent any entity that you want to use in the firewall rules. In most cases this means a source, a destination, and a service (port) at a minimum. Both the configuration and the GUI bear a strong resemblance to that of the Checkpoint Firewall GUI. Once the objects are defined, you can drag and drop them into the rules in order to permit or deny communications between the two. For this example we use a Windows XP host to run Firewall Builder and configure a Linux netfilter firewall. 66 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 66 1. Install Firewall Builder. 2. Start the GUI by navigating to Start | Programs | Firewall Builder 2.1 | FWBuilder, which opens the main Firewall Builder window (see Figure 2.19). It is divided up into an objects tree (the left pane) and the dialog area (the right pane). Figure 2.19 Firewall Builder 3. Initially, the dialog area will be empty. In order to add the first fire- wall (in this case a netfilter firewall) on the same host as you are run- ning Firewall Builder, select Firewalls in the object tree. 4. Right-click and select New Firewall, which will open the New Firewall dialog box (see Figure 2.20). Protecting Your Perimeter • Chapter 2 67 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 67 Figure 2.20 FWBuilder New Firewall Wizard 5. Enter the name for the new firewall (in this case LAB01). 6. For the firewall software, select iptables. 7. Choose Linux 2.4/2.6 for the OS and click Next. 8. The next window allows you to configure the interfaces on the fire- wall.You can do so manually, or if the firewall is running SNMP,you can discover them via SNMP.You select Configure interfaces manually and click Next. 9. The manual interface configuration window is shown in Figure 2.21. Enter the relevant information for each network interface.The name must correspond to the actual interface name (same as if you entered ifconfig on the Linux host), such as eth0.The Label is a human friendly name for easy reference such as OUTSIDE. When you are done entering the information for a given interface click Add. 68 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 68 Figure 2.21 FWBuilder Manual Interface Configuration 10. When you have entered the information for all interfaces (typically an INSIDE and OUTSIDE), click Finish. 11. You must designate one of the interfaces on the firewall as the man- agement interface, typically the INSIDE interface. Do this by navi- gating to the firewall in the object tree.As you select each interface in the object tree, there is a “Management interface” checkbox in the dialog area. Check this box for the interface you want to use.This will be the interface that FWBuilder uses to connect and upload the firewall rules to.The interface properties are shown in Figure 2.22. Now that you have the basic firewall defined, you need to define some- thing for it to talk to. In this case, let’s assume that is your internal network, and you want to allow outbound Web browsing and access to an internal Web server (WEB1). For starters, you need to create an object to represent the internal network. Follow these steps to create the network object. Protecting Your Perimeter • Chapter 2 69 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 69 Figure 2.22 Management Interface 13. Navigate to Objects | Networks in the object tree. 14. Right-click Networks and select New Network. 15. Enter INTERNAL for the name of the network, and use for the Address field. Enter for the Netmask and click Apply. 16. Let’s go ahead and next create an internal Web server at Right-click Objects | Hosts in the objects tree and select New Host. 17. Enter WEB1 for the name of the object. Click the Use preconfig- ured template host objects check box and click Next. 18. Select PC with one interface and click Finish. 19. Expand the object tree to User | Objects | Hosts | WEB1 | eth0 | WEB1. Edit the IP address to be and click Apply. 20. Next, define the appropriate services to allow Web browsing. Right- click Services | TCP and select New Service. 21. Enter HTTP for the name. Leave the source port ranges at zero, but change the destination port range to start and end at 80 and click Apply. 22. Repeat steps 20 and 21 for HTTPS on port 443 for secure Web pages. This can be a lot of trouble; however, the real strength of an object-ori- ented approach is seen when it comes time to configure the rules. With all of 70 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 70 the appropriate objects in place, let’s define the rules to permit the inbound HTTP traffic. 23. In the top panel of the dialog area right-click and select Insert Rule. 24. Allow inbound HTTP to WEB1. Click on WEB1 in the object tree and drag it to the destination cell for rule 0. 25. Now drag the HTTP and HTTPS service from the object pane to the Service cell in rule 0. 26. Right-click the big red dot in the Action column and select Accept.This allows the inbound Web traffic to access WEB1. 27. To allow outbound Internet access, create another rule by right- clicking on rule zero and selecting Add Rule. 28. Drag and drop HTTP and HTTPS from the object tree into the Service column of rule one. 29. Drag the Network object INTERNAL from the object tree to the Source column of the new rule. 30. Right-click on the Action column for rule 1 and change the action to ACCEPT.Your policy should look like the one shown in Figure 2.23. Figure 2.23 Sample FWBuilder Policy 31. Although our rules seem simple at the moment, let’s apply them to see how things work. First, save your work by navigating to File | Save or File | Save As. 32. Next, right-click the LAB01 Firewall and select Compile. Protecting Your Perimeter • Chapter 2 71 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 71 33. When the “Select Firewalls for compilation” window comes up, LAB01 should be checked. When satisfied with your selection, click Next. When the compilation is complete you should see “Success” in the “Progress” column.After verifying that the compilation was suc- cessful, click Finish. Tools & Traps… Don’t Block Yourself Anyone who has spent any time configuring firewalls has learned the hard way to be very careful when configuring the rules. It is always a good idea to create the rules to PERMIT administrative access before any others. This is because as soon as you configure the default policies to DROP, your SSH connection will no longer be permitted unless you have it added to the access list. If you forget to do this, you could find that you no longer have remote access to your firewall after applying the policy. If that hap- pens, you won’t even be able to remotely connect to update the policy and change the ACLs. The next step is to tell FWBuilder where to find the SSH executables, because this is how FWBuilder uploads the configuration to the firewalls.You need to have SSH working on both the firewall and the FWBuilder console (assuming they are on different systems). (Detailed steps on using and config- uring SSH are included in Chapter 2,“Securing Your Perimeter.” 34. Select Edit | Preferences from the menu. 35. Select the SSH tab and click the Browse button. 36. Navigate to the location of your desired SSH utility (e.g., plink.exe) and click Open. Note that if you are using Windows for the FWBuilder host, you cannot select PuTTY.exe; you must use the command-line PuTTY program, plink.exe. 37. After selecting the SSH executable, click OK. 38. Right-click the LAB01 firewall in the object tree and select Install. 72 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 72 39. Select the Firewalls you wish to install to and click Next. 40. Enter the username and password for the SSH connection. 41. All other fields are optional; however, it is recommended that you check “Store a copy of the fwb on the firewall.”When satisfied with your choices, click Ok. After the upload completes, you will get a status of “Success” (see Figure 2.24). Checking your firewall (iptables –L) shows you the new rules that are listed. Figure 2.24 Policy Install Success As you can probably see, once you have completed the up-front work of defining your objects, adding or modifying rules is simple.Additionally, unlike the other free GUI solutions, FWBuilder allows you to centrally and securely administer all of your (supported) firewalls from one location. When you use the aforementioned policy, Figure 2.25 shows a sample of the iptables rules that were generated. Notice that the default chains have rules matching the rule you configured in FWBuilder, with a target of RULE_. These additional chains are used to configure the logging.There is also a rule at the beginning of all chains to ACCEPT traffic related to an established session.This is generally desirable but is still configurable.To remove this automatically generated rule, Protecting Your Perimeter • Chapter 2 73 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 73 select the firewall in the object tree and click on Firewall Settings in the dialog area.There is a checkbox that is selected by default called “Accept ESTABLISHED and RELATED packets before the first rule.”Although the FWBuilder policies you’ve configured can handle any basic rules you might need, there are still a few more bases to cover. If you need to NAT with your Linux firewall, configuring it with FWBuilder is easy. Follow these steps so that your Firewall will NAT all the traffic from the internal network to the DHCP address used on the outside interface.This configuration is also known as source nat because it is the source address that is being changed. Figure 2.25 FWBuilder Generated Chains 1. In the dialog area select the NAT tab. 2. Right-click and select Insert Rule.This will add a NAT rule number zero. 3. Drag your INTERNAL network object from the object tree to the Original Src column in the new NAT policy. 4. Drag the external interface on the firewall from the object tree to the “Translated Source” column in the NAT policy. That’s all there is to it. Save, compile, and install the new policy. Now traffic originating from the internal network will be NAT’ed to the IP on the external interface.Although this source NAT configuration will allow all your internal users to reach the internet, you will need to use destination NAT if Internet users need to reach an internal server. Because the internal server is using a private IP address (which is not routable on the Internet), you need to translate this destination to an IP address that the external users can reach.To configure packets destined for the firewall’s single public IP address to an inside resource using destination NAT, follow these steps. 74 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 74 1. In the dialog select the NAT tab 2. Right click on the rule number zero of the existing NAT rule and select Add Rule Below. 3. Drag the firewall OUTSIDE interface into the Original Destination column of the new rule. 4. Drag the appropriate services (i.e. HTTP for web access) into the Original Service column of the new rule. 5. Drag the internal server into the translated destination column of the new rule. Another nice feature is being able to create a time policy (e.g., if you only want the internal systems to be able to surf the Internet from noon to 1:00 P.M., you can easily make that adjustment. 1. In the object tree, right-click Time, and select New Time Interval. 2. In the “Name” field we’ll call this rule LUNCH. 3. In the two time fields provided, enter a time for the rule to START and a time for the rule to STOP.In this case we will enter 12:00 and 13:00 and leave the date field as zeros.The day of the week can stay at -1, which means all days. When done, click Apply. 4. Drag the LUNCH time interval, form the object tree to the Time column of rule # 1. Now, rule # 1 (which permits outbound Web surfing) will only be active from noon to 1:00 P.M.The ability to configure the rules to be active based on the time of day is a very powerful feature. If the organization is a strictly 8:00 A.M to 5:00 P.M type of place, you could configure the firewall to disable all access during non-business hours.Alternatively, certain non-business- related protocols (e.g., instant messenger, file sharing, and so on) could be enabled after the normal business day ends. While not the easiest GUI to use, FWBuilder is definitely the most full featured, and the only one offering fea- tures you would expect to find in a commercial product. Protecting Your Perimeter • Chapter 2 75 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 75 Other GUIs Although there are too many netfilter GUIs to cover them all extensively, we have tried to cover some of the best ones available. If none of the ones cov- ered strike your fancy, or if you just like to experiment and see what else is out there, you might want to investigate some additional offerings. If you are running KDE look into Guarddog from, which is aimed at novice to intermediate users and offers the ability to define security policies based on logical groupings called network “zones.”The Turtle Firewall Project ( allows you to administer your firewall host via a Web interface. While there is no substitute for a good understanding of the command-line configuration of iptables, for an uncomplicated firewall config- uration many of these GUIs allow you to get your firewall up and running quickly and without having to read the iptables man page. Smoothwall Smoothwall ( is a firewall in its own category. First, let’s clarify some basic nomenclature. is the site for SmoothWall Express. SmoothWall Express is a free open-source firewall solu- tion. is the home of SmoothWall Limited, which produces sev- eral commercial security products, including a version of the SmoothWall firewall. SmoothWall differs from the other solutions covered here in that it is a dedicated firewall device. Other solutions using netfilter and optional GUIs to configure the firewall can be run on a workstation.You can still use the firewall system as a normal workstation, but it’s not recommended. If you want to harden the firewall (as you should), you need to remove unneeded services and software from the system, and update all of the remaining soft- ware. SmoothWall takes a different approach in that all of this is done for you. When you install SmoothWall, it wipes out the filesystem and installs a secured version of Linux on the hard disk, along with the SmoothWall soft- ware.The SmoothWall firewall has no GUI on the system, only command- line access and administration via the Web management interface. SmoothWall is meant to be a firewall and nothing more. With that in mind, there are several advantages to this approach. Foremost, you don’t have to learn how to harden your Linux distribution so that it will be 76 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 76 secure enough to use. Further, unlike installing Linux and then learning iptables syntax, with SmoothWall you don’t need to know Linux.The installation menu walks you through configuring the minimum settings so that you can then use the Web interface to configure the firewall functionality.You don’t need to know anything about Linux to get SmoothWall up and running (though it never hurts).The fact that the SmoothWall firewall is already stripped down and unneeded software and services are removed means that you can get the max- imum performance out of an old computer without having to spend a lot of time trying to tweak a full (normal) Linux distribution. Installing Smoothwall The simplest way to install SmoothWall Express is by downloading the .iso image from It is advisable to read along with the manuals located at documentation pro- vided with SmoothWall Express is exceptional among free products, and all of the installation screens are shown in the PDF installation guide.This installa- tion method is used as we walk though installing SmoothWall Express. 1. After burning this image to a CD-ROM, boot the prospective fire- wall with the CD-ROM in the drive. 2. The boot screen will look typical of many Linux distributions. It will warn you that installing SmoothWall Express will delete all data on the hard drive.To continue with the installation, press ENTER. 3. The installation then shifts into a DOS-like GUI interface. Navigation is accomplished using the TAB, arrow, and ENTER keys. You will be prompted to insert the installation CD and press OK. This is done in case your system cannot boot from a CD-ROM and you used a boot floppy to begin the installation. Either way, ensure that the CD-ROM is (still) in the drive, highlight OK, and press ENTER. 4. You have to select OK twice before the hard disk will be reparti- tioned and all data lost. 5. When prompted, select Probe to allow the installation routine to see what network cards it can detect. Protecting Your Perimeter • Chapter 2 77 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 77 SmoothWall uses a concept of interface colors to denote their trust level, and you will begin seeing them referred to in that fashion during the installa- tion process. For example, your inside interface is assumed to be the trusted traffic and is designated as the GREEN interface. Various dial-up, Integrated Services Digital Network (ISDN), or DMZ interfaces are designated as ORANGE interfaces.You can also have a combination of colors indicating your interface configuration. If you use an additional Ethernet interface as the untrusted (OUTSIDE) interface, in SmoothWall parlance that would be GREEN + RED. After the files are installed successfully, you are given the opportunity to restore your configuration from floppy disks.This is useful if you are upgrading or migrating to new hardware. In this case, we select OK. 1. Select your keyboard layout (in my case “US,” and select OK. 2. Select a hostname for the firewall (e.g., smoothwall) and select OK. 3. The next screen allows you to enter proxy server information in case you need to go through a proxy for the firewall to retrieve Web updates. If you are using a proxy, enter the appropriate information here; if not, select OK. 4. The next couple of screens allow you to enter configuration infor- mation for an ISDN or ADSL connection.The assumption of the installation process is that your INSIDE (trusted) interface will be an Ethernet interface, and the OUTSIDE (untrusted) interface will be either an Ethernet, ISDN, or ADSL. If you are using one of these, enter the appropriate information. If your OUTSIDE interface is a normal Ethernet interface (e.g., from a cable modem), select DIS- ABLE for both the ISDN and Asymmetric Digital Subscriber Line (ADSL) configuration screens. 5. The next screen allows you to review and edit your network config- uration. If you are using an Ethernet interface for both, you need to select GREEN + RED for the network configuration type. Check each menu option here and ensure that both interfaces have been recognized, have a driver installed, and have IP address settings. Commonly, the RED interface uses DHCP and the GREEN uses a static IP address, so that internal hosts can configure the firewall as their default gateway out to the Internet. 78 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 78 6. When you are satisfied with all the settings, select DONE. 7. You will be asked if you want to enable the SmoothWall firewall to serve as a DHCP server.This is the same configuration as most home firewalls, acting as firewall, gateway, and DHCP server. If you do not already have a DHCP server in your network, enable it. Fill in the desired values for the various fields. Most of the settings are not mis- sion critical, but one setting to take note of is the lease duration. If your lease duration is too long, you will slowly lose IP addresses from systems that did not get the chance to release the address prop- erly prior to going offline (such as from a crash or power outage). If the lease time is too long, this IP address attrition can exhaust the DHCP scope and leave no address available for other users.A 24- hour lease is not uncommon, and generally the larger the network the shorter the lease duration you will want. If you are unsure about DHCP,you can leave it disabled.The DHCP settings are easily con- figured later from the Web interface. 8. The next several screens allow you to enter the password for various accounts used by the firewall. Here are summaries of these accounts. ■ Administrator This is used for administering the firewall via the Web interface.This account is only for accessing the Web inter- face and cannot be used to login to the Linux OS on the firewall directly. ■ root This is a local Linux account that is used for command-line access on the firewall itself. ■ setup This is a local Linux account that is used to run the setup program, which automatically starts when you login as setup.The setup program allows you to configure some of the network set- tings if they need to be changed after the initial installation. 9. After you configure the final password, the CD-ROM will eject and the system will reboot. When the system comes back up, you can log in directly via the console using the root account, or the preferred method is to log in to the Web interface.The default Web interface is found at http://smoothwall:81 and the secure HTTP is found at Protecting Your Perimeter • Chapter 2 79 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 79 https://smoothwall:441. Both the root and the setup account can also login via SSH, which is configured by default on port 222. Configuring SmoothWall When you first log in to the SmoothWall Web interface, the screen will look like the one shown in Figure 2.26. Figure 2.26 SmoothWall Web Interface There is some information available before logging in, such as the number of users and average load on the firewall.As soon as you click on a menu item at the top you are prompted to authenticate with the Web admin user. By default, the account name is “admin.” One of the first things you should do is enable SSH access, which is disabled by default.This allows you an additional way to manage the firewall if something goes wrong with the Web server or the firewall filters.You can enable SSH by clicking on the Services tab, and then selecting Remote Access. Next, place a check in the box next to SSH and click Save.You can verify what services are running by clicking the “About your smoothie” tab.There are three screens available under this tab. The status screen shows which services are running.The advanced screen 80 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 80 shows more detailed information regarding memory usage, hard disk usage, network interface settings, and uptime.The traffic graphs screen shows input and output rates for all interfaces. After enabling SSH, you should be able to connect on port 222.An example using openssh would be: ssh -l root –p 222 Now that you have a backup way to get into the firewall, the next pri- ority is to update the firewall.Although you don’t have much of a configura- tion to warrant making a backup before applying the patches, it is still a good habit to get into. By selecting the maintenance tab and then the backup screen, you have a couple of options.The “Create backup floppy disk” button will write the configuration information directly to a floppy disk. Given the relatively unreliable nature of floppy disks, you should choose the “Create backup floppy image file” option.This creates and downloads an .img file to the system you are using for Web administration.You can store this file on a more reliable media, and then write the image to a physical floppy disk at a later date using a utility such as rawwrite. Once you have made a backup, you can safely apply the firewall updates. Firewall updates are another area where the SmoothWall designers have made things as painless as possible. Click on the maintenance tab and you will see two sections on the updates screen.The top section shows installed updates and the bottom one shows available updates.To update the firewall, go to In the “Latest Updates and Patches” section there is a small link called updates archive. Click that link and on the fol- lowing page, download all the available updates to your local system. NOTE All of the updates must be applied sequentially; the SmoothWall updates are not cumulative updates. Apply update 1 first, then update 2, and so on, until you have applied all of the updates currently available for your firewall. At the time of this writing there were seven updates available for download. Protecting Your Perimeter • Chapter 2 81 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 81 The bottom of the Maintenance | Updates page has a box to upload an update. Click Browse and select the first update, and then click upload. The firewall automatically installs the patch as it is uploaded and, when fin- ished, the page will refresh and show the updated listed in the “Installed updates” section. Continue this process until all available updates have been completed.A partial list of the successfully installed updates can be seen in Figure 2.27. Figure 2.27 SmoothWall Installed Updates One final configuration option that should be a part of any firewall setup is providing the firewall with a good way to synchronize its clock.Accurate time is important for many reasons, one of which is to make sure your logs have accurate time stamps. Without accurate time stamps, it will be more dif- ficult, if not impossible, to reconstruct events later if there is an intrusion.You can configure the time source on the “Services” tab using the “time” screen. You should use the drop-down box to select the appropriate time zone. While SmoothWall does not give you the option to configure network time protocol (NTP) security, it does give you the option of using random public servers. In this fashion, even if it pulled time from one that was too far off 82 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 82 (either accidentally or maliciously), the next time it is checked (a different server) would likely correct itself.To enable SmoothWall to retrieve the time from a public time server, check the Enabled: checkbox and then click Save. With all of the basic administrative configuration out of the way, the actual rule configuration is next. SmoothWall relies heavily on the security level of the interfaces for access permissions. By default, all traffic will be blocked that enters on a RED interface and is destined for an address via a GREEN interface, unless it is specifically configured to be permitted. Similarly, traffic is blocked by default from an ORANGE interface to a GREEN interface.Traffic from a more secure interface to a less secure inter- face is permitted by default.This behavior is similar to several other commer- cial firewalls including the Cisco PIX/ASA. What all this means is that for your users to access the Internet, you don’t need to configure anything at all. On the other hand, suppose you wanted to permit inbound access to a Web server (GREEN interface) with an IP address of from any host on the Internet (RED interface).You would configure this by selecting the Networking tab and the Port Forwarding screen (see Figure 2.28). Figure 2.28 SmoothWall Port Forwarding Leave the source IP blank (for ALL) and enter a source port of 80. For the destination IP,enter the internal server’s IP of, and for the desti- nation port, enter 80 for HTTP.When finished, click Add. If you need to Protecting Your Perimeter • Chapter 2 83 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 83 permit HTTPS, you need to repeat the process with 443 as the destination port. By using SSH to connect to the firewall directly (SmoothWall uses port 222 for SSH), you can list the netfilter rules using iptables –L and see where the HTTP and HTTPS rules were added. Chain portfwf (1 references) target prot opt source destination ACCEPT tcp -- anywhere state NEW tcp dpt:http ACCEPT tcp -- anywhere state NEW tcp dpt:https If you have three interfaces in a one-legged DMZ design, the DMZ inter- face is labeled as ORANGE. If you need to permit access from the DMZ into the trusted (GREEN) network, the process is a little different.You would then navigate to the networking | DMZ pinholes screen.The interface is very similar to the port forwarding with the exception that there is no field to specify the source port. At times, an internal system’s permissions may allow it to communicate with a device outside the firewall (on the RED interface); however, you may wish to block the communications completely. If you do this, any access by the blocked site will fail, even attempts to respond to an internal trusted system’s request.You can configure this on the “Networking” tab, using the “ip block” screen. Enter the source IP address or name to block, and click Add to save the rule.You also have the option to enable logging for the blocked attempts. With the basic firewall rules and maintenance configured, there are a few “extras” that are nice to see in a free product. One of these is the built-in Intrusion Detection System (IDS). Because it uses Linux as its base operating system, it conveniently includes Snort IDS; all you have to do is enable it. Enable Snort by selecting the “Services” tab, and then the “Intrusion Detection System” screen. Place a check next to Snort and click Save.The Snort alerts and other logs can be viewed on the “logs” tab.There are several subscreens that include a drop-down box to select what subset of logs you want to see, such as SSH, SmoothWall (which will show your recently applied patches), and several more.The “Web proxy” screen is only useful if you are using the Web proxy feature of the firewall.The “firewall” page shows all blocked connections and allows you to filter by month and day. Lastly, the 84 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 84 IDS screen shows events logged by the Snort IDS. Unfortunately, SmoothWall Express does not support remote logging natively, while the commercial offering does. It does, however, allow you to export the log files to a text file. Another nice option is the dynamic DNS support.There are various dynamic DNS services available that will allow you to use a consistent DNS name to refer to a system whose IP address is dynamic via DHCP.In order to do this, you typically must install a small program on the host system that will periodically contact the dynamic DNS server and alert them to your current IP address.The service then uses this information to update their DNS records so that people can locate the system via DNS.The SmoothWall fire- wall has the capability to perform these updates for you, to the major dynamic DNS providers.You can configure dynamic DNS support by selecting navigating to the services | dynamic dns page. Use the drop- down menu to select the dynamic DNS service you are using, fill in the rest of the information, and click Add.The firewall will then make the updates to the service and all of the hosts to IP mappings can be maintained in one place rather than having to install an agent on all of the systems that need dynamic DNS functionality. SmoothWall Express is a very well-built firewall package.The documenta- tion is very good, and the setup and management are straightforward and understandable.You don’t have to know anything about the underlying oper- ating system. With all of the advanced features such as traffic graphs, intrusion detection, and respectable logging, it deserves a top spot on the list of con- tenders for “best free firewalls.” If you want the efficiency of running your firewall on Linux without having to learn how to secure your Linux installa- tion, give SmoothWall a try. Configuring Windows Firewall Although there is a plethora of commercial firewalls available to run on Windows, the field is a lot smaller when it comes to free offerings. Additionally, while there are several quality offerings for Windows as personal firewalls, there are not any free ones that are appropriate to protect your net- work perimeter.The built in Windows Firewall included with Windows XP and 2003 is very limited in its configuration options and is only appropriate as the personal firewall it was intended to be.The Windows Firewall included Protecting Your Perimeter • Chapter 2 85 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 85 with Windows Vista is supposed to incorporate increased flexibility and con- trol over the filtering rules, so that might be something to keep an eye on when it is released. Given this, configuring the Windows Firewall is covered in Chapter 3, along with content on other personal firewalls. Providing Secure Remote Access Sooner or later odds are good that you will either want or need the ability to work remotely. Providing remote access must be undertaken very cautiously, because, as soon as you allow employees to connect to the corporate network, you have to some degree, extended your network boundary to their worksta- tions.This means your network’s security is now only as good as the security of the remote user’s system or network. In many cases this borders on no security at all.That is why remote access must only be granted after careful consideration and planning. While the different types of remote access pose different levels of security risk, there are some planning and configuration steps that are common to all of them. The first task is to determine what type of remote access is appropriate. With a virtual tunnel network (VPN), it is as if the remote workstation is on the corporate network.This generally provides the greatest level of function- ality, but also poses the greatest risk. If the remote system is compromised, an attacker is effectively inside your corporate network. While there are steps you can take to mitigate these risks, they may be time- and effort-intensive.To plan, configure, and properly secure a VPN solution is the most involved choice of the various remote access solutions you could provide. Another option is to provide remote desktop functionality.This would allow a remote user to see and use the desktop of a system at work.A remote desktop acts as if the user is at work, while a VPN acts as if the user’s com- puter is at work.This type of solution is slightly easier to implement, because you can typically isolate the traffic that needs to be permitted through the firewall to a single TCP port. Many of the same risks exist, however, in that if an attacker manages to gain access to an internal desktop remotely, it is usu- ally easy for them to move information out of the network or otherwise cause mischief. Another key consideration with this type of solution is that you need to have a computer at home and a computer at work. With the 86 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 86 VPN option, you only need to use one system, so if the user has a laptop, it can be used while they work remotely. The last and least functional option is that of a remote shell. Because most average users don’t operate extensively (if at all) in a console (i.e., text only) environment, this type of remote access is generally most viable for network administration personnel. While it may be impossible for accountants to operate their accounting program without a GUI, many network tasks and most firewall administration tasks can be performed with only terminal access. Because the widely used Telnet protocol sends all data unencrypted, any sensi- tive tasks should only be performed using a secured protocol such as secure shell (SSH), or Telnet over a Secure Internet Protocol (IPsec) tunnel. Providing VPN Access A virtual private network (VPN) is exactly what it sounds like, the network connection you create is virtual, because you can use it over an otherwise public network. Basically, you take two endpoints for the VPN tunnel, and all traffic between these two endpoints will be encrypted so that the data being transmitted is private and unreadable to the systems in between. Different VPN solutions use different protocols and encryption algorithms to accom- plish this level of privacy.VPNs tend to be protocol independent, at least to some degree, in that the VPN configuration is not on a per-port basis. Rather, once you have established the VPN tunnel, all applicable traffic will be routed across the tunnel, effectively extending the boundaries of your internal network to include the remote host. One of your first considerations when planning to implement a VPN solution is the network design. Because the VPN tunnel needs two endpoints, one will be the remote workstation.The other will be a specially configured device for that purpose.This is generally called a VPN concentrator, because it acts as a common endpoint for multiple VPN tunnels.The remote systems will effectively be using the concentrator as a gateway into the internal net- work, so the placement of the concentrator is important. In a highly secured environment, the concentrator is placed in a DMZ sandwiched between two firewalls—one firewall facing the Internet and the other facing internally (see Figure 2.29). While this type of arrangement is the most secure, it takes more hardware to implement. Protecting Your Perimeter • Chapter 2 87 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 87 Figure 2.29 VPN Concentrator Design Another way to place the VPN concentrator inside a DMZ is to use an additional interface on the firewall as the DMZ in a “one-legged” configura- tion.This saves you having to implement an additional firewall, but still pro- vides some isolation between the concentrator and the rest of the internal network. If an attacker compromised a remote host who was VPN’d into the concentrator or compromised the concentrator itself, they would still have a firewall between them and the internal network.The least preferable option it to place the concentrator inside the internal network. With this type of design, if the concentrator is compromised, the attacker would have full access to the internal network, with no firewalls to inhibit their activities. With any of these designs, you will have to permit the required ports through the fire- wall and forward them to your VPN concentrator. Another consideration is the type of VPN protocol you want to use. IPsec is still the most widely deployed VPN technology for good reason. One is interoperability.As a widely used and tested standard, IPsec will work with virtually any modern firewall and operating system.The disadvantage of IPsec is that it can sometimes be difficult to configure properly, and there is zero margin for error on the configuration. Both ends have to use the same parameters for encryptions, hashing, and so forth, or the tunnel cannot be established. Secure Sockets Layer (SSL) is an increasingly popular choice for VPNs, largely because of its simplicity to implement. 88 Chapter 2 • Protecting Your Perimeter DMZ VPN Concentrator Corporate Network Public Internet Remote User1 ` VPN Tunnel Internal Resources Remote User2 ` VPN Tunnel 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 88 Once you have chosen a design and VPN technology, you need to con- sider the administrative ramifications of offering remote access. Some level of training will be required, at the very least so that they can sue the VPN soft- ware.You should educate the users on good security habits as well.A determi- nation will also need to be made as to whether remote users are allowed to use their own personal computers, or if they must use a company-provided computer for remote access.The former option carries with it many risks. When remote users connect their personal computers to the corporate net- work (via a VPN), they may have spyware, a virus, or any number of poten- tially damaging conditions present on their systems. Because you probably don’t have any administrative access to their systems, you may have no way to secure the personal systems even if you wanted to.This is why most compa- nies require that only corporate resources be allowed to connect to the com- pany network. In the case of remote users, this typically means a company-provided laptop, but I have also seen instances of older desktops being sent home for remote access. A final consideration is one of hardware selection. Normal desktop pro- ductivity applications typically place very little strain on an even remotely modern processor.The same is not true when it comes to VPN connections. A single VPN connection requires little overhead and rarely impacts the remote user’s system unless it is especially underpowered. For the VPN con- centrator, however, it will handle the encryption and decryption of multiple connections, in addition to managing the volume of network data that will be accessed through it. For this reason, if you anticipate more than just a couple of VPN connections to be used simultaneously, you will want to test and evaluate your hardware needs. Using Windows as a VPN Concentrator For a simple VPN solution servicing a small number of users you can use a Windows 2000, XP,or 2003 system using native software.This has the advan- tage that you are not using any third-party software, so installation and sup- port may be easier. Not only is the configuration reasonably simple, but it may be easier to sell to upper management, because it doesn’t involve any non-Microsoft software being installed or relied on.The Microsoft VPN con- nection uses the point-to-point tunneling protocol (PPTP), which is not Protecting Your Perimeter • Chapter 2 89 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 89 compatible with other types of VPNs such as IPsec-based or SSL-based VPNs. PPTP is a widely supported and relatively lightweight protocol. PPTP support can be found on Linux, MAC OS X, and Palm Personal Digital Assistants (PDAs). To configure a Windows host as a VPN endpoint using Windows 2000, follow these steps. 1. Navigate to Start | Control Panel | Network Connections. 2. Click Create New Connection 3. On the welcome screen, click Next. 4. In the New Connection Type windows, select Set up an advanced connection and click Next. 5. In the Advanced Connections Options window, leave the default Accept incoming connections checked and click Next. 6. On the “Devices for incoming Connections” window, click Next. Any modems you have installed will be listed; however, for a network connection, you can leave them unchecked. 7. On the next screen, select Allow virtual private connections and then click Next. 8. On the “User Permissions” window, place a check next to the user accounts you wish to be able to connect via VPN and then click Next. 9. On the networking software screen, highlight Internet Protocol (TCP/IP) and click Properties (see Figure 2.30). 10. The Incoming TCP/IP Properties window is where you configure the most important settings for the VPN connection.The Allow callers to access my local network must be checked or the VPN connection won’t work. For TCP/IP address assignment, you need to plan accordingly. If you leave the default selected, the remote systems will be assigned an IP address via DHCP as they connect. 90 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 90 Figure 2.30 Network Software 11. When finished configuring the TCP/IP properties, click OK. 12. On the Networking Software window, click Next. 13. Click Finish. After completing these steps the server should be ready to accept an incoming VPN connection.The next step is the client side of the configura- tion. We will walk through this configuration using a Windows XP system, as the client, in order to make a VPN connection to the Windows XP VPN server. 1. Navigate to Start | Control Panel | Network Connections. 2. Click Create New Connection 3. On the welcome screen, click Next. 4. Select Connect to the network at my workplace and click Next. 5. Select Virtual Private Network Connection and click Next. 6. On the Connection Name window, choose a descriptive name for the connection and then click Next. 7. The next window is the VPN Server Selection screen. Enter an IP address or host name and click Next. Protecting Your Perimeter • Chapter 2 91 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 91 8. On the final screen you have the option of adding a shortcut for the connection to your desktop. Select the checkbox if you want to create the shortcut and then click Finish. The shortcut that is created can be opened to initiate the VPN connec- tion.You will be prompted to enter the login credentials to use for the VPN connection (see Figure 2.31). Figure 2.31 Windows XP VPN Login After entering your username and password, click Connect. If the con- nection is successful, you should see a pop-up in the system tray indicating that you are connected. Once connected, you can route traffic through the VPN server. NOTE In order for the connection to work, you must have a password for the account you are using to connect via VPN. If the account has no pass- word, you will not be able to connect. One final thing you may need to configure is the routing table on the client system. When you make the PPTP connection, a default route is added to the clients routing table after their existing default route.You can view the 92 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 92 routing table on Windows using the route print command.The default route has for the network destination.This means that any traffic des- tined for an IP address that the client doesn’t know where to send it, will continue to go out the interface it was using before the PPTP connection was made. If you need to change this behavior so that all non-local traffic goes through the VPN tunnel, you can alter the routing tables with a simple batch file. iPig iPig is a VPN solution provided by iOpus Software at The client is freeware, and the server portion (the VPN concentrator) is offered as an unlimited commercial product or as a five-user iPig Server Express Edition for free.The five-user limit is for simultaneous connections to the VPN server.You can create more than five user accounts to use the VPN, but they cannot all use the server at the same time. Both the commercial and the free versions use AES256 for their encryption and run on Windows 2000, XP,and 2003. If you download the iPig client and do not install the iPig server, you can still use the client. In this configuration the client will connect to an iOpus-controlled server on the Internet.You are limited to 10MB of “free” bandwidth before you must pay for additional bandwidth. Instead, you should install your own server side component, which is the iPig Server Express Edition product. We walk through setting up the iPig server compo- nent first, and then the client software. Installing the iPig Server Express Edition Download and install the iPig server software.There are no unusual options during the installation process. In typical fashion, the install begins with a welcome screen and then asks you to accept the License agreement.The next screens lets you choose the installation directory and start menu folders. When the installation is complete, you will get a window informing you that the server started successfully.You can configure the iPig server options by navigating to Start | All Programs | iPig Server | iPig Server.The main configuration screen is shown in Figure 2.32. Protecting Your Perimeter • Chapter 2 93 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 93 Figure 2.32 iPig Server Configuration The first step is to define the VPN users. 1. Select Users in the left pane and then click Add in the right pane. 2. The Edit user window allows you to enter a username, a password, and a traffic limit if desired (see Figure 2.33).You can artificially throttle back the VPN users to make sure they do not consume too much of your Internet bandwidth and negatively impact Internet access for the local network users. Figure 2.33 iPig Edit User 94 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 94 3. After entering the user information, click OK. Back at the main con- figuration window there are a few additional settings to configure. One option of note is under the “Settings” section in the left pane. If you select “Settings” you can then edit the Server port that is used to listen for incoming connections. Generally speaking, a non-default port is almost always better than using the defaults.You should also change the Log type from None to Small or, even better, Full, depending on how much VPN traffic you expect to see.The server log is located in the \iPig\server\vpn_log.csv file.The logging that is offered even in “Full” mode is pretty minimal, but it’s better than nothing. Installing the iPig VPN Client Installing the client is equally as painless. 1. Download the client installer and run the installation for the client setup. 2. On the initial welcome screen, click Next, select the radio button to accept the license agreement, and then click Next. 3. Choose the installation folder and click Next. 4. Choose the start menu folder and click Next, and then click Install on the next screen.You will need to reboot the system when the installation completes. 5. Start the iPig client program by navigating to Start | All Programs | iPig WLAN Security | iPig Client. Once the client is started, there are a couple of settings you must configure. 1. First, select Advanced Settings in the left pane (see Figure 2.34). 2. Select the radio button next to “Use your own iPig server,” and enter the IP address and server port (11888 is the default port) and click Apply. Click Connect and select User in the left pane (see Figure 2.35). Protecting Your Perimeter • Chapter 2 95 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 95 Figure 2.34 iPig Client Advanced Settings Figure 2.35 iPig Client User Settings 3. Enter the user name and password that matches the ones you defined in the iPig server. 4. When finished, click iPig On. This is all that is needed to have the VPN tunnel up and working. However, there are some additional configuration options that would be advisable to configure. 96 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 96 In the Settings page, make sure you have Log all Internet Access checked.There is also a checkbox to encrypt UDP traffic. If you leave this unchecked, only TCP traffic will be encrypted. Depending on your needs, this may or may not be significant. One thing to consider is that if you encrypt UDP traffic, it will include DNS requests.Therefore, when the client requests an IP address to match a host name (e.g.,, the request is encrypted and sent to the iPig server, which then decrypts the request and sends it to its DNS server. In most cases, this shouldn’t be an issue, but some- times ISP’s and others will configure their DNS servers to only answer queries when they come from their internal network. Another option of note is the ability to configure encryption filters.The Filter settings window is shown in Figure 2.36. Figure 2.36 iPig Client Filter Settings The two options at the top determine if this filter will act as an inclusion list or an exclusion list. If you select Encrypt only the following, only traffic matching the rules will be encrypted and everything else will be sent unen- crypted as if the iPig VPN were not there.Alternatively, you can configure it to encrypt all traffic except those that match the filter rules.The latter option is probably more desirable, because it will allow you to send all data over the VPN except any applications you specify in the filters.The filters allow you to specify the name or IP address to match, as well as port number and pro- tocol (UDP,TCP,or both). Protecting Your Perimeter • Chapter 2 97 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 97 The iPig VPN solution is extremely easy to set up, offering a quick and painless way to provide VPN connectivity to remote users.The limit of five connections to the iPig server is very reasonable and should be able to accommodate a small office. If you decide that the product meets your needs and you want to upgrade to the full, unlimited user version, the registration cost of $99 is very reasonable.Another offering in the “zero configuration” VPN space is LogMeIn Hamachi, available from LogMeIn Hamachi’s structure for the free version limits you to 16 systems in the VPN network and the documentation says that the product’s “mediation” server is used to help clients find each other. It’s not entirely clear if the initial authen- tication passes through Himachi-owned devices or not.As always, do your research. While iPig’s limitations seem easier to work with, Hamachi might be worth investigating to see if it suits your needs. OpenSSL VPN There are many commercial VPN solutions using SSL to provide encryption. SSL is the same encryption protocol that is used for secure Web pages (HTTPS://) and as such it is a very well tested and widely understood pro- tocol.There are not very many offerings for free SSL based VPNs, but OpenVPN is a very robust and active package.You can read about it and download it from OpenVPN can be installed on Linux, Windows (2000 or newer), several versions of BSD, MAX OS X, and Solaris. We will be using Windows 2000 for the server and Windows XP for the client, although the differences between using Windows and Linux should be minimal. OpenVPN uses a single executable to serve as both the client and server components. Download the latest stable version from download.html.You can download a .ZIP file or a Windows installation pro- gram (.EXE).The executable is the easiest to use, so that will be the installation method used in the examples. OpenVPN is natively a command-line program; however, there is a GUI available for download from Follow these steps to get OpenVPN installed and configured. 1. Start the installation program. Click Next on the welcome screen. 2. On the license agreement screen you must click I Agree to continue with the installation. 98 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 98 3. The next screen is the “Choose Components screen.” Leave all com- ponents checked and click Next. 4. On the next screen, select your installation directory and click Install. During the installation you will receive a notice that the TAP driver has not been Windows certified. Click Ye s (Windows 2000) or Continue Anyway to continue with the installation. 5. After the installation completes, click Next and then click Finish. Configuring the OpenVPN Server After installation, the next step is to edit the client configuration file and the server configuration file.You will first configure the server side. Pay strict attention when following the instructions as to whether you are working with the server configuration file or the client configuration file.Also note that your operating system has to be able to find any files it needs, so your configuration files either need to use the complete path for all file references, or you must have the appropriate directory in your system’s search path. Sample configura- tion files can be found in the \OpenVPN\sample-config\ directory. 1. Copy the server.ovpn file to the \OpenVPN\config directory and rename it to something meaningful. For this example, we used \config\LAB_SERVER.ovpn. 2. Open the server configuration file for editing with an American Standard Code for Information Interchange (ASCII) editor, such as Notepad. 3. There is a directive named port that specifies the port the server will listen on for inbound connections.The default port for the server is 1194. If you want to change the port and use something non-stan- dard, edit the port number here. 4. Scroll down to the line containing ;dev-node.You need to remove the semicolon and enter the name of the virtual adapter that OpenVPN installed in place of the default “MyTap.”You can find this by going to a command prompt and entering ipconfig /all. One of the adapters will list “TAP-Win32 Adapter V8” as its description.The name of that adapter is often Local Area Connection 2, or something similar. Protecting Your Perimeter • Chapter 2 99 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 99 Edit the line in the configuration file with the adapter name such as dev-node Local Area Connection 2. 5. Save your changes and then close the configuration file. TIP As a general rule, I always rename the network interfaces on my systems to make it easier to administer. When you are troubleshooting a connec- tion or program it is far easier to understand which interface is which with a more meaningful name than Local Area Connection 1, Local Area Connection 2, and so on. To do this, navigate to your Network Connection, right-click any of the connections, and select Rename. You can use ipconfig to see the description, which usually tells you which one is which. In the preceding example, I renamed the OpenVPN virtual adapter to OpenVPN, so my configuration file would read dev-node OpenVPN. At this point you can choose which type of authentication you want to implement. OpenVPN can support a wide variety of methods, including public key infrastructure (PKI), user/password, and even two-part authentica- tion with the proper plug-ins. For simplicity, we use a simple user and pass- word.You will need to create a server certificate and Certificate of Authenticity (CA) certificate.This must be done as part of the SSL encryp- tion, and is required whether you use PKI or user/password authentication. 6. Open a command prompt prompt on the server and CD to the \OpenVPN\easy-rsa\ directory. 7. Enter the init-config command and press Enter.This creates the vars.bat file and the openssl.cnf files. 8. Edit the vars.bat file using a text editor such as notepad.exe or write.exe. 9. Edit the HOME variable to match your directory structure if you installed OpenVPN to a non-default directory location. 100 Chapter 2 • Protecting Your Perimeter 421_Sec_Free_02.qxd 12/22/06 12:38 PM Page 100 10. Edit the KEY_COUNTRY, KEY_PROVINCE, KEY_CITY, KEY_ORG, and KEY_EMAIL variables with their appropriate values.These are used to generate the key file. 11. Enter the following commands at the command prompt. vars clean-all build-ca When you run build-ca it will prompt you for some localized information. It should read the defaults from what you entered in the vars.bat file for any required fields.Additional fields that were not in the vars.bat are optional. Pressing ENTER should accept each default value and fill in all of the required information.The only exception is the server’s “common name,” which you must enter. When the pro- cess completes there will be no special indication as to whether it was successful or not.You can verify the creation of the CA certifi- cate by checking in the \OpenVPN\easy-rsa\keys\ directory for a newly created ca.crt file. 12 Generate the required Diffie-Hellman parameters by running \OpenVPN\easy-rsa\build-dh. 13 Generate the server certificate by running \OpenVPN\easy-rsa\build- key-server server.As with build-ca, there will be a series of questions you must answer.The questions that must be answered should pull information in from the vars.bat file and use it as the defaults. Once again you will need to enter a common name in a series of prompts. 14 Add the following directives to the server configuration file (\OpenVPN\config\LAB_SERVER.ovpn). ■ client-cert-not-required Tells the server not to expect the clients to present their own certificate. ■ username-as-common-name Tells the server to use the user- name the client provides as the unique identifier for the client, rather than the common name found in the client’s certificate. ■ Auth-user-pass-verify