Schroder - Linux Networking Cookbook (O'Reilly, 2008).pdf

(3525 KB) Pobierz
435731690 UNPDF
Linux Networking Cookbook
Carla Schroder
Beijing Cambridge Farnham Köln Paris Sebastopol Taipei Tokyo
435731690.003.png
Linux Networking Cookbook
by Carla Schroder
Copyright © 2008 O’Reilly Media, Inc. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles ( safari.oreilly.com ). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com .
Editor: Mike Loukides
Production Editor: Sumita Mukherji
Copyeditor: Derek Di Matteo
Proofreader: Sumita Mukherji
Indexer: John Bickelhaupt
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrator: Jessamyn Read
Printing History:
November 2007: First Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. The Cookbook series designations, Linux Networking Cookbook , the image of a
female blacksmith, and related trade dress are trademarks of O’Reilly Media, Inc.
Java is a trademark of Sun Microsystems, Inc. .NET is a registered trademark of Microsoft
Corporation.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume
no responsibility for errors or omissions, or for damages resulting from the use of the information
contained herein.
This book uses RepKover, a durable and flexible lay-flat binding.
ISBN-10: 0-596-10248-8
ISBN-13: 978-0-596-10248-7
[M]
435731690.004.png
Table of Contents
Preface
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xv
1. Introduction to Linux Networking
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
1.0 Introduction
1
2. Building a Linux Gateway on a Single-Board Computer . . . . . . . . . . . . . . . . .
12
2.0 Introduction
12
2.1 Getting Acquainted with the Soekris 4521
14
2.2 Configuring Multiple Minicom Profiles
17
2.3 Installing Pyramid Linux on a Compact Flash Card
17
2.4 Network Installation of Pyramid on Debian
19
2.5 Network Installation of Pyramid on Fedora
21
2.6 Booting Pyramid Linux
24
2.7 Finding and Editing Pyramid Files
26
2.8 Hardening Pyramid
27
2.9 Getting and Installing the Latest Pyramid Build
28
2.10 Adding Additional Software to Pyramid Linux
28
2.11 Adding New Hardware Drivers
32
2.12 Customizing the Pyramid Kernel
33
2.13 Updating the Soekris comBIOS
34
3. Building a Linux Firewall
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
36
3.0 Introduction
36
3.1 Assembling a Linux Firewall Box
44
3.2 Configuring Network Interface Cards on Debian
45
3.3 Configuring Network Interface Cards on Fedora
48
3.4 Identifying Which NIC Is Which
50
v
435731690.005.png 435731690.006.png
 
3.5 Building an Internet-Connection Sharing Firewall on a Dynamic
WAN IP Address
51
3.6 Building an Internet-Connection Sharing Firewall on a Static
WAN IP Address
56
3.7 Displaying the Status of Your Firewall
57
3.8 Turning an iptables Firewall Off
58
3.9 Starting iptables at Boot, and Manually Bringing Your Firewall
Up and Down
59
3.10 Testing Your Firewall
62
3.11 Configuring the Firewall for Remote SSH Administration
65
3.12 Allowing Remote SSH Through a NAT Firewall
66
3.13 Getting Multiple SSH Host Keys Past NAT
68
3.14 Running Public Services on Private IP Addresses
69
3.15 Setting Up a Single-Host Firewall
71
3.16 Setting Up a Server Firewall
76
3.17 Configuring iptables Logging
79
3.18 Writing Egress Rules
80
4. Building a Linux Wireless Access Point
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
82
4.0 Introduction
82
4.1 Building a Linux Wireless Access Point
86
4.2 Bridging Wireless to Wired
87
4.3 Setting Up Name Services
90
4.4 Setting Static IP Addresses from the DHCP Server
93
4.5 Configuring Linux and Windows Static DHCP Clients
94
4.6 Adding Mail Servers to dnsmasq
96
4.7 Making WPA2-Personal Almost As Good As WPA-Enterprise
97
4.8 Enterprise Authentication with a RADIUS Server
100
4.9 Configuring Your Wireless Access Point to Use FreeRADIUS
104
4.10 Authenticating Clients to FreeRADIUS
106
4.11 Connecting to the Internet and Firewalling
107
4.12 Using Routing Instead of Bridging
108
4.13 Probing Your Wireless Interface Card
113
4.14 Changing the Pyramid Router’s Hostname
114
4.15 Turning Off Antenna Diversity
115
4.16 Managing dnsmasq’s DNS Cache
117
4.17 Managing Windows’ DNS Caches
120
4.18 Updating the Time at Boot
121
vi
|
Table of Contents
435731690.001.png
5. Building a VoIP Server with Asterisk
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
123
5.0 Introduction
123
5.1 Installing Asterisk from Source Code
127
5.2 Installing Asterisk on Debian
131
5.3 Starting and Stopping Asterisk
132
5.4 Testing the Asterisk Server
135
5.5 Adding Phone Extensions to Asterisk and Making Calls
136
5.6 Setting Up Softphones
143
5.7 Getting Real VoIP with Free World Dialup
146
5.8 Connecting Your Asterisk PBX to Analog Phone Lines
148
5.9 Creating a Digital Receptionist
151
5.10 Recording Custom Prompts
153
5.11 Maintaining a Message of the Day
156
5.12 Transferring Calls
158
5.13 Routing Calls to Groups of Phones
158
5.14 Parking Calls
159
5.15 Customizing Hold Music
161
5.16 Playing MP3 Sound Files on Asterisk
161
5.17 Delivering Voicemail Broadcasts
162
5.18 Conferencing with Asterisk
163
5.19 Monitoring Conferences
165
5.20 Getting SIP Traffic Through iptables NAT Firewalls
166
5.21 Getting IAX Traffic Through iptables NAT Firewalls
168
5.22 Using AsteriskNOW, “Asterisk in 30 Minutes”
168
5.23 Installing and Removing Packages on AsteriskNOW
170
5.24 Connecting Road Warriors and Remote Users
171
6. Routing with Linux
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
173
6.0 Introduction
173
6.1 Calculating Subnets with ipcalc
176
6.2 Setting a Default Gateway
178
6.3 Setting Up a Simple Local Router
180
6.4 Configuring Simplest Internet Connection Sharing
183
6.5 Configuring Static Routing Across Subnets
185
6.6 Making Static Routes Persistent
186
6.7 Using RIP Dynamic Routing on Debian
187
6.8 Using RIP Dynamic Routing on Fedora
191
6.9 Using Quagga’s Command Line
192
Table of Contents
vii
|
435731690.002.png
Zgłoś jeśli naruszono regulamin