Cover image for Linux firewalls
Title:
Linux firewalls
Personal Author:
Edition:
3rd ed.
Publication Information:
Indianapolis, IN : Novell Pr., 2006
ISBN:
9780672327711
General Note:
Previous ed. : published as by Robert L. Ziegler/ 2nd ed./ Indianapolis, Ind. : New Riders, 2001 (QA76.9.A25 Z54 2001)

Available:*

Library
Item Barcode
Call Number
Material Type
Item Category 1
Status
Searching...
30000010134675 QA76.9.A25 Z54 2006 Open Access Book Book
Searching...

On Order

Summary

Summary

An Internet-connected Linux machine is in a high-risk situation. Linux Firewalls, Third Edition details security steps that any sized implementation--from home use to enterprise level--might take to protect itself from potential remote attackers. As with the first two editions, this book is especially useful for its explanations of iptables, packet filtering, and firewall optimization along with some advanced concepts including customizing the Linux kernel to enhance security.The third edition, while distribution neutral, has been updated for the current Linux Kernel and provides code examples for Red Hat, SUSE, and Debian implementations. Don't miss out on the third edition of the critically acclaimed Linux Firewalls .


Author Notes

Steve Suehring is a technology architect with a diverse set of skills


Excerpts

Excerpts

Introduction This book is essentially about creating a software-based firewall using Netfilter and iptables in the Linux operating system. Beyond the basics of a firewall, this book also looks at the firewall in the context of a networked computing environment. To that end, topics such as intrusion detection and system security are also covered. Computer security is an expansive subject area. Volumes have been written about it and volumes will continue to be written about it. Computer security is centered around protection of data assets using three principles: confidentiality, integrity, and availability. Confidentiality means that data is accessible only by those who are authorized to access the data and no one else. Integrity ensures that the data is verifiably good and is not tainted. Availability means that the data can be accessed when it needs to be accessed. These three principles guide the discussion of computer security and provide the framework for this book. In addition to the three principles of confidentiality, integrity, and availability, I subscribe to an in-depth, risk-assessed approach to computer security. This means that I don't consider any single option to be an endpoint when it comes to securing data, rather that each item such as a firewall or antivirus software plays a role in securing data. However, there is a cost involved with each measure of security. Therefore, each additional measure or layer of security must be assessed to ensure that the cost of that layer doesn't exceed the benefit of being protected from that risk. Consider this example: I use two firewalls, a choke and gateway (see Chapter 6, "Packet Forwarding"), for my home network. I consider the benefit of having a dual-firewall approach to outweigh the cost of operating and maintaining the firewalls. Other people use a single firewall or no firewall at all. They consider the risk of their data or systems being unavailable or attacked to be less costly than running a dual-firewall setup or even a single firewall for some. Many more examples of this cost/benefit assessment could be done. Unfortunately, this analysis is often overlooked for many areas of security, not just computer security. For more information on this type of analysis and a good read on top of it, see Bruce Schneier's works Secrets and Lies and Beyond Fear . The Purpose of This Book The goal of this book is to give the reader enough information that they may configure a firewall using iptables in Linux. A secondary goal is to educate the reader about system and network security. However, because this isn't a book on system and network security, those topics are indeed secondary even though they do consume a large portion of the book. There are also topics in this book that I haven't seen (yet) in other books to any great degree. You are reading the third revision of this book and the first revision with a new author, Steve Suehring. Bob Ziegler wrote the original material and also revised the work into its second revision in 2001. Bob did an excellent job and I've built upon his solid foundation to bring you the third revision. In addition, the previous revision had some material contributed by Carl B. Constantine. You'll find Carl's contribution, though updated, in Appendix C of this revision, "VPNs." I learned much of what I know about Linux security while working at an Internet service provider (ISP), beginning in 1995. Resisting the temptation to recite a "back when I was young" tale, I'll just say that most of what I learned was done with security in mind. It had to be. By definition at an ISP, you must run publicly available services and those services must be available 24x7. Having publicly available services means that there's a constant threat (and frequent execution) of attacks against the network and the systems therein. If we wouldn't have considered security to be central to our operation, we simply could not have ensured the reliability that our customers demanded, nor could we have guaranteed the integrity of the data that we housed. None of this takes into account the general lack of security tools, software, and books like this back in 1995, either. That background also helps to answer the question "Why Linux?" The answer was and is quite simple: Linux and open-source tools were the only solution when I was tasked with solving these problems. There simply was no other way to provide Internet services with anywhere near the reliability that Linux and open-source software provided. No other operating system provided the same set of reliability and security while at the same time keeping down the Total Cost of Ownership (TCO). The same can largely be said today. With a pure technological decision, Linux wins. Factor in TCO and the picture only gets better for Linux and open-source software, regardless of the results from funded and paid studies. Why Linux? Because it works. Who Should Read This Book I've usually found these "Who Should Read This Book" sections to be somewhat useless simply because the goal is to get you to think that you should read the book. Therefore, to satisfy the publisher I'll tell you that everyone should read this book. In fact, everyone should read this book multiple times, buying a separate copy each time. In all seriousness, I can't tell you whether you should be reading this book, but I can tell you about the book. This book assumes that you have already chosen a Linux distribution and that you've already installed it. This book also assumes that you're not looking for an introductory "HOWTO" on Linux or *nix security such as the chmod command. There are many great resources about those topics already, many of them on the Internet, and I feel as though coverage of those issues gets away from the focus of this book. However, this book does deal rather extensively with introductory material on network security, packet filtering, and the layers in the OSI model (if you're unfamiliar with the OSI model, it's explained in the book). This book tries to be helpful to those who know nothing about firewalls as well as to those who know a bit about Linux and Linux security but want to carry that to the next level. This book could be used successfully by home users and enterprise security administrators alike. To get the most out of this book, you should be comfortable with, or at least not afraid of, the Linux command line, or shell. You should know how to move about in the file system and perform basic shell commands. Linux Distribution Linux and open-source books need to be more distribution neutral or cover more than one distribution. This book does both. A Linux firewall is built using the iptables firewall administration program on top of the Netfilter core software that resides in the Linux kernel. As such, the Linux distribution you choose is largely irrelevant. The book does, however, cover some commands and issues as seen through the eyes of SUSE, Red Hat/Fedora, and Debian. Yes, there are other distributions, many of them very good. Favoring those three distributions is certainly not meant to take away from any other distribution. The second edition of this book covered only Red Hat. However, I undertook an effort early on in the revision process to remove the distribution-centric tone where it did show up. This was not done to intentionally favor any one distribution or to reject another. Rather, this was a pragmatic decision to provide material applicable to a larger audience and to prevent confusion as to file and command locations if you don't happen to be using the same distribution as the author. Errors in This Book Although every effort is made to check facts and figures, files and syntax, some errors will inevitably slip through the writing, technical editing, copyediting, and review process. Let me apologize in advance for any such errors as exist within these pages. I invite the reader to visit my web site at http://www.braingia.org/ for updates and other information about this book. I also invite you to send me feedback at steve.suehring@braingia.com . Although I can't guarantee that I'll have the answer, I will definitely try to respond and point you in the right direction. Companion Website Visit http://www.braingia.org/ for up-to-date information on this book and links to interesting security articles. Included on the website are the latest versions of some of the same scripts you'll see within the text. (c) Copyright Pearson Education. All rights reserved. Excerpted from Linux Firewalls by Robert Ziegler, Steve Suehring All rights reserved by the original copyright owners. Excerpts are provided for display purposes only and may not be reproduced, reprinted or distributed without the written permission of the publisher.

Table of Contents

Introductionp. 1
The Purpose of This Bookp. 2
Who Should Read This Bookp. 3
Linux Distributionp. 3
Errors in This Bookp. 4
Companion Websitep. 4
Part I Packet-Filtering and Basic Security Measures
Chapter 1 Preliminary Concepts Underlying Packet-Filtering Firewallsp. 7
The OSI Networking Modelp. 9
The IPp. 12
Transport Mechanismsp. 20
Don't Forget ARPp. 24
Hostnames and IP Addressesp. 24
Routing: Getting a Packet from Here to Therep. 25
Service Ports: The Door to the Programs on Your Systemp. 25
Summaryp. 30
Chapter 2 Packet-Filtering Conceptsp. 31
A Packet-Filtering Firewallp. 33
Choosing a Default Packet-Filtering Policyp. 35
Rejecting Versus Denying a Packetp. 38
Filtering Incoming Packetsp. 38
Filtering Outgoing Packetsp. 56
Private Versus Public Network Servicesp. 59
Summaryp. 61
Chapter 3 Iptables: The Linux Firewall Administration Programp. 63
Differences Between IPFW and Netfilter Firewall Mechanismsp. 64
Basic iptables Syntaxp. 67
iptables Featuresp. 68
iptables Syntaxp. 74
Summaryp. 99
Chapter 4 Building and Installing a Standalone Firewallp. 101
iptables: The Linux Firewall Administration Programp. 102
Initializing the Firewallp. 106
Protecting Services on Assigned Unprivileged Portsp. 119
Enabling Basic, Required Internet Servicesp. 124
Enabling Common TCP Servicesp. 132
Enabling Common UDP Servicesp. 160
Filtering ICMP Control and Status Messagesp. 166
Logging Dropped Incoming Packetsp. 170
Logging Dropped Outgoing Packetsp. 172
Denying Access to Problem Sites Up Frontp. 172
Installing the Firewallp. 173
Summaryp. 176
Part II Advanced Issues, Multiple Firewalls, and Perimeter Networks
Chapter 5 Firewall Optimizationp. 181
Rule Organizationp. 181
User-Defined Chainsp. 185
Optimized Examplep. 188
What Did Optimization Buy?p. 210
Summaryp. 212
Chapter 6 Packet Forwardingp. 213
The Limitations of a Standalone Firewallp. 213
Basic Gateway Firewall Setupsp. 215
LAN Security Issuesp. 217
Configuration Options for a Trusted Home LANp. 218
Configuration Options for a Larger or Less Trusted LANp. 222
A Formal Screened-Subnet Firewall Examplep. 231
Converting the Gateway from Local Services to Forwardingp. 258
Summaryp. 258
Chapter 7 NAT-Network Address Translationp. 261
The Conceptual Background of NATp. 261
iptables NAT Semanticsp. 266
Examples of SNAT and Private LANsp. 271
Examples of DNAT, LANs, and Proxiesp. 274
Summaryp. 280
Chapter 8 Debugging the Firewall Rulesp. 281
General Firewall-Development Tipsp. 281
Listing the Firewall Rulesp. 284
Checking the Input, Output, and Forwarding Rulesp. 294
Interpreting the System Logsp. 300
Checking for Open Portsp. 307
Summaryp. 312
Part III Beyond iptables
Chapter 9 Intrusion Detection and Responsep. 315
Detecting Intrusionsp. 315
Symptoms Suggesting That the System Might Be Compromisedp. 317
What to Do If Your System Is Compromisedp. 320
Incident Reportingp. 322
Summaryp. 327
Chapter 10 Intrusion Detection Toolsp. 329
Intrusion Detection Toolkit: Network Toolsp. 329
Rootkit Checkersp. 332
Filesystem Integrityp. 337
Log Monitoringp. 338
How to Not Become Compromisedp. 340
Summaryp. 344
Chapter 11 Network Monitoring and Attack Detectionp. 345
Listening to the Etherp. 345
TCPDump: A Simple Overviewp. 348
Using TCPDump to Capture Specific Protocolsp. 355
Automated Intrusion Monitoring with Snortp. 371
Monitoring with ARPWatchp. 377
Summaryp. 379
Chapter 12 Filesystem Integrityp. 381
Filesystem Integrity Definedp. 381
Installing AIDEp. 383
Configuring AIDEp. 383
Monitoring AIDE for Bad Thingsp. 388
Cleaning Up the AIDE Databasep. 390
Changing the Output of the AIDE Reportp. 391
Defining Macros in AIDEp. 394
The Types of AIDE Checksp. 396
Summaryp. 398
Chapter 13 Kernel Enhancementsp. 399
Security Enhanced Linuxp. 399
Greater Security with GrSecurityp. 401
A Quick Look Around the Kernelp. 401
To Patch or Not to Patchp. 404
Using a GrSecurity Kernelp. 405
GrSecurityp. 415
Conclusion: Custom Kernelsp. 421
Part IV Appendices
Appendix A Security Resourcesp. 425
Security Information Sourcesp. 425
Reference Papers and FAQsp. 426
Booksp. 426
Appendix B Firewall Examples and Support Scriptsp. 427
iptables Firewall for a Standalone System from Chapter 4p. 427
Optimized iptables Firewall from Chapter 5p. 446
iptables Firewall for a Choke Firewall from Chapter 6p. 463
Appendix C VPNsp. 475
Overview of Virtual Private Networksp. 475
VPN Protocolsp. 475
Linux and VPN Productsp. 480
VPN Configurationsp. 482
Connecting Networksp. 483
VPN and Firewallsp. 483
Summaryp. 485
Appendix D Glossaryp. 487