Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Absolute BSD - The Ultimate Guide To FreeBSD (2002).pdf
Скачиваний:
25
Добавлен:
17.08.2013
Размер:
8.15 Mб
Скачать

Absolute BSD—The Ultimate Guide to FreeBSD

Table of Contents

 

Absolute BSD—The Ultimate Guide to FreeBSD............................................................................

1

Dedication..........................................................................................................................................

3

Foreword............................................................................................................................................

4

Introduction........................................................................................................................................

5

What Is FreeBSD?...................................................................................................................

5

How Did FreeBSD Get Here?..................................................................................................

5

The BSD License: BSD Goes Public.......................................................................................

6

The Birth of Modern FreeBSD.................................................................................................

6

FreeBSD Development............................................................................................................

7

Committers.........................................................................................................................

7

Contributors........................................................................................................................

8

Users..................................................................................................................................

8

Other BSDs..............................................................................................................................

8

NetBSD..............................................................................................................................

8

OpenBSD...........................................................................................................................

9

BSD/OS..............................................................................................................................

9

Mac OS X...........................................................................................................................

9

Other UNIXes...........................................................................................................................

9

Solaris................................................................................................................................

9

AIX...................................................................................................................................

10

Linux................................................................................................................................

10

IRIX, HPUX, etc...............................................................................................................

10

FreeBSD's Strengths.............................................................................................................

10

Portability.........................................................................................................................

10

Power...............................................................................................................................

10

Simplified Software Management....................................................................................

11

Optimized Upgrade Process............................................................................................

11

Filesystem........................................................................................................................

11

Who Should Use FreeBSD....................................................................................................

11

FreeBSD as Your Desktop.....................................................................................................

11

Who Should Run Another BSD..............................................................................................

12

Who Should Run a Proprietary Operating System................................................................

12

How to Read This Book.........................................................................................................

13

What Must You Know?..........................................................................................................

13

How to Think About UNIX......................................................................................................

14

Channels of Communication............................................................................................

14

Working with Channels....................................................................................................

14

The Command Line..........................................................................................................

14

Chapter 1: Installation.....................................................................................................................

16

FreeBSD Hardware................................................................................................................

16

Processor.........................................................................................................................

16

Memory (RAM).................................................................................................................

16

Hard Drives......................................................................................................................

16

Downloading FreeBSD..........................................................................................................

17

Installing by FTP..............................................................................................................

18

Other FTP Install Information...........................................................................................

19

i

 

Table of Contents

 

Chapter 1: Installation

 

Hardware Setup.....................................................................................................................

19

Actually Installing FreeBSD...................................................................................................

20

Configuring the Kernel for ISA Cards...............................................................................

21

Sysinstall: The Ugly FreeBSD Installer............................................................................

21

Disk Usage.......................................................................................................................

22

Partitioning.............................................................................................................................

24

Root.......................................................................................................................................

25

Swap Space...........................................................................................................................

25

Swap Splitting..................................................................................................................

26

/var, /usr, and /home..............................................................................................................

26

A Second Hard Drive.............................................................................................................

27

Soft Updates....................................................................................................................

28

Block Size........................................................................................................................

28

What to Install..................................................................................................................

28

Installation Media.............................................................................................................

29

Committing.......................................................................................................................

30

Post−Install Setup..................................................................................................................

30

Root Password.................................................................................................................

30

Adding Users....................................................................................................................

31

Time Zone........................................................................................................................

32

Mouse..............................................................................................................................

32

Configuring Network Cards..............................................................................................

33

Xfree86............................................................................................................................

35

Software...........................................................................................................................

35

Restart...................................................................................................................................

36

A Note on Editors...................................................................................................................

37

Chapter 2: Getting More Help.........................................................................................................

38

Why Not Mail First?................................................................................................................

38

The FreeBSD Attitude............................................................................................................

38

Man Pages.............................................................................................................................

39

The FreeBSD Manual......................................................................................................

40

Man Page Headings.........................................................................................................

41

The FreeBSD Documentation................................................................................................

42

The Mailing List Archives.......................................................................................................

42

Other Web Sites.....................................................................................................................

43

Using FreeBSD Problem−Solving Resources........................................................................

43

Checking the Handbook/FAQ..........................................................................................

43

Checking the Man Pages.................................................................................................

43

Checking the Mailing List Archives..................................................................................

45

Using Your Answer..........................................................................................................

45

Mailing for Help................................................................................................................

45

Chapter 3: Read This Before You Break Something Else! (Backup and Recovery).................

48

Overview................................................................................................................................

48

System Backups....................................................................................................................

48

Tape Devices.........................................................................................................................

49

How to Read Dmesg.boot................................................................................................

49

Controlling Your Tape Drive...................................................................................................

50

ii

 

Table of Contents

 

Chapter 3: Read This Before You Break Something Else! (Backup and Recovery)

 

Device Nodes...................................................................................................................

50

Using the TAPE Variable.................................................................................................

50

The mt Command............................................................................................................

51

Backup Programs..................................................................................................................

52

Tar....................................................................................................................................

52

Dump/Restore..................................................................................................................

55

Restoring from an Archive.....................................................................................................

58

Checking the Contents of an Archive...............................................................................

58

Extracting Data from an Archive......................................................................................

58

Restoring Interactively......................................................................................................

59

Recording What Happened....................................................................................................

60

Revision Control.....................................................................................................................

61

Getting Older Versions.....................................................................................................

63

Breaking Locks.................................................................................................................

64

Viewing Log Messages....................................................................................................

64

Reviewing a File's Revision History.................................................................................

65

Ident and ident Strings.....................................................................................................

65

Going Further...................................................................................................................

66

Single−User Mode.................................................................................................................

66

The Fixit Disk.........................................................................................................................

68

Chapter 4: Kernel Games................................................................................................................

70

Overview................................................................................................................................

70

What Is the Kernel?...............................................................................................................

70

Configuring Your Kernel.........................................................................................................

71

Sysctl................................................................................................................................

71

Changing Sysctls.............................................................................................................

74

Setting Sysctls at Boot.....................................................................................................

74

Kernel Configuration with Loader.conf.............................................................................

75

Manually Configuring the Loader.....................................................................................

77

Loading and Unloading Modules in Multi−User Mode...........................................................

78

Viewing Loaded Modules.................................................................................................

78

Loading and Unloading Modules......................................................................................

79

Customizing the Kernel..........................................................................................................

79

Preparation.......................................................................................................................

79

Your Backup Kernel.........................................................................................................

80

Editing Kernel Files..........................................................................................................

80

Basic Options...................................................................................................................

83

Multiple Processors..........................................................................................................

86

Device Entries..................................................................................................................

86

Building Your Kernel..............................................................................................................

89

Troubleshooting Kernel Builds.........................................................................................

90

Booting an Alternate Kernel...................................................................................................

91

Adding to the Kernel..............................................................................................................

92

LINT.................................................................................................................................

92

Fixing Errors with Options................................................................................................

93

Tweaking Kernel Performance...............................................................................................

94

Sharing Kernels.....................................................................................................................

96

iii

Table of Contents

 

Chapter 5: Networking....................................................................................................................

97

Overview................................................................................................................................

97

Network Layers......................................................................................................................

97

The Physical Layer...........................................................................................................

98

The Physical Protocol Layer............................................................................................

98

The Logical Protocol Layer..............................................................................................

99

The Application Layer....................................................................................................

100

The Network in Practice.......................................................................................................

100

Mbufs.............................................................................................................................

101

What Is a Bit?.................................................................................................................

101

Ethernet...............................................................................................................................

102

Broadcasting..................................................................................................................

103

Address Resolution........................................................................................................

103

Hubs and Switches........................................................................................................

103

Netmasks.......................................................................................................................

104

Netmask Tricks..............................................................................................................

105

Hexadecimal Netmasks.................................................................................................

105

Unusable IP Addresses..................................................................................................

106

Routing...........................................................................................................................

106

UDP and TCP................................................................................................................

107

Network Ports.................................................................................................................

107

Connecting to an Ethernet Network.....................................................................................

108

Multiple IP Addresses on One Interface.........................................................................

110

Using Netstat..................................................................................................................

111

Chapter 6: Upgrading FreeBSD....................................................................................................

116

Overview..............................................................................................................................

116

FreeBSD Versions...............................................................................................................

116

Release..........................................................................................................................

116

FreeBSD−current...........................................................................................................

117

FreeBSD−stable.............................................................................................................

117

Snapshots......................................................................................................................

118

Security Updates............................................................................................................

118

Which Release Should You Use?..................................................................................

119

Upgrade Methods................................................................................................................

119

Upgrading via Sysinstall.................................................................................................

119

Upgrading via CVSup.....................................................................................................

120

Simplifying the CVSup Upgrade Process.......................................................................

130

Building a Local CVSup Server............................................................................................

132

Controlling Access.........................................................................................................

134

Authentication................................................................................................................

135

Combining Authentication and Access...........................................................................

137

Chapter 7: Securing Your System................................................................................................

138

Overview..............................................................................................................................

138

Who Is the Enemy?..............................................................................................................

138

Script Kiddies.................................................................................................................

139

Disaffected Users...........................................................................................................

139

Skilled Attackers.............................................................................................................

139

FreeBSD Security Announcements.....................................................................................

139

iv

 

Table of Contents

 

Chapter 7: Securing Your System

 

Subscribing....................................................................................................................

140

What You'll Get..............................................................................................................

140

Installation Security Profiles.................................................................................................

141

Moderate........................................................................................................................

141

Extreme..........................................................................................................................

141

Root, Groups, and Permissions...........................................................................................

141

The root Password.........................................................................................................

142

Groups of Users.............................................................................................................

142

Primary Group................................................................................................................

143

Some Interesting Default Groups...................................................................................

143

Group Permissions.........................................................................................................

144

Changing Permissions.........................................................................................................

145

Changing File Ownership...............................................................................................

146

Assigning Permissions...................................................................................................

147

File Flags.............................................................................................................................

148

Viewing a File's Flags....................................................................................................

149

Setting Flags..................................................................................................................

149

Securelevels........................................................................................................................

150

Setting Securelevels......................................................................................................

150

Which Securelevel Do You Need?.................................................................................

152

What Won't Securelevel and File Flags Do?..................................................................

152

Living with Securelevels.................................................................................................

153

Programs That Can Be Hacked...........................................................................................

153

Putting It All Together..........................................................................................................

156

Chapter 8: Advanced Security Features......................................................................................

157

Traffic Control......................................................................................................................

157

Default Accept vs. Default Deny....................................................................................

157

TCP Wrappers.....................................................................................................................

158

Configuring Wrappers....................................................................................................

158

Daemon Name...............................................................................................................

158

The Client List................................................................................................................

159

Putting It All Together.....................................................................................................

165

Packet Filtering....................................................................................................................

166

IPFilter............................................................................................................................

166

IPFW..............................................................................................................................

167

Default Accept and Default Deny in Packet Filtering.....................................................

167

Basic Concepts of Packet Filtering................................................................................

167

Implementing IPFilter.....................................................................................................

168

Configuring Your Server to Use Jail...............................................................................

176

Configuring Your Kernel to Use Jail...............................................................................

177

Client Setup....................................................................................................................

178

Final Jail Setup...............................................................................................................

181

Starting the Jail..............................................................................................................

182

Managing Jails...............................................................................................................

182

Shutting Down a Jail......................................................................................................

183

Monitoring System Security.................................................................................................

183

If You're Hacked...................................................................................................................

184

v

Table of Contents

 

Chapter 9: Too Much Information About /etc..............................................................................

185

Overview..............................................................................................................................

185

Varieties of /etc Files............................................................................................................

185

Default Files.........................................................................................................................

185

/etc/defaults/rc.conf........................................................................................................

186

/etc/adduser.conf............................................................................................................

186

/etc/crontab....................................................................................................................

188

/etc/csh.*........................................................................................................................

191

/etc/dhclient.conf............................................................................................................

191

/etc/fstab........................................................................................................................

192

/etc/ftp.*..........................................................................................................................

192

/etc/hosts.allow...............................................................................................................

193

/etc/hosts.equiv..............................................................................................................

193

/etc/hosts.lpd..................................................................................................................

193

/etc/inetd.conf.................................................................................................................

194

/etc/locate.rc...................................................................................................................

194

/etc/login.access.............................................................................................................

194

/etc/login.conf.................................................................................................................

197

Specifying Default Environment Settings.......................................................................

199

/etc/mail/mailer.conf.......................................................................................................

202

/etc/make.conf and /etc/defaults/make.conf...................................................................

202

/etc/master.passwd........................................................................................................

207

/etc/motd........................................................................................................................

208

/etc/mtree/*.....................................................................................................................

208

/etc/namedb/*.................................................................................................................

208

/etc/newsyslog.conf........................................................................................................

208

/etc/passwd....................................................................................................................

209

/etc/periodic.conf and /etc/defaults/periodic.conf...........................................................

209

/etc/printcap....................................................................................................................

210

Working with Printcap Entries........................................................................................

210

/etc/profile.......................................................................................................................

212

/etc/protocols..................................................................................................................

213

/etc/pwd.db.....................................................................................................................

213

/etc/rc.............................................................................................................................

214

/etc/rc.conf and /etc/defaults/rc.conf..............................................................................

215

/etc/resolv.conf...............................................................................................................

221

/etc/security....................................................................................................................

221

/etc/services...................................................................................................................

222

/etc/shells.......................................................................................................................

222

/etc/spwd.db...................................................................................................................

222

/etc/ssh...........................................................................................................................

222

/etc/sysctl.conf................................................................................................................

222

/etc/syslog.conf..............................................................................................................

222

Chapter 10: Making Your System Useful.....................................................................................

223

Overview..............................................................................................................................

223

Making Software..................................................................................................................

223

The Pain and Pleasure of Source Code.........................................................................

224

Debugging......................................................................................................................

225

The Ports and Packages System.........................................................................................

225

vi

 

Table of Contents

 

Chapter 10: Making Your System Useful

 

Ports...............................................................................................................................

225

Finding Software............................................................................................................

227

Legal Restrictions...........................................................................................................

229

Using Packages...................................................................................................................

229

Installing from CD−ROM................................................................................................

230

Installing via FTP............................................................................................................

231

What Does a Package Install?.......................................................................................

232

Uninstalling Packages....................................................................................................

234

Package Information......................................................................................................

234

Controlling Pkg_add.......................................................................................................

235

Package Problems.........................................................................................................

236

Forcing an Install............................................................................................................

237

Using Ports..........................................................................................................................

238

Installing a Port..............................................................................................................

239

Using Make Install..........................................................................................................

239

Built−In Port Features....................................................................................................

240

Uninstalling and Reinstalling..........................................................................................

243

Cleaning Up with Make Clean........................................................................................

244

Building Packages..........................................................................................................

244

Changing the Install Path...............................................................................................

245

Setting Make Options Permanently................................................................................

245

Upgrading Ports and Packages...........................................................................................

245

Upgrading the Ports Collection......................................................................................

246

Ports Collection Upgrade Issues....................................................................................

247

Checking Software Versions..........................................................................................

247

Hints for Upgrading........................................................................................................

248

Chapter 11: Advanced Software Management............................................................................

250

Overview..............................................................................................................................

250

Startup and Shutdown Scripts.............................................................................................

250

Typical Startup Script.....................................................................................................

251

Using Scripts to Manage Running Programs.................................................................

252

Managing Shared Libraries..................................................................................................

252

Ldconfig.........................................................................................................................

253

Running Software from the Wrong OS................................................................................

256

Recompilation................................................................................................................

256

Emulation.......................................................................................................................

257

ABI Implementation........................................................................................................

257

Foreign Software Libraries.............................................................................................

259

Installing and Enabling Linux Mode.....................................................................................

259

Identifying Programs......................................................................................................

260

What Is Linux_base?......................................................................................................

261

Adding to Linux_base.....................................................................................................

261

Configuring Linux Shared Libraries................................................................................

262

Installing Extra Linux Packages as RPMs......................................................................

263

Using Multiple Processors—SMP........................................................................................

263

What Is SMP?................................................................................................................

263

Kernel Assumptions.......................................................................................................

264

FreeBSD 3.0 SMP..........................................................................................................

265

vii

 

Table of Contents

 

Chapter 11: Advanced Software Management

 

FreeBSD 5 SMP.............................................................................................................

265

Using SMP.....................................................................................................................

266

SMP and Upgrades........................................................................................................

266

Chapter 12: Finding Hosts With DNS...........................................................................................

268

How DNS Works..................................................................................................................

268

Basic DNS Tools..................................................................................................................

269

The Host Command.......................................................................................................

269

Getting Detailed Information with Dig.............................................................................

269

Looking Up Hostnames with Dig....................................................................................

271

More Dig Options...........................................................................................................

272

Configuring a DNS Client: The Resolver.............................................................................

273

Domain or Search Keywords.........................................................................................

274

The Nameserver List......................................................................................................

275

DNS Information Sources....................................................................................................

275

The Hosts File................................................................................................................

275

The Named Daemon......................................................................................................

276

Zone Files......................................................................................................................

282

A Real Sample Zone............................................................................................................

286

named.conf....................................................................................................................

286

/var/named/master/absolutebsd.com.............................................................................

286

Making Changes Work.........................................................................................................

288

Starting Named at Boottime.................................................................................................

289

Checking DNS.....................................................................................................................

289

Named Configuration Errors..........................................................................................

290

Named Security...................................................................................................................

290

Controlling Information Order...............................................................................................

291

More About BIND.................................................................................................................

292

Chapter 13: Managing Small Network Services..........................................................................

293

Bandwidth Control................................................................................................................

293

Configuring IPFW...........................................................................................................

294

Reviewing IPFW Rules..................................................................................................

297

Dummynet Queues........................................................................................................

297

Directional Traffic Shaping.............................................................................................

298

Public−Key Encryption.........................................................................................................

298

Certificates.....................................................................................................................

299

Create a Request...........................................................................................................

299

Being Your Own CA.......................................................................................................

302

SSH......................................................................................................................................

303

Testing SSH...................................................................................................................

304

Enabling SSH.................................................................................................................

304

Basics of SSH................................................................................................................

304

Creating Keys.................................................................................................................

304

Confirming SSH Identity.................................................................................................

305

SSH Clients....................................................................................................................

305

Connecting via SSH.......................................................................................................

306

Configuring SSH............................................................................................................

306

System Time........................................................................................................................

309

viii

 

Table of Contents

 

Chapter 13: Managing Small Network Services

 

Setting the Time Zone....................................................................................................

309

Network Time Protocol...................................................................................................

309

Ntpdate..........................................................................................................................

310

Ntpd...............................................................................................................................

310

Inetd.....................................................................................................................................

311

/etc/inetd.conf.................................................................................................................

311

Configuring Programs in Inetd.......................................................................................

312

Inetd Security.................................................................................................................

313

Starting Inetd..................................................................................................................

313

Changing Inetd's Behavior.............................................................................................

314

Chapter 14: Email Services...........................................................................................................

315

Email Overview....................................................................................................................

315

Where FreeBSD Fits In..................................................................................................

315

The Email Protocol.........................................................................................................

315

Email Programs...................................................................................................................

318

Who Needs Sendmail?..................................................................................................

319

Replacing Sendmail.......................................................................................................

319

Installing Postfix.............................................................................................................

319

Pieces of Postfix.............................................................................................................

319

Configuring Postfix.........................................................................................................

320

Email Aliases..................................................................................................................

323

Email Logging................................................................................................................

324

Virtual Domains..............................................................................................................

325

Postfix Commands.........................................................................................................

326

Finding the Correct Mail Host.........................................................................................

326

Undeliverable Mail..........................................................................................................

326

POP3...................................................................................................................................

327

Installing POP3..............................................................................................................

327

Testing POP3.................................................................................................................

327

POP3 Logging................................................................................................................

328

POP3 Modes..................................................................................................................

328

Qpopper Preconfiguration Questions.............................................................................

329

Default Qpopper Configuration......................................................................................

329

APOP Setup...................................................................................................................

332

Configuring Pop3ssl.......................................................................................................

333

Qpopper Security...........................................................................................................

334

Chapter 15: Web and FTP Services.............................................................................................

335

Overview..............................................................................................................................

335

How a Web Server Works....................................................................................................

335

The Apache Web Server......................................................................................................

336

Apache Configuration Files............................................................................................

336

Configuring Apache........................................................................................................

337

Controlling Apache.........................................................................................................

352

Virtual Hosting......................................................................................................................

355

Name−Based Virtual Hosts............................................................................................

356

IP−Based Virtual Hosts..................................................................................................

357

Tweaking Virtual Hosts..................................................................................................

357

ix

 

Table of Contents

 

Chapter 15: Web and FTP Services

 

.NET on FreeBSD................................................................................................................

359

Installing the SSCLI........................................................................................................

359

FTP......................................................................................................................................

360

FTP Security..................................................................................................................

360

The FTP Client...............................................................................................................

360

The FTP Server..............................................................................................................

362

Chapter 16: Filsystems and Disks...............................................................................................

367

Device Nodes.......................................................................................................................

367

Hard Disks and Partitions...............................................................................................

367

The /etc/fstab File................................................................................................................

368

Disk Basics..........................................................................................................................

369

The Fast File System...........................................................................................................

370

Vnodes...........................................................................................................................

371

FFS Mount Types...........................................................................................................

371

FFS Mount Options........................................................................................................

372

What's Mounted Now?.........................................................................................................

373

Dirty Disks............................................................................................................................

373

Fsck................................................................................................................................

373

Mounting and Unmounting Disks.........................................................................................

375

Mounting Standard Filesystems.....................................................................................

375

Mounting with Options....................................................................................................

375

Forcing Read−Write Mounts..........................................................................................

375

Mounting All Standard Filesystems................................................................................

376

Mounting at Nonstandard Locations..............................................................................

376

Unmounting....................................................................................................................

376

Soft Updates........................................................................................................................

376

Enabling Soft Updates...................................................................................................

377

IDE Write Caching and Soft Updates.............................................................................

377

Virtual Memory Directory Caching.......................................................................................

378

Mounting Foreign Filesystems.............................................................................................

378

Using Foreign Mounts....................................................................................................

378

Foreign Filesystem Types..............................................................................................

379

Mount Options and Foreign Filesystems........................................................................

380

Filesystem Permissions.......................................................................................................

380

Removable Media and /etc/fstab.........................................................................................

381

Creating a Floppy.................................................................................................................

381

Low−Level Formatting....................................................................................................

381

Creating an FFS Filesystem...........................................................................................

381

Creating an MS−DOS Filesystem..................................................................................

382

The Basics of SCSI..............................................................................................................

382

SCSI Types....................................................................................................................

383

SCSI Adapters...............................................................................................................

383

SCSI Buses....................................................................................................................

383

Termination and Cabling................................................................................................

383

SCSI IDs and LUNs.......................................................................................................

384

FreeBSD and SCSI..............................................................................................................

384

Boot−Time Delay...........................................................................................................

384

Wiring Down Devices.....................................................................................................

385

x

 

Table of Contents

 

Chapter 16: Filsystems and Disks

 

Adding New Hard Disks.......................................................................................................

386

Creating Slices...............................................................................................................

386

Creating Partitions..........................................................................................................

387

Configuring /etc/fstab.....................................................................................................

388

Installing Existing Files onto New Disks.........................................................................

388

Temporary Mounts.........................................................................................................

388

Moving Files...................................................................................................................

389

Stackable Mounts...........................................................................................................

389

Chapter 17: RAID...........................................................................................................................

391

Hardware vs. Software RAID...............................................................................................

391

RAID Levels.........................................................................................................................

391

Software RAID.....................................................................................................................

392

Vinum Disk Components................................................................................................

392

Vinum Plex Types..........................................................................................................

393

RAID−5 Plex..................................................................................................................

393

Preparing Vinum Drives.................................................................................................

393

Dedicating Partitions to Vinum.......................................................................................

394

Configuring Vinum..........................................................................................................

395

Concatenated Plex.........................................................................................................

396

Removing Vinum Configuration.....................................................................................

398

Striped Volumes.............................................................................................................

399

Mirrored Volumes...........................................................................................................

400

Starting Vinum at Boot...................................................................................................

401

Other Vinum Commands................................................................................................

402

Replacing a Failed Mirrored Plex...................................................................................

402

Chapter 18: System Performance................................................................................................

406

Overview..............................................................................................................................

406

Computer Resources...........................................................................................................

406

Disk Input/Output.................................................................................................................

407

Network Bandwidth..............................................................................................................

407

CPU and Memory................................................................................................................

407

Using Top.......................................................................................................................

408

Memory Usage...............................................................................................................

411

Swap Space Usage........................................................................................................

411

CPU Usage....................................................................................................................

412

When Swap Goes Bad.........................................................................................................

414

Paging............................................................................................................................

414

Swapping.......................................................................................................................

415

Are You Swapping or Paging?.......................................................................................

415

Real−World Performance Tuning.........................................................................................

418

Fairness in Benchmarking..............................................................................................

418

The Initial Test................................................................................................................

418

Using Both CPUs...........................................................................................................

420

Directory Caching...........................................................................................................

421

Moving /usr/obj...............................................................................................................

421

Lessons Learned.................................................................................................................

423

xi

Table of Contents

 

Chapter 19: Now What's It Doing?...............................................................................................

424

Status Mails.........................................................................................................................

424

Forwarding Reports........................................................................................................

424

Logging with Syslogd...........................................................................................................

424

Facilities.........................................................................................................................

424

Levels.............................................................................................................................

425

Syslog.conf.....................................................................................................................

426

Wildcards.......................................................................................................................

426

Rotating Logs with Newsyslog.conf...............................................................................

429

Reporting with SNMP...........................................................................................................

433

Basics of SNMP.............................................................................................................

433

MIBs...............................................................................................................................

433

Net−snmp.......................................................................................................................

434

Snmpwalk.......................................................................................................................

435

Specific Snmpwalk Queries...........................................................................................

435

Translating Between Numbers and Names...................................................................

436

Setting Up Snmpd..........................................................................................................

437

Index Numbers...............................................................................................................

441

Long−Term Monitoring with MRTG......................................................................................

441

Configuring MRTG.........................................................................................................

442

Sample mrtg.cfg Entry....................................................................................................

442

Testing MRTG................................................................................................................

444

Tracking Other System Values......................................................................................

445

Useful Net−snmp MIBs..................................................................................................

445

Monitoring a Single MIB.................................................................................................

446

Customizing MRTG........................................................................................................

447

MRTG Index Page.........................................................................................................

448

Sample MRTG Configurations.......................................................................................

448

Monitoring Non−BSD Systems......................................................................................

450

Chapter 20: System Crashes and Panics....................................................................................

452

What Causes Panics?..........................................................................................................

452

What Does a Panic Look Like?......................................................................................

452

Responding to a Panic.........................................................................................................

453

Prerequisites..................................................................................................................

454

Crash Dump Process.....................................................................................................

454

The Debugging Kernel...................................................................................................

454

Post−Panic Behavior......................................................................................................

455

kernel.debug..................................................................................................................

455

Dumpon..........................................................................................................................

456

Savecore........................................................................................................................

456

Upon a Crash.................................................................................................................

456

Dumps and Bad Kernels................................................................................................

456

Using the Dump...................................................................................................................

457

Advanced Kernel Debugging.........................................................................................

459

Examining Lines.............................................................................................................

460

Examining Variables......................................................................................................

460

Apparent Gdb Weirdness...............................................................................................

462

Results...........................................................................................................................

462

Vmcore and Security......................................................................................................

463

xii

 

Table of Contents

 

Chapter 20: System Crashes and Panics

 

Symbols vs. No Symbols...............................................................................................

463

Serial Consoles....................................................................................................................

465

Hardware Serial Console...............................................................................................

465

Software Serial Console.................................................................................................

465

Changing the Configuration...........................................................................................

466

Using a Serial Console...................................................................................................

467

Serial Login....................................................................................................................

469

Emergency Logon Setup................................................................................................

469

Disconnecting the Serial Console..................................................................................

470

Submitting a Problem Report...............................................................................................

471

Problem Report System.................................................................................................

471

What's in a PR?.............................................................................................................

471

Using Send−pr...............................................................................................................

471

Filling Out the Form........................................................................................................

472

PR Results.....................................................................................................................

474

Chapter 21: Desktop FreeBSD......................................................................................................

475

Overview..............................................................................................................................

475

Accessing File Shares.........................................................................................................

475

Prerequisites..................................................................................................................

475

Character Sets...............................................................................................................

476

Kernel Support for CIFS.................................................................................................

476

SMB Tools......................................................................................................................

476

Configuring CIFS............................................................................................................

476

Minimum Configuration: Name Resolution.....................................................................

478

Other smbutil Functions.................................................................................................

478

Mounting a Share...........................................................................................................

479

Other mount_smbfs Options..........................................................................................

480

Sample nsmb.conf Entries.............................................................................................

480

CIFS File Ownership......................................................................................................

481

Serving Windows File Shares..............................................................................................

481

Accessing Print Servers.......................................................................................................

482

Lpd.................................................................................................................................

482

Running a Local Lpd......................................................................................................

483

Printer Testing................................................................................................................

483

Local Printers.......................................................................................................................

484

X: A Graphic Interface..........................................................................................................

484

X Prerequisites...............................................................................................................

484

X Versions......................................................................................................................

484

Configuring X.................................................................................................................

485

Making X Look Decent...................................................................................................

485

Desktop Applications...........................................................................................................

486

Web Browsers................................................................................................................

486

Email Readers................................................................................................................

486

Office Suites...................................................................................................................

487

Music..............................................................................................................................

488

Graphics.........................................................................................................................

488

Desk Utilities..................................................................................................................

488

Games............................................................................................................................

489

xiii

 

Table of Contents

 

Afterword........................................................................................................................................

491

Overview..............................................................................................................................

491

The Community....................................................................................................................

491

What Can You Do?..............................................................................................................

492

If Nothing Else …...........................................................................................................492

Getting Things Done............................................................................................................

493

Second Opinions............................................................................................................

493

Do It!....................................................................................................................................

494

Appendix: Some Useful SYSCTL MIBs........................................................................................

495

List of Figures................................................................................................................................

507

Chapter 1: Installation..........................................................................................................

507

Chapter 5: Networking.........................................................................................................

507

Chapter 6: Upgrading FreeBSD...........................................................................................

507

Chapter 19: Now What's It Doing?.......................................................................................

507

List of Tables..................................................................................................................................

508

Chapter 4: Kernel Games....................................................................................................

508

Chapter 5: Networking.........................................................................................................

508

Chapter 8: Advanced Security Features..............................................................................

508

Chapter 9: Too Much Information About /etc.......................................................................

508

List of Sidebars..............................................................................................................................

509

Chapter 15: Web and FTP Services....................................................................................

509

xiv

Absolute BSD—The Ultimate Guide to FreeBSD

Michael Lucas

NO STARCH PRESS San Francisco

Copyright © 2002 Michael Lucas

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.

1 2 3 4 5 6 7 8 9 10–05 04 03 02

No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.

Publisher: William Pollock

Editorial Director: Karol Jurado

Cover and Interior Design: Octopod Studios

Composition: 1106 Design, LLC

Copyeditor: Andy Carroll

Proofreader: Robyn Brode

Indexer: Kevin Broccoli

Distributed to the book trade in the United States by Publishers Group West, 1700 Fourth Street, Berkeley, CA 94710; phone: 800−788−3123; fax: 510−658−1834.

Distributed to the book trade in Canada by Jacqueline Gross & Associates, Inc., One Atlantic Avenue, Suite 105, Toronto, Ontario M6K 3E7 Canada; phone: 416−531−6737; fax 416−531−4259.

For information on translations or book distributors outside the United States, please contact No Starch Press, Inc. directly:

No Starch Press, Inc.

555 De Haro Street, Suite 250, San Francisco, CA 94107

phone: 415−863−9900; fax: 415−863−9950; info@nostarch.com; http://www.nostarch.com/

The information in this book is distributed on an "As Is" basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it.

Library of Congress Cataloguing−in−Publication Data

Lucas, Michael, 1967−

Absolute BSD : the ultimate guide to FreeBSD / Michael Lucas.

p. cm.

1

Includes index.

1−886411−74−3 (pbk.)

1. FreeBSD. 2. UNIX (Computer file) 3. Internet service

providers−−Computer programs. 4. Web servers−−Computer programs. 5.

Client/server computing. I. Title.

QA76.76.O63 L83 2002

005.4'4769−−dc21

2