Download Quick Fix Notebook – Free 696 Page eBook

Download Quick Fix Notebook

Download Quick Fix Notebook Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxxi
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xl
About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xli

Part 1 The Linux File Server Project

1 Why Host Your Own Site? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3
Our Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
Alternatives to In-House Web Hosting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
Virtual Hosting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
Dedicated Hosting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
Factors to Consider Before Hosting Yourself . . . . . . . . . . . . . . . . . . . . . . . . . .6
Is In-House Hosting Preferred? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6
How to Migrate From an External Provider . . . . . . . . . . . . . . . . . . . . . . . . . . .8
In-House Server Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10

2 Introduction to Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
The OSI Networking Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
An Introduction to TCP/IP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13
TCP Is a Connection-Oriented Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . .14
How TCP Establishes a Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
UDP, TCP’s “Connectionless” Cousin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
TCP and UDP Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
The TCP/IP Time to Live Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
The ICMP Protocol and Its Relationship to TCP/IP . . . . . . . . . . . . . . . . . .16
How IP Addresses Are Used to Access Network Devices . . . . . . . . . . . . . . .17
Private IP Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17
The localhost IP Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
Network Address Translation (NAT) Makes Private IPs Public . . . . . . . .18
Port Forwarding with NAT Facilitates Home-Based Web Sites . . . . . . . .19
DHCP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
How DNS Links Your IP Address to Your Web Domain . . . . . . . . . . . . . . .20
IP Version 6 (IPv6) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
How Subnet Masks Group IP Addresses into Networks . . . . . . . . . . . . . . . .21
Calculating the Number of Addresses Assigned to a Subnet . . . . . . . . . . .22
Calculating the Range of Addresses on Your Network . . . . . . . . . . . . . . . .22
Subnet Masks for the Typical Business DSL Line . . . . . . . . . . . . . . . . . . .24
The Physical and Link Layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
Networking Equipment Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
Network Interface Cards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
The Two Broad Types of Networking Equipment . . . . . . . . . . . . . . . . . . .27
Connectivity Using Hubs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
Using Switches as a Faster Alternative to Hubs . . . . . . . . . . . . . . . . . . . .29
Local Area Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
How Routers Interconnect LANs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
How Simple Routing Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30
Default Gateways, the Routers of Last Resort . . . . . . . . . . . . . . . . . . . . . .31
Firewalls Help Provide a Secure Routing Environment . . . . . . . . . . . . . .31
Additional Introductory Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
The File Transfer Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
Linux Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33

3 Linux Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
How to Configure Your NIC’s IP Address . . . . . . . . . . . . . . . . . . . . . . . . . . . .36
Determining Your IP Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36
Changing Your IP Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37
Multiple IP Addresses on a Single NIC . . . . . . . . . . . . . . . . . . . . . . . . . . .39
IP Address Assignment for a Direct DSL Connection . . . . . . . . . . . . . . . .40
IP Address Assignment for a Cable Modem Connection . . . . . . . . . . . . . .45
How to Activate/Shut Down Your NIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
How to View Your Current Routing Table . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
How to Change Your Default Gateway . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46
How to Configure Two Gateways . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47
Adding Routes from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . .47
Adding Routes with /etc/sysconfig/network-scripts/ Files . . . . . . . . . . .48
How to Delete a Route . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Changing NIC Speed and Duplex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Using mii-tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Using ethtool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50
How to Convert Your Linux Server into a Router . . . . . . . . . . . . . . . . . . . . . .52
Configuring IP Forwarding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52
Configuring Proxy ARP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
Configuring Your /etc/hosts File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .54
The loopback Interface’s localhost Entry . . . . . . . . . . . . . . . . . . . . . . . . . .55
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56

4 Simple Network Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57
Sources of Network Slowness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Sources of a Lack of Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Doing Basic Cable and Link Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Testing Your NIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59
Viewing Your Activated Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59
Viewing All Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59
Testing Link Status from the Command Line . . . . . . . . . . . . . . . . . . . . . .60
Viewing NIC Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61
How to See MAC Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62
Using ping to Test Network Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . .64
Using telnet to Test Network Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . .65
Linux telnet Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66
Successful Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66
Connection Refused Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67
telnet Timeout or Hanging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67
telnet Troubleshooting Using Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67
Screen Goes Blank—Successful Connection . . . . . . . . . . . . . . . . . . . . . . . .68
Connect Failed Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
telnet Timeout or Hanging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
Testing Web Sites with the curl and wget Utilities . . . . . . . . . . . . . . . . . . . . .68
Using curl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
Using wget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69
The netstat Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70
The Linux iptables Firewall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
Determining Whether iptables Is Running . . . . . . . . . . . . . . . . . . . . . . . .71
How to Stop iptables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
How to Configure iptables Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
Using traceroute to Test Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
Sample traceroute Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72
Possible traceroute Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72
traceroute Time Exceeded False Alarms . . . . . . . . . . . . . . . . . . . . . . . . . . .73
traceroute Internet Slowness False Alarm . . . . . . . . . . . . . . . . . . . . . . . . .74
traceroute Dies at the Router Just Before the Server . . . . . . . . . . . . . . . .75
Always Get a Bidirectional traceroute . . . . . . . . . . . . . . . . . . . . . . . . . . . .75
ping and traceroute Troubleshooting Example . . . . . . . . . . . . . . . . . . . . . .77
tracerouteWeb Sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77
Possible Reasons for a Failed traceroute . . . . . . . . . . . . . . . . . . . . . . . . . .78
Using MTR to Detect Network Congestion . . . . . . . . . . . . . . . . . . . . . . . . . . .79
Viewing Packet Flows with tcpdump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
Analyzing tcpdump files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
Common Problems with tcpdump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
Viewing Packet Flows with tethereal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83
Basic DNS Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85
Using nslookup to Test DNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85
Using the host Command to Test DNS . . . . . . . . . . . . . . . . . . . . . . . . . . . .86
Using nmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87
Determining the Source of an Attack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88
Who Has Used My System? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89
The last Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89
The who Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90

5 Troubleshooting Linux with syslog . . . . . . . . . . . . . . . . . . . . . . . . . . . .91

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91
syslog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92
The /etc/syslog.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92
Activating Changes to the syslog Configuration File . . . . . . . . . . . . . . . .93
How to View New Log Entries as They Happen . . . . . . . . . . . . . . . . . . . . .93
Logging syslog Messages to a Remote Linux Server . . . . . . . . . . . . . . . . .94
syslog Configuration and Cisco Network Devices . . . . . . . . . . . . . . . . . . .96
syslog and Firewalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96
logrotate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96
The /etc/logrotate.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96
Sample Contents of /etc/logrotate.conf . . . . . . . . . . . . . . . . . . . . . . . . . .97
The /etc/logrotate.d Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97
Activating logrotate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
Compressing Your Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99

6 Installing RPM Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101
Where to Get Commonly Used RPMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102
RPMs on Your Installation CDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102
RPMs Downloaded from Fedora . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102
RPMs Downloaded from rpmfind.net . . . . . . . . . . . . . . . . . . . . . . . . . . . .103
Getting RPMs Using Web-Based FTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103
Using the Fedora Web site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103
Using the rpmfindWeb site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103
Getting RPMs Using Command-Line Anonymous FTP . . . . . . . . . . . . . . . .104
Getting RPMs Using wget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107
Automatic Updates with yum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107
Configuring yum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108
Creating Your Own yum Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109
Before You Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110
Keeping Your System Current with yum . . . . . . . . . . . . . . . . . . . . . . . . . .110
Example of a yum Package Installation . . . . . . . . . . . . . . . . . . . . . . . . . . .112
How to Install RPMs Manually . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113
Using Downloaded Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113
Using CD-ROMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113
How to Install Source RPMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114
RPM Installation Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115
Failed Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115
Signature Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116
How to List Installed RPMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117
Listing Files Associated with RPMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117
Listing Files for Already Installed RPMs . . . . . . . . . . . . . . . . . . . . . . . . .118
Listing Files in RPM Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118
Listing the RPM to Which a File Belongs . . . . . . . . . . . . . . . . . . . . . . . . .119
Uninstalling RPMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119
Which RPMs Start at Boot Time? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119
Installing Software Using tar Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120

7 The Linux Boot Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121
The Fedora Boot Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121
Determining the Default Boot runlevel . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123
Getting a GUI Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124
Get a Basic Text Terminal Without Exiting the GUI . . . . . . . . . . . . . . . . . .125
Using a GUI Terminal Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125
Using Virtual Consoles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125
System Shutdown and Rebooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125
Halt/Shut Down the System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125
Reboot the System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126
Entering Single-user Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127
How to Set Programs to Run at Each runlevel . . . . . . . . . . . . . . . . . . . . . . .129
chkconfig Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129
Using chkconfig to Improve Security . . . . . . . . . . . . . . . . . . . . . . . . . . . .130
Final Tips on chkconfig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133

8 Configuring the DHCP Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135
Download and Install the DHCP Package . . . . . . . . . . . . . . . . . . . . . . . . . .135
The /etc/dhcpd.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136
How to Get DHCP Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
DHCP Servers with Multiple NICs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
Temporary Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
Permanent Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
Configuring Linux Clients to Use DHCP . . . . . . . . . . . . . . . . . . . . . . . . . . .139
Configuring Windows Clients to Use DHCP . . . . . . . . . . . . . . . . . . . . . . . . .139
Simple DHCP Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
DHCP Clients Obtaining 169.254.0.0 Addresses . . . . . . . . . . . . . . . . . . .140
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .140

9 Linux Users and sudo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141
Adding Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141
Who Is the Super User? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141
How to Add Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142
How to Change Passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142
How to Delete Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .143
How to Tell the Groups to Which a User Belongs . . . . . . . . . . . . . . . . . .143
How to Change the Ownership of a File . . . . . . . . . . . . . . . . . . . . . . . . . .144
Using sudo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144
Example of a User Using sudo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144
Downloading and Installing the sudo Package . . . . . . . . . . . . . . . . . . . . .145
Simple /etc/sudoers Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .146
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148

10 Windows, Linux, and Samba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149
Download and Install Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150
How to Get Samba Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .151
The Samba Configuration File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .151
How SWAT Makes Samba Simpler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .152
Basic SWAT Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .152
Controlling SWAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .154
Encrypting SWAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .154
How to Make SWAT Changes Immediate . . . . . . . . . . . . . . . . . . . . . . . . .158
Creating a Starter Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158
The [global] Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158
The [homes] Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .160
The [netlogon] and [profiles] Share Sections . . . . . . . . . . . . . . . . . . . . . .161
The [printers] Share Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161
Shares for Specific Groups of Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162
Samba Passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162
How to Create a Samba PDC Administrator User . . . . . . . . . . . . . . . . . . . .162
Home Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162
Corporate Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163
How to Add Workstations to Your Samba Domain . . . . . . . . . . . . . . . . . . . .163
Create Samba Trust Accounts for Each Workstation . . . . . . . . . . . . . . . .163
Make Your PC Clients Aware of Your Samba PDC . . . . . . . . . . . . . . . . .164
How to Add Users to Your Samba Domain . . . . . . . . . . . . . . . . . . . . . . . . . .166
Adding the Users in Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166
Mapping the Linux Users to an smbpassword . . . . . . . . . . . . . . . . . . . . . . .166
Mapping a Private Windows Drive Share . . . . . . . . . . . . . . . . . . . . . . . . .167
Domain Groups and Samba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .168
How to Delete Users from Your Samba Domain . . . . . . . . . . . . . . . . . . . . . .168
How to Modify Samba Passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169

11 Sharing Resources Using Samba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
Adding a Printer to a Samba PDC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
Adding the Printer to Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
Make Samba Aware of the Printer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .173
Configure the Printer Driver on the Workstations . . . . . . . . . . . . . . . . . .173
Creating Group Shares in Samba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174
Create the Directory and User Group . . . . . . . . . . . . . . . . . . . . . . . . . . . .174
Configure the Share in SWAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174
Map the Directory Using My Computer . . . . . . . . . . . . . . . . . . . . . . . . . .175
Sharing Windows Drives Using a Linux Samba Client . . . . . . . . . . . . . . . .175
Windows Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .175
Test Your Windows Client Configuration . . . . . . . . . . . . . . . . . . . . . . . . .176
Create a CD-ROM Drive Mount Point on Your Samba Server . . . . . . . .177
Automating Mounting with Linux Samba Clients . . . . . . . . . . . . . . . . . . . .178
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178

12 Samba Security and Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . .179

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179
Testing the smb.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179
Samba and Firewall Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180
Linux iptables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180
Windows-based Zone Alarm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .181
The Windows XP Built-In Firewall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .181
Testing Basic Client/Server Network Connectivity . . . . . . . . . . . . . . . . . . .181
Testing Samba Client/Server Network Connectivity . . . . . . . . . . . . . . . . . .182
Checking the Samba Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .186
Samba Network Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .186
Basic Samba Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .186
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .186

13 Linux Wireless Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .187

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .187
Wireless Linux-Compatible NICs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .188
Common Wireless Networking Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .188
Wireless Access Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .188
Extended Service Set ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .189
Encryption Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .189
Networking with Linux Wireless Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . .189
Using iwconfig for Wireless Tools Configuration . . . . . . . . . . . . . . . . . . .189
Permanent Wireless Tools Configuration . . . . . . . . . . . . . . . . . . . . . . . . .190
Wireless Tools Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .191
Networking with Linux-WLAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .191
Linux-WLAN Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .192
Identifying the Correct RPMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .192
Installing the RPMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .193
Linux-WLAN Post Installation Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . .194
Start Linux-WLAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .196
Testing Linux-WLAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .196
Linux-WLAN Encryption for Security . . . . . . . . . . . . . . . . . . . . . . . . . . .197
Troubleshooting Your Wireless LAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .199
Check the NIC Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .200
Check for Interrupt Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202
Kernel Log Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203
Can’t Ping Default Gateway . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203
Unknown Device Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203
A Common Problem with Linux-WLAN and Fedora Core 1 . . . . . . . . . .204
Wireless Networks In Businesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .205
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206

Part 2 The Linux Web Site Project

14 Linux Firewalls Using iptables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209
What Is iptables? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .210
Download and Install the iptables Package . . . . . . . . . . . . . . . . . . . . . . . . .211
How to Start iptables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211
Determining the Status of iptables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211
Packet Processing in iptables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211
Targets and Jumps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .215
Important iptables Command Switch Operations . . . . . . . . . . . . . . . . . . . .216
Using User-Defined Chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .219
Saving Your iptables Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .220
Fedora’s iptables Rule Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .220
Recovering from a Lost Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .221
Loading Kernel Modules Needed by iptables . . . . . . . . . . . . . . . . . . . . . . . .222
Sample iptables Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .222
Basic Operating System Defense . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .223
Basic iptables Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .225
Advanced iptables Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .226
Allowing DNS Access to Your Firewall . . . . . . . . . . . . . . . . . . . . . . . . . . .227
Allowing WWW and SSH Access to Your Firewall . . . . . . . . . . . . . . . . . .227
Allowing Your Firewall to Access the Internet . . . . . . . . . . . . . . . . . . . . .228
Allow Your Home Network to Access the Firewall . . . . . . . . . . . . . . . . . .229
Masquerading (Many to One NAT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .229
Port Forwarding Type NAT (DHCP DSL) . . . . . . . . . . . . . . . . . . . . . . . . .230
Static NAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .232
Troubleshooting iptables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .234
Checking the Firewall Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .234
iptablesWon’t Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .236
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .236

15 Linux FTP Server Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237
FTP Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237
Types of FTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .238
Problems with FTP and Firewalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .240
Client Protected by a Firewall Problem . . . . . . . . . . . . . . . . . . . . . . . . . .240
Server Protected by a Firewall Problem . . . . . . . . . . . . . . . . . . . . . . . . . .241
How to Download and Install VSFTPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . .242
How to Get VSFTPD Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .242
Testing the Status of VSFTPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243
The vsftpd.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243
Other vsftpd.conf Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245
FTP Security Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245
The /etc/vsftpd.ftpusers File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245
Anonymous Upload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245
FTP Greeting Banner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .246
Using SCP as Secure Alternative to FTP . . . . . . . . . . . . . . . . . . . . . . . . .246
Troubleshooting FTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .246
Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .246
FTP Users with Read-Only Access to a Shared Directory . . . . . . . . . . . .247
Sample Login Session to Test Functionality . . . . . . . . . . . . . . . . . . . . . . .248
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .249

16 Telnet, TFTP, and xinetd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .251

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .251
Managing xinetd Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .251
Controlling xinetd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .251
Controlling xinetd-Managed Applications . . . . . . . . . . . . . . . . . . . . . . . .252
TELNET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .252
Using The TELNET Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .252
Installing the TELNET Server Software . . . . . . . . . . . . . . . . . . . . . . . . .253
Setting Up a TELNET Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .254
Stopping a TELNET Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .254
Basic TELNET Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .254
TFTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .256
Installing the TFTP Server Software . . . . . . . . . . . . . . . . . . . . . . . . . . . .257
Configuring the TFTP Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .257
Saving Cisco Configurations to the TFTP Server . . . . . . . . . . . . . . . . . . .258
Uploading Cisco Configurations from the TFTP Server . . . . . . . . . . . . .260
Using TFTP to Restore Your Router Configuration . . . . . . . . . . . . . . . . .261
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .262

17 Secure Remote Logins and File Copying . . . . . . . . . . . . . . . . . . . . . . .263


In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .263
A Quick Introduction to SSH Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . .263
Starting OpenSSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265
Testing the Status of SSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265
The /etc/ssh/sshd_config File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265
SSH Versions 1 and 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266
Change the TCP Port on Which SSH Listens . . . . . . . . . . . . . . . . . . . . . .266
Using SSH to Log Into a Remote Machine . . . . . . . . . . . . . . . . . . . . . . . . . .267
What to Expect with Your First Login . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .267
SSH Failures Due to Linux Reinstallations . . . . . . . . . . . . . . . . . . . . . . .268
Deactivating TELNET After Installing SSH . . . . . . . . . . . . . . . . . . . . . . . .268
Executing Remote Commands on Demand with SSH . . . . . . . . . . . . . . . . .269
SCP: A Secure Alternative to FTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .269
Copying Files to the Local Linux Box . . . . . . . . . . . . . . . . . . . . . . . . . . . .270
Copying Files to the Remote Linux Box . . . . . . . . . . . . . . . . . . . . . . . . . .270
SFTP: Another Secure Alternative to FTP . . . . . . . . . . . . . . . . . . . . . . . . . .271
Using SSH and SCP Without a Password . . . . . . . . . . . . . . . . . . . . . . . . . . .271
Configuration: Client Side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .272
Configuration: Server Side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .273
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .273

18 Configuring DNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .275

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .275
Introduction to DNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .275
DNS Domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .276
BIND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .276
DNS Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .276
Authoritative DNS Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .276
How DNS Servers Find Your Site Information . . . . . . . . . . . . . . . . . . . . .276
When to Use a DNS Caching Name Server . . . . . . . . . . . . . . . . . . . . . . .276
When to Use a Static DNS Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .277
When To Use A Dynamic DNS Server . . . . . . . . . . . . . . . . . . . . . . . . . . .277
How to Get Your Own Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .277
Basic DNS Testing of DNS Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . .278
Downloading and Installing the BIND Packages . . . . . . . . . . . . . . . . . . . . .279
Starting BIND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279
The /etc/resolv.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279
Configuring a Caching Name Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280
Important File Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281
Configuring a Regular Name Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282
Configuring resolv.conf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282
Configuring named.conf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282
Configuring the Zone Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .284
Sample Forward Zone File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .287
Sample Reverse Zone File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .288
What You Need to Know About NAT and DNS . . . . . . . . . . . . . . . . . . . .289
Loading Your New Configuration Files . . . . . . . . . . . . . . . . . . . . . . . . . . .292
Make Sure Your /etc/hosts File is Correctly Updated . . . . . . . . . . . . . . .292
Configure Your Firewall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .293
Fix Your Domain Registration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .293
Troubleshooting BIND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .294
General Troubleshooting Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .295
Migrating Your Web Site In-House . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .298
DHCP Considerations for DNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .299
Simple DNS Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .300
Zone Transfer Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .300
Naming Convention Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .301
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .301

19 Dynamic DNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .303

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .303
Dynamic DNS Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .304
Testing ISP Connectivity for Your Web Site . . . . . . . . . . . . . . . . . . . . . . .304
Registering DDNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .305
Install a DDNS Client on Your Server . . . . . . . . . . . . . . . . . . . . . . . . . . .306
Dynamic DNS and NAT Router/Firewalls . . . . . . . . . . . . . . . . . . . . . . . . . .307
DDNS Client Software: SOHO Router/Firewalls . . . . . . . . . . . . . . . . . . . . .307
DDNS Client Software: Linux DDclient . . . . . . . . . . . . . . . . . . . . . . . . . . . .307
The /etc/ddclient.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .308
How to Get DDclient Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .309
Finding DDclient Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .310
Testing Your Dynamic DNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .310
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .311

20 The Apache Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .313

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .313
Downloading and Installing the Apache Package . . . . . . . . . . . . . . . . . . . .313
Starting Apache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .314
Configuring DNS for Apache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .314
DHCP and Apache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .314
General Configuration Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .315
Where to Put Your Web Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .315
Named Virtual Hosting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .320
IP-Based Virtual Hosting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .321
Virtual Hosting and SSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .322
Configuration: Multiple Sites and IP Addresses . . . . . . . . . . . . . . . . . . . . . .323
Testing Your Web Site Before DNS Is Fixed . . . . . . . . . . . . . . . . . . . . . . .325
Disabling Directory Listings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .326
Handling Missing Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .327
Using Data Compression on Web Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . .327
Compression Configuration Example . . . . . . . . . . . . . . . . . . . . . . . . . . . .328
Apache Running on a Server Behind a NAT Firewall . . . . . . . . . . . . . . . . .329
Step 1: Configure Virtual Hosting on Multiple IPs . . . . . . . . . . . . . . . . .329
Step 2: Configure DNS Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .329
Protecting Web Page Directories with Passwords . . . . . . . . . . . . . . . . . . . .330
The /etc/httpd/conf.d Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .331
Troubleshooting Apache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .332
Testing Basic HTTP Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .332
Browser 403 Forbidden Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .332
Only the Default Apache Page Appears . . . . . . . . . . . . . . . . . . . . . . . . . .332
Incompatible /etc/httpd/conf/http.conf Files When Upgrading . . . . . .333
Server Name Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .333
The Apache Status Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .333
The Apache Error Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .335
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .335

21 Configuring Linux Mail Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .337

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .337
Configuring sendmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .337
How sendmailWorks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .337
Installing sendmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .340
Starting sendmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .340
How to Restart sendmail After Editing Your Configuration Files . . . . . .340
The /etc/mail/sendmail.mc File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .341
Configuring DNS for sendmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .342
How to Configure Linux sendmail Clients . . . . . . . . . . . . . . . . . . . . . . . . .343
Converting From a Mail Client to a Mail Server . . . . . . . . . . . . . . . . . . .343
The /etc/mail/relay-domains File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .345
The /etc/mail/access File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .346
The /etc/mail/local-host-names File . . . . . . . . . . . . . . . . . . . . . . . . . . . . .347
Which User Should Really Receive the Mail? . . . . . . . . . . . . . . . . . . . . . .347
sendmail Masquerading Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .350
Using sendmail to Change the Sender’s E-mail Address . . . . . . . . . . . . .352
Troubleshooting sendmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .353
Fighting Spam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .358
Using Public Spam Blacklists with sendmail . . . . . . . . . . . . . . . . . . . . . .358
spamassassin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .359
A Simple PERL Script to Help Stop Spam . . . . . . . . . . . . . . . . . . . . . . . .361
Configuring Your POP Mail Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .362
Installing Your POP Mail Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .362
Starting Your POP Mail Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .362
How to Configure Your Windows Mail Programs . . . . . . . . . . . . . . . . . . .363
Configuring Secure POP Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .363
How to Handle Overlapping E-mail Addresses . . . . . . . . . . . . . . . . . . . .363
Troubleshooting POP Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .363
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .364

22 Monitoring Server Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .365

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .365
SNMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .365
OIDs and MIBs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .365
SNMP Community Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .368
SNMP Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .368
Doing SNMP Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .369
Basic SNMP Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .371
Simple SNMP Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .373
MRTG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .373
MRTG Download and Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .374
Configuring MRTG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .375
Getting MRTG to Poll Multiple Devices . . . . . . . . . . . . . . . . . . . . . . . . . .377
Configuring Apache to Work with MRTG . . . . . . . . . . . . . . . . . . . . . . . . .377
How to View the MRTG Graphs in Your Web Browser . . . . . . . . . . . . . .378
Using MRTG to Monitor Other Subsystems . . . . . . . . . . . . . . . . . . . . . . .378
Troubleshooting MRTG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .379
Webalizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .380
How to View Your Webalizer Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . .381
The Webalizer Configuration File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .381
The top Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .381
The vmstat Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .382
The free Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .382
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .383

23 Advanced MRTG for Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385
Locating and Viewing the Contents of Linux MIBs . . . . . . . . . . . . . . . . . . .385
Testing Your MIB Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .387
Differences in MIB and MRTG Terminology . . . . . . . . . . . . . . . . . . . . . . . .387
The CPU and the Memory Monitoring MIB . . . . . . . . . . . . . . . . . . . . . . . . .388
The TCP/IP Monitoring MIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .388
Manually Configuring Your MRTG File . . . . . . . . . . . . . . . . . . . . . . . . . . . .389
Parameter Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .389
Legend Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .390
Options Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .390
Title Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .391
Scaling Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .391
Defining The MIB Target Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . .391
Defining Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .395
Implementing Advanced Server Monitoring . . . . . . . . . . . . . . . . . . . . . . . . .395
A Complete Sample Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .395
Testing the Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .397
Creating a New MRTG Index Page to Include this File . . . . . . . . . . . . .398
Configuring CRON to Use the New MRTG File . . . . . . . . . . . . . . . . . . . .398
Monitoring Non-Linux MIB Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .398
Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .398
Find the OIDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .399
Testing The OIDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .399
Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .400
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .400

24 The NTP Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .401

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .401
Download and Install the NTP Package . . . . . . . . . . . . . . . . . . . . . . . . . . . .402
The /etc/ntp.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .402
How to Get NTP Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .403
Testing and Troubleshooting NTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .403
Verifying NTP is Running . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .403
Doing an Initial Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .403
Determining If NTP Is Synchronized Properly . . . . . . . . . . . . . . . . . . . .404
Your Linux NTP Clients Cannot Synchronize Properly . . . . . . . . . . . . . .405
Fedora Core 2 File Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .406
Configuring Cisco Devices to Use an NTP Server . . . . . . . . . . . . . . . . . . . .406
Cisco IOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .406
CAT OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .407
Firewalls and NTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .407
Configuring a Windows NTP Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .407
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .408

Part 3 Advanced Topics

25 Network-Based Linux Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . .411

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .411
Setting Up the Installation Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .412
Basic Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .412
Set Up Your Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .414
Set Up Your FTP Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .414
Create a Special FTP User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .415
xxii Contents
00Harrison_FM.qxd 2/25/05 12:39 PM Page xxii
Set Up Your NFS Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .415
Configure Your DHCP Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .416
Creating a Boot CD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .416
The Network Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .416
Troubleshooting the Network Installation . . . . . . . . . . . . . . . . . . . . . . . . . .417
Differences Between Fedora and Red Hat Installation . . . . . . . . . . . . . . . .417
Automating Installation with Kickstart . . . . . . . . . . . . . . . . . . . . . . . . . . . .417
How to Create New Kickstart Configuration Files . . . . . . . . . . . . . . . . .418
How to Run a Kickstart Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . .419
Booting With Your Kickstart Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .419
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .420

26 Linux Software RAID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .421

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .421
RAID Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .421
Linear Mode RAID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .421
RAID 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .422
RAID 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .423
RAID 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .423
RAID 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .423
Before You Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .424
IDE Drives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .424
Serial ATA Drives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .425
SCSI Drives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .425
Should I Use Software RAID Partitions or Entire Disks? . . . . . . . . . . . .426
Back up Your System First . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .426
Configure RAID in Single-User Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . .426
Configuring Software RAID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .427
RAID Partitioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .427
Edit the RAID Configuration File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .430
Create the RAID Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .431
Confirm RAID Is Correctly Initialized . . . . . . . . . . . . . . . . . . . . . . . . . . .431
Format the New RAID Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .431
Load the RAID Driver for the New RAID Set . . . . . . . . . . . . . . . . . . . . .432
Create a Mount Point for the RAID Set . . . . . . . . . . . . . . . . . . . . . . . . . .432
Edit the /etc/fstab File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .432
Start the New RAID Set’s Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .433
Mount the New RAID Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .433
Check the Status of the New RAID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .434
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .434

27 Expanding Disk Capacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .435

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .435
Adding Disks to Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .435
Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .435
Determining the Disk Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .436
Contents xxiii
00Harrison_FM.qxd 2/25/05 12:39 PM Page xxiii
Preparing Partitions on New Disks . . . . . . . . . . . . . . . . . . . . . . . . . . . . .437
Verifying Your New Partition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .439
Putting a Directory Structure on Your New Partition . . . . . . . . . . . . . . .439
Migrating Data to Your New Partition . . . . . . . . . . . . . . . . . . . . . . . . . . .440
Expanding Partitions with LVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .442
LVM Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .442
Configuring LVM Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .443
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .449

28 Managing Disk Usage with Quotas . . . . . . . . . . . . . . . . . . . . . . . . . . . .451

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .451
Setting Up Quotas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .451
Enter Single-User Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .451
Edit Your /etc/fstab File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .452
Remount the Filesystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .452
Get Out of Single-User Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .452
Create the Partition Quota Configuration Files . . . . . . . . . . . . . . . . . . . .453
Initialize the Quota Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .453
Edit the User’s Quota Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .453
Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .454
Other Quota Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .454
Editing Grace Periods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .454
Editing Group Quotas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .455
Getting Quota Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .455
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .455

29 Remote Disk Access With NFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .457

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .457
NFS Operation Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .457
General NFS Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .458
Key NFS Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .458
Important NFS Daemons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .460
Installing nfs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .461
Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .462
Configuring NFS on the Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .462
The /etc/exports File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .462
Starting NFS on the Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .463
Configuring NFS on the Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .463
Starting NFS on the Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .464
NFS and DNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .464
Making NFS Mounting Permanent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .465
Activating Modifications to the /etc/exports File . . . . . . . . . . . . . . . . . . . .467
New Exports File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .467
Adding a Shared Directory To An Existing Exports File . . . . . . . . . . . . .467
Deleting, Moving, or Modifying a Share . . . . . . . . . . . . . . . . . . . . . . . . . .468
xxiv Contents
00Harrison_FM.qxd 2/25/05 12:39 PM Page xxiv
The NFS automounter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .468
automounter Map Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .468
The Structure of Direct and Indirect Map Files . . . . . . . . . . . . . . . . . . . .469
Wildcards in Map Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .471
Starting automounter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .471
automounter Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .472
Troubleshooting NFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .472
The showmount Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .473
The df Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .473
The nfsstat Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .473
Other NFS Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .474
Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .475
NFS Hanging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .475
File Locking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .476
Nesting Exports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .476
Limiting root Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .476
Restricting Access to the NFS Server . . . . . . . . . . . . . . . . . . . . . . . . . . . .476
File Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .476
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .477

30 Centralized Logins Using NIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .479

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .479
Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .480
Configuring the NFS Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .480
Configuring the NFS Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .481
Configuring the NIS Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .483
Edit Your /etc/sysconfig/network File . . . . . . . . . . . . . . . . . . . . . . . . . . .483
Edit Your /etc/yp.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .483
Start the Key NIS Server-Related Daemons . . . . . . . . . . . . . . . . . . . . . .484
Initialize Your NIS Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .485
Start the ypbind and ypxfrd Daemons . . . . . . . . . . . . . . . . . . . . . . . . . . . .486
Make Sure the Daemons Are Running . . . . . . . . . . . . . . . . . . . . . . . . . . .486
Adding New NIS Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .487
Configuring the NIS Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .488
Run authconfig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .488
Start the NIS Client-Related Daemons . . . . . . . . . . . . . . . . . . . . . . . . . .488
Verify Name Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .489
Test NIS Access to the NIS Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .489
Test Logins via the NIS Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .490
NIS Slave Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .491
Configuring NIS Slave Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .491
Configuring NIS Clients with Slaves . . . . . . . . . . . . . . . . . . . . . . . . . . . .495
Changing Your NIS Passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .495
When There Is Only an NIS Master . . . . . . . . . . . . . . . . . . . . . . . . . . . . .495
When There Is a NIS Master and Slave Pair . . . . . . . . . . . . . . . . . . . . . .496
Possible Password Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .496
Contents xxv
00Harrison_FM.qxd 2/25/05 12:39 PM Page xxv
Considerations for a Non-NFS Environment . . . . . . . . . . . . . . . . . . . . . . . .497
NIS Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .497
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .498

31 Centralized Logins Using LDAP and RADIUS . . . . . . . . . . . . . . . . . .499

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .499
The LDAP Directory Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .500
Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .500
Downloading and Installing the LDAP Packages . . . . . . . . . . . . . . . . . . . . .501
Required LDAP Server RPMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .501
Required LDAP Client RPMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .501
Configuring the LDAP Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .501
Create a Database Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .501
Create an LDAP Root Password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .502
Edit the slapd.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .502
Start the ldap Daemon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .502
Convert the /etc/passwd File to LDIF Format . . . . . . . . . . . . . . . . . . . . .503
Modify the LDIF Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .504
Import the LDIF Files into the Database . . . . . . . . . . . . . . . . . . . . . . . . .505
Test the LDAP Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .505
Configuring the LDAP Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .505
Edit the ldap.conf Configuration File . . . . . . . . . . . . . . . . . . . . . . . . . . . .506
Edit the /etc/nsswitch File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .506
Create Home Directories on the LDAP Client . . . . . . . . . . . . . . . . . . . . .506
Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .507
Configuring Encrypted LDAP Communication . . . . . . . . . . . . . . . . . . . . . .508
Configuring the stunnel LDAP Client . . . . . . . . . . . . . . . . . . . . . . . . . . . .508
Configuring the stunnel LDAP Server . . . . . . . . . . . . . . . . . . . . . . . . . . .509
Troubleshooting LDAP Logins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .511
Test Using ldapsearch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .511
Use SSH or the Linux Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .512
Use the tcpdump Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .512
Test Basic Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .513
LDAP Works But Is Not Using LDAPS . . . . . . . . . . . . . . . . . . . . . . . . . .513
stunnel Doesn’t Appear to Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .513
LDAP bind Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .513
Possible stunnel Errors in Fedora Core 2 . . . . . . . . . . . . . . . . . . . . . . . . .513
Common LDAP Administrative Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . .514
Starting and Stopping LDAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .514
LDAP Users Changing Their Own Passwords . . . . . . . . . . . . . . . . . . . . .514
Modifying LDAP Users by User root . . . . . . . . . . . . . . . . . . . . . . . . . . . .515
Adding New LDAP Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .516
Deleting LDAP Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .517
LDAP Web Management Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .517
xxvi Contents
00Harrison_FM.qxd 2/25/05 12:39 PM Page xxvi
Configuring RADIUS for LDAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .517
Download and Install the FreeRADIUS Packages . . . . . . . . . . . . . . . . . .518
Starting and Stopping FreeRADIUS . . . . . . . . . . . . . . . . . . . . . . . . . . . .518
Configuring the /etc/raddb/radiusd.conf File . . . . . . . . . . . . . . . . . . . . .518
Configuring the /etc/raddb/users File . . . . . . . . . . . . . . . . . . . . . . . . . . .519
Configuring the /etc/raddb/clients.conf File . . . . . . . . . . . . . . . . . . . . .520
Troubleshooting and Testing RADIUS . . . . . . . . . . . . . . . . . . . . . . . . . . .520
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .522

32 Controlling Web Access with Squid . . . . . . . . . . . . . . . . . . . . . . . . . . . .523

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .523
Download and Install the Squid Package . . . . . . . . . . . . . . . . . . . . . . . . . . .524
Starting Squid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .524
The /etc/squid/squid.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .524
The Visible Host Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .524
Access Control Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .525
Restricting Web Access by Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .525
Restricting Web Access by IP Address . . . . . . . . . . . . . . . . . . . . . . . . . . .526
Password Authentication Using NCSA . . . . . . . . . . . . . . . . . . . . . . . . . . .526
Forcing Users to Use Your Squid Server . . . . . . . . . . . . . . . . . . . . . . . . . . . .528
Making Your Squid Server Transparent to Users . . . . . . . . . . . . . . . . . .528
Manually Configuring Web Browsers to Use Your Squid Server . . . . . .529
Squid Disk Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .530
Troubleshooting Squid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .530
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .531

33 Modifying the Linux Kernel to Improve Performance . . . . . . . . . . .533

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .533
The Pros and Cons of Kernel Upgrades . . . . . . . . . . . . . . . . . . . . . . . . . .534
Download and Install the Kernel Sources Package . . . . . . . . . . . . . . . . . . .534
Kernel Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .535
Reasons for Kernel Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .535
How Kernel Modules Load When Booting . . . . . . . . . . . . . . . . . . . . . . . .536
Loading Kernel Modules on Demand . . . . . . . . . . . . . . . . . . . . . . . . . . . .537
Creating a Custom Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .539
Make Sure Your Source Files Are in Order . . . . . . . . . . . . . . . . . . . . . . . .539
The .config File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .539
Customizing the .config File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .540
Configure Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .542
Edit the Makefile to Give the Kernel a Unique Name . . . . . . . . . . . . . . .542
Compile a New Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .542
Build the Kernel’s Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .542
Install the Kernel Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .543
Copy the New Kernel to the /boot Partition . . . . . . . . . . . . . . . . . . . . . . .543
Contents xxvii
00Harrison_FM.qxd 2/25/05 12:39 PM Page xxvii
Updating GRUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .544
Kernel Crash Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .544
How to Create a Boot CD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .544
Updating the Kernel Using RPMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .545
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .546

34 Basic MySQL Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .547

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .547
Preparing MySQL for Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .548
Installing MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .548
Starting MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .549
The /etc/my.cnf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .549
The Location of MySQL Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .549
Creating a MySQL Root Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .549
Accessing the MySQL Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . .550
Creating and Deleting MySQL Databases . . . . . . . . . . . . . . . . . . . . . . . . . .550
Granting Privileges to Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .551
Running MySQL Scripts to Create Data Tables . . . . . . . . . . . . . . . . . . . . . .552
Viewing Your New MySQL Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . .552
Listing the Data Tables in Your MySQL Database . . . . . . . . . . . . . . . . .553
Viewing Your MySQL Database’s Table Structure . . . . . . . . . . . . . . . . . .553
Viewing the Contents of a Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .554
Configuring Your Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .554
Recovering and Changing Your MySQL Root Password . . . . . . . . . . . . . . .554
MySQL Database Backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .555
MySQL Database Restoration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .556
Very Basic MySQL Network Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .556
Basic MySQL Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .557
Connectivity Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .557
Test Database Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .557
A Common Fedora Core 1 MySQL Startup Error . . . . . . . . . . . . . . . . . .557
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .558

35 Configuring Linux VPNs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .559

In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .559
VPN Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .560
Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .560
Download and Install the Openswan Package . . . . . . . . . . . . . . . . . . . . . . .561
How to Get Openswan Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .561
Get the Status of the Openswan Installation . . . . . . . . . . . . . . . . . . . . . . . .562
How to Fix Common Status Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .562
VPN Configuration Steps Using RSA Keys . . . . . . . . . . . . . . . . . . . . . . . . .563
The /etc/ipsec.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .563
Obtaining RSA Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .564
Edit the /etc/ipsec.conf Configuration File . . . . . . . . . . . . . . . . . . . . . . .565
Restart Openswan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .566
xxviii Contents
00Harrison_FM.qxd 2/25/05 12:39 PM Page xxviii
Initialize the New Tunnel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .566
Testing the New Tunnel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .567
Possible Changes to IP Tables NAT/Masquerade Rules . . . . . . . . . . . . . . . .567
How to Ensure Openswan Starts When Rebooting . . . . . . . . . . . . . . . . . . .568
Using Pre-Shared Keys (PSK) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .568
Troubleshooting Openswan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .569
Determine the Tunnel Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .569
Testing VPN Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .570
Check the Routes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .571
Using tcpdump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .571
Check syslog Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .572
Invalid Key Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .572
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .573
Appendix I Miscellaneous Linux Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . .575
Fedora Core 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .575
Linux Security with TCP Wrappers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .576
The TCP Wrappers File Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .576
Determining the TCP Daemon’s Name . . . . . . . . . . . . . . . . . . . . . . . . . . .577
Adjusting Kernel Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .577
Running Linux Without a Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .579
Preparing to Go Headless . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .579
Configuration Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .580
Make Your Linux Box Emulate a VT100 Dumb Terminal . . . . . . . . . . . . . .581
Configuration Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .581
VPN Terms and Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .583
Authentication and Encryption Methods . . . . . . . . . . . . . . . . . . . . . . . . .584
Internet Key Exchange (IKE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .584
IKE’s Role in Creating Security Associations . . . . . . . . . . . . . . . . . . . . . .585
VPN Security and Firewalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .586
VPN User Authentication Methods for Temporary Connections . . . . . . .586
TCP/IP Packet Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .587
ICMP Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .588
Appendix II Codes, Scripts, and Configurations . . . . . . . . . . . . . . . . . . . . .591
Apache File Permissions Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .591
sendmail Spam Filter Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .592
The mail-filter.accept File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .593
The mail-filter.reject File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .593
The mail-filter Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .593
iptables Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .598
FTP Client Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .598
FTP Server Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .599
NTP Server Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .600
Home/Small Office Protection Script . . . . . . . . . . . . . . . . . . . . . . . . . . . .600
Contents xxix
00Harrison_FM.qxd 2/25/05 12:39 PM Page xxix
Sample DNS Zone Files: Using BIND Views . . . . . . . . . . . . . . . . . . . . . . . .609
The /etc/named.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .609
Zone File for my-web-site.org (External View) . . . . . . . . . . . . . . . . . . . . .611
Zone File for my-web-site.org (Internal View) . . . . . . . . . . . . . . . . . . . . .611
Reverse Zone File for a Home Network Using NAT . . . . . . . . . . . . . . . . .612
sendmail Samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .613
Sample /etc/mail/access File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .613
Sample /etc/mail/local-host-names File . . . . . . . . . . . . . . . . . . . . . . . . . .613
Sample /etc/mail/sendmail.mc File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .613
Sample /etc/mail/virtusertable File . . . . . . . . . . . . . . . . . . . . . . . . . . . .615
Appendix III Fedora Version Differences . . . . . . . . . . . . . . . . . . . . . . . . . . .617
FTP Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .617
DHCP Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .618
DNS Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .618
Routing Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .619
iptables Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .619
Software Installation Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .619
Wireless Networking Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .620
Linux-WLAN File Locations Using Red Hat 8.0 RPMs . . . . . . . . . . . . . .620
MRTG Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .621
File Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .621
indexmaker MRTG_LIB Errors with Red Hat 9 and 8.0 . . . . . . . . . . . . . .621
Precedence Bitwise Error with Red Hat 9 . . . . . . . . . . . . . . . . . . . . . . . .622
Webalizer Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .622
Appendix IV syslog Configuration and Cisco Devices . . . . . . . . . . . . . . . .623
Cisco Routers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .623
Catalyst CAT Switches Running CATOS . . . . . . . . . . . . . . . . . . . . . . . . . . .623
Cisco Local Director . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .624
Cisco PIX Firewalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .624
Cisco CSS11000 (Arrowpoints) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .625
The Sample Cisco syslog.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .625
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .627

Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook Download Quick Fix Notebook 

Download Quick Fix Notebook

Thanks for your wonderful Support and Encouragement

Ravi Kumar Ankam

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

Leave a Reply

Your email address will not be published. Required fields are marked *