Linux Network Administrators Guide LinuxNetworkAdministratorsGuide Table of Contents Preface.....................................................................................................................................................xiv 1.PurposeandAudienceforThisBook..........................................................................................xv 2.SourcesofInformation.................................................................................................................xv 2.1.DocumentationAvailableviaFTP..................................................................................xvi 2.2.DocumentationAvailableviaWWW...........................................................................xvii 2.3.DocumentationAvailableCommercially.....................................................................xvii 2.4.LinuxJournalandLinuxMagazine.............................................................................xviii 2.5.LinuxUsenetNewsgroups...........................................................................................xviii 2.6.LinuxMailingLists........................................................................................................xix 2.7.OnlineLinuxSupport......................................................................................................xx 2.8.LinuxUserGroups..........................................................................................................xx 2.9.ObtainingLinux...............................................................................................................xx 3.FileSystemStandards...............................................................................................................xxii 4.StandardLinuxBase.................................................................................................................xxii 5.AboutThisBook......................................................................................................................xxiii 6.TheOfficialPrintedVersion......................................................................................................xxiv 7.Overview....................................................................................................................................xxv 8.ConventionsUsedinThisBook..............................................................................................xxvii 9.SubmittingChanges...............................................................................................................xxviii 10.Acknowledgments................................................................................................................xxviii 10.1.TheHallofFame........................................................................................................xxix 1.IntroductiontoNetworking..................................................................................................................1 1.1.History.........................................................................................................................................1 1.2.TCP/IPNetworks........................................................................................................................1 1.2.1.IntroductiontoTCP/IPNetworks...................................................................................2 1.2.2.Ethernets.........................................................................................................................3 1.2.3.OtherTypesofHardware...............................................................................................5 1.2.4.TheInternetProtocol......................................................................................................6 1.2.5.IPOverSerialLines.......................................................................................................8 1.2.6.TheTransmissionControlProtocol................................................................................8 1.2.7.TheUserDatagramProtocol..........................................................................................9 1.2.8.MoreonPorts.................................................................................................................9 1.2.9.TheSocketLibrary.......................................................................................................10 1.3.UUCPNetworks........................................................................................................................10 1.4.LinuxNetworking.....................................................................................................................11 1.4.1.DifferentStreaksofDevelopment................................................................................12 1.4.2.WheretoGettheCode.................................................................................................13 1.5.MaintainingYourSystem..........................................................................................................13 1.5.1.SystemSecurity............................................................................................................13 2.IssuesofTCP/IPNetworking.............................................................................................................16 2.1.NetworkingInterfaces...............................................................................................................16 2.2.IPAddresses..............................................................................................................................16 2.3.AddressResolution...................................................................................................................18 2.4.IPRouting.................................................................................................................................19 2.4.1.IPNetworks..................................................................................................................19 iii 2.4.2.Subnetworks.................................................................................................................19 2.4.3.Gateways......................................................................................................................21 2.4.4.TheRoutingTable........................................................................................................23 2.4.5.MetricValues................................................................................................................24 2.5.TheInternetControlMessageProtocol....................................................................................25 2.6.ResolvingHostNames..............................................................................................................25 3.ConfiguringtheNetworkingHardware...............................................................................................28 3.1.KernelConfiguration.................................................................................................................30 3.1.1.KernelOptionsinLinux2.0andHigher......................................................................31 3.1.2.KernelNetworkingOptionsinLinux2.0.0andHigher...............................................34 3.2.ATourofLinuxNetworkDevices............................................................................................37 3.3.EthernetInstallation..................................................................................................................38 3.3.1.EthernetAutoprobing...................................................................................................39 3.4.ThePLIPDriver........................................................................................................................41 3.5.ThePPPandSLIPDrivers........................................................................................................43 3.6.OtherNetworkTypes................................................................................................................43 4.ConfiguringtheSerialHardware.......................................................................................................45 4.1.CommunicationsSoftwareforModemLinks...........................................................................45 4.2.IntroductiontoSerialDevices...................................................................................................46 4.3.AccessingSerialDevices..........................................................................................................46 4.3.1.TheSerialDeviceSpecialFiles....................................................................................48 4.4.SerialHardware.........................................................................................................................49 4.5.UsingtheConfigurationUtilities..............................................................................................50 4.5.1.ThesetserialCommand................................................................................................50 4.5.2.ThesttyCommand.......................................................................................................61 4.6.SerialDevicesandthelogin:Prompt........................................................................................69 4.6.1.ConfiguringthemgettyDaemon..................................................................................70 5.ConfiguringTCP/IPNetworking.......................................................................................................73 5.1.Mountingthe/procFilesystem.................................................................................................73 5.2.InstallingtheBinaries...............................................................................................................74 5.3.SettingtheHostname................................................................................................................74 5.4.AssigningIPAddresses............................................................................................................75 5.5.CreatingSubnets.......................................................................................................................76 5.6.WritinghostsandnetworksFiles..............................................................................................76 5.7.InterfaceConfigurationforIP...................................................................................................78 5.7.1.TheLoopbackInterface................................................................................................78 5.7.2.EthernetInterfaces........................................................................................................80 5.7.3.RoutingThroughaGateway.........................................................................................82 5.7.4.ConfiguringaGateway.................................................................................................83 5.7.5.ThePLIPInterface.......................................................................................................84 5.7.6.TheSLIPandPPPInterfaces.......................................................................................85 5.7.7.TheDummyInterface...................................................................................................85 5.7.8.IPAlias.........................................................................................................................86 5.8.AllAboutifconfig.....................................................................................................................86 5.9.ThenetstatCommand...............................................................................................................89 5.9.1.DisplayingtheRoutingTable.......................................................................................89 5.9.2.DisplayingInterfaceStatistics......................................................................................91 iv 5.9.3.DisplayingConnections................................................................................................92 5.10.CheckingtheARPTables.......................................................................................................92 6.NameServiceandResolverConfiguration........................................................................................96 6.1.TheResolverLibrary................................................................................................................96 6.1.1.Thehost.confFile.........................................................................................................96 6.1.2.Thensswitch.confFile..................................................................................................98 6.1.3.ConfiguringNameServerLookupsUsingresolv.conf...............................................101 6.1.4.ResolverRobustness...................................................................................................103 6.2.HowDNSWorks.....................................................................................................................103 6.2.1.NameLookupswithDNS..........................................................................................109 6.2.2.TypesofNameServers...............................................................................................110 6.2.3.TheDNSDatabase.....................................................................................................111 6.2.4.ReverseLookups........................................................................................................113 6.3.Runningnamed.......................................................................................................................114 6.3.1.Thenamed.bootFile...................................................................................................115 6.3.2.TheBIND8host.confFile.........................................................................................117 6.3.3.TheDNSDatabaseFiles............................................................................................118 6.3.4.Caching-onlynamedConfiguration...........................................................................122 6.3.5.WritingtheMasterFiles.............................................................................................123 6.3.6.VerifyingtheNameServerSetup...............................................................................125 6.3.7.OtherUsefulTools......................................................................................................128 7.SerialLineIP......................................................................................................................................130 7.1.GeneralRequirements.............................................................................................................130 7.2.SLIPOperation.......................................................................................................................130 7.3.DealingwithPrivateIPNetworks...........................................................................................137 7.4.Usingdip.................................................................................................................................137 7.4.1.ASampleScript..........................................................................................................138 7.4.2.AdipReference..........................................................................................................139 7.5.RunninginServerMode.........................................................................................................143 8.ThePoint-to-PointProtocol..............................................................................................................154 8.1.PPPonLinux..........................................................................................................................154 8.2.Runningpppd..........................................................................................................................155 8.3.UsingOptionsFiles.................................................................................................................156 8.4.UsingchattoAutomateDialing..............................................................................................157 8.5.IPConfigurationOptions........................................................................................................160 8.5.1.ChoosingIPAddresses...............................................................................................160 8.5.2.RoutingThroughaPPPLink.....................................................................................161 8.6.LinkControlOptions..............................................................................................................165 8.7.GeneralSecurityConsiderations.............................................................................................167 8.8.AuthenticationwithPPP.........................................................................................................167 8.8.1.PAPVersusCHAP......................................................................................................168 8.8.2.TheCHAPSecretsFile..............................................................................................169 8.8.3.ThePAPSecretsFile..................................................................................................170 8.9.DebuggingYourPPPSetup....................................................................................................171 8.10.MoreAdvancedPPPConfigurations....................................................................................172 8.10.1.PPPServer................................................................................................................172 8.10.2.DemandDialing........................................................................................................173 v 8.10.3.PersistentDialing......................................................................................................179 9.TCP/IPFirewall.................................................................................................................................181 9.1.MethodsofAttack...................................................................................................................181 9.2.WhatIsaFirewall?.................................................................................................................183 9.3.WhatIsIPFiltering?...............................................................................................................184 9.4.SettingUpLinuxforFirewalling............................................................................................185 9.4.1.KernelConfiguredwithIPFirewall...........................................................................185 9.4.2.TheipfwadmUtility...................................................................................................186 9.4.3.TheipchainsUtility....................................................................................................186 9.4.4.TheiptablesUtility.....................................................................................................187 9.5.ThreeWaysWeCanDoFiltering...........................................................................................187 9.6.OriginalIPFirewall(2.0Kernels)...........................................................................................189 9.6.1.Usingipfwadm...........................................................................................................189 9.6.2.AMoreComplexExample.........................................................................................192 9.6.3.SummaryofipfwadmArguments..............................................................................193 9.7.IPFirewallChains(2.2Kernels).............................................................................................197 9.7.1.Usingipchains............................................................................................................198 9.7.2.ipchainsCommandSyntax.........................................................................................198 9.7.3.OurNaïveExampleRevisited....................................................................................202 9.7.4.ListingOurRuleswithipchains.................................................................................203 9.7.5.MakingGoodUseofChains......................................................................................203 9.8.NetfilterandIPTables(2.4Kernels).......................................................................................208 9.8.1.BackwardCompatabilitywithipfwadmandipchains.................................................211 9.8.2.Usingiptables.............................................................................................................211 9.8.3.OurNaïveExampleRevisited,YetAgain..................................................................216 9.9.TOSBitManipulation.............................................................................................................217 9.9.1.SettingtheTOSBitsUsingipfwadmoripchains.......................................................218 9.9.2.SettingtheTOSBitsUsingiptables...........................................................................219 9.10.TestingaFirewallConfiguration...........................................................................................220 9.11.ASampleFirewallConfiguration.........................................................................................222 10.IPAccounting...................................................................................................................................229 10.1.ConfiguringtheKernelforIPAccounting............................................................................229 10.2.ConfiguringIPAccounting...................................................................................................229 10.2.1.AccountingbyAddress............................................................................................230 10.2.2.AccountingbyServicePort......................................................................................232 10.2.3.AccountingofICMPDatagrams..............................................................................235 10.2.4.AccountingbyProtocol............................................................................................236 10.3.UsingIPAccountingResults................................................................................................236 10.3.1.ListingAccountingDatawithipfwadm...................................................................237 10.3.2.ListingAccountingDatawithipchains....................................................................237 10.3.3.ListingAccountingDatawithiptables.....................................................................238 10.4.ResettingtheCounters..........................................................................................................238 10.5.FlushingtheRuleset..............................................................................................................239 10.6.PassiveCollectionofAccountingData.................................................................................239 vi 11.IPMasqueradeandNetworkAddressTranslation......................................................................241 11.1.SideEffectsandFringeBenefits...........................................................................................242 11.2.ConfiguringtheKernelforIPMasquerade...........................................................................243 11.3.ConfiguringIPMasquerade..................................................................................................244 11.3.1.SettingTimingParametersforIPMasquerade.........................................................246 11.4.HandlingNameServerLookups...........................................................................................249 11.5.MoreAboutNetworkAddressTranslation...........................................................................250 12.ImportantNetworkFeatures...........................................................................................................251 12.1.TheinetdSuperServer..........................................................................................................251 12.2.ThetcpdAccessControlFacility..........................................................................................253 12.3.TheServicesandProtocolsFiles..........................................................................................255 12.4.RemoteProcedureCall.........................................................................................................257 12.5.ConfiguringRemoteLoginandExecution............................................................................258 12.5.1.Disablingther;Commands......................................................................................259 12.5.2.InstallingandConfiguringssh..................................................................................259 13.TheNetworkInformationSystem..................................................................................................267 13.1.GettingAcquaintedwithNIS................................................................................................268 13.2.NISVersusNIS+...................................................................................................................270 13.3.TheClientSideofNIS..........................................................................................................270 13.4.RunninganNISServer.........................................................................................................271 13.5.NISServerSecurity...............................................................................................................272 13.6.SettingUpanNISClientwithGNUlibc..............................................................................273 13.7.ChoosingtheRightMaps......................................................................................................275 13.8.UsingthepasswdandgroupMaps.......................................................................................277 13.9.UsingNISwithShadowSupport..........................................................................................279 14.TheNetworkFileSystem.................................................................................................................282 14.1.PreparingNFS.......................................................................................................................283 14.2.MountinganNFSVolume....................................................................................................283 14.3.TheNFSDaemons................................................................................................................286 14.4.TheexportsFile.....................................................................................................................287 14.5.Kernel-BasedNFSv2ServerSupport...................................................................................289 14.6.Kernel-BasedNFSv3ServerSupport...................................................................................289 15.IPXandtheNCPFilesystem..........................................................................................................291 15.1.Xerox,Novell,andHistory...................................................................................................291 15.2.IPXandLinux.......................................................................................................................292 15.2.1.CalderaSupport........................................................................................................292 15.2.2.MoreonNDSSupport..............................................................................................293 15.3.ConfiguringtheKernelforIPXandNCPFS..........................................................................293 15.4.ConfiguringIPXInterfaces...................................................................................................294 15.4.1.NetworkDevicesSupportingIPX............................................................................294 15.4.2.IPXInterfaceConfigurationTools...........................................................................294 15.4.3.Theipx_configureCommand...................................................................................294 15.4.4.Theipx_interfaceCommand....................................................................................296 15.5.ConfiguringanIPXRouter...................................................................................................297 15.5.1.StaticIPXRoutingUsingtheipx_routeCommand.................................................298 15.5.2.InternalIPXNetworksandRouting.........................................................................298 vii 15.6.MountingaRemoteNetWareVolume..................................................................................300 15.6.1.ASimplencpmountExample...................................................................................301 15.6.2.ThencpmountCommandinDetail..........................................................................301 15.6.3.HidingYourNetWareLoginPassword....................................................................313 15.6.4.AMoreComplexncpmountExample......................................................................313 15.7.ExploringSomeoftheOtherIPXTools...............................................................................314 15.7.1.ServerList................................................................................................................314 15.7.2.SendMessagestoNetWareUsers............................................................................314 15.7.3.BrowsingandManipulatingBinderyData...............................................................315 15.8.PrintingtoaNetWarePrintQueue........................................................................................319 15.8.1.UsingnprintwiththeLinePrinterDaemon.............................................................323 15.8.2.ManagingPrintQueues............................................................................................325 15.9.NetWareServerEmulation....................................................................................................326 16.ManagingTaylorUUCP...................................................................................................................327 16.1.UUCPTransfersandRemoteExecution...............................................................................328 16.1.1.TheInnerWorkingsofuucico..................................................................................329 16.1.2.uucicoCommand-lineOptions.................................................................................330 16.2.UUCPConfigurationFiles....................................................................................................331 16.2.1.AGentleIntroductiontoTaylorUUCP....................................................................331 16.2.2.WhatUUCPNeedstoKnow....................................................................................334 16.2.3.SiteNaming..............................................................................................................335 16.2.4.TaylorConfigurationFiles........................................................................................335 16.2.5.GeneralConfigurationOptionsUsingtheconfigFile..............................................336 16.2.6.HowtoTellUUCPAboutOtherSystemsUsingthesysFile..................................337 16.2.7.IdentifyingAvailableDevicesThroughtheportFile...............................................342 16.2.8.HowtoDialaNumberUsingthedialFile...............................................................343 16.2.9.UUCPOverTCP......................................................................................................344 16.2.10.UsingaDirectConnection.....................................................................................345 16.3.ControllingAccesstoUUCPFeatures..................................................................................346 16.3.1.CommandExecution................................................................................................346 16.3.2.FileTransfers............................................................................................................346 16.3.3.Forwarding................................................................................................................347 16.4.SettingUpYourSystemforDialingIn.................................................................................348 16.4.1.ProvidingUUCPAccounts.......................................................................................348 16.4.2.ProtectingYourselfAgainstSwindlers.....................................................................349 16.4.3.BeParanoid:CallSequenceChecks.........................................................................350 16.4.4.AnonymousUUCP...................................................................................................351 16.5.UUCPLow-LevelProtocols.................................................................................................351 16.5.1.ProtocolOverview....................................................................................................352 16.5.2.TuningtheTransmissionProtocol............................................................................353 16.5.3.SelectingSpecificProtocols.....................................................................................354 16.6.Troubleshooting....................................................................................................................354 16.6.1.uucicoKeepsSaying“WrongTimetoCall”............................................................355 16.6.2.uucicoComplainsThattheSiteIsAlreadyLocked.................................................355 16.6.3.YouCanConnecttotheRemoteSite,buttheChatScriptFails..............................355 16.6.4.YourModemDoesNotDial.....................................................................................355 16.6.5.YourModemTriestoDialbutDoesn’tGetOut......................................................355 viii 16.6.6.LoginSucceeds,buttheHandshakeFails................................................................356 16.7.LogFilesandDebugging......................................................................................................356 17.ElectronicMail.................................................................................................................................359 17.1.WhatIsaMailMessage?......................................................................................................360 17.2.HowIsMailDelivered?........................................................................................................362 17.3.EmailAddresses....................................................................................................................363 17.3.1.RFC-822...................................................................................................................363 17.3.2.ObsoleteMailFormats.............................................................................................363 17.3.3.MixingDifferentMailFormats................................................................................364 17.4.HowDoesMailRoutingWork?............................................................................................365 17.4.1.MailRoutingontheInternet....................................................................................365 17.4.2.MailRoutingintheUUCPWorld............................................................................366 17.4.3.MixingUUCPandRFC-822....................................................................................367 17.5.Configuringelm....................................................................................................................370 17.5.1.GlobalelmOptions...................................................................................................371 17.5.2.NationalCharacterSets............................................................................................371 18.Sendmail...........................................................................................................................................374 18.1.Introductiontosendmail.......................................................................................................374 18.2.Installingsendmail................................................................................................................374 18.3.OverviewofConfigurationFiles...........................................................................................375 18.4.Thesendmail.cfandsendmail.mcFiles................................................................................375 18.4.1.TwoExamplesendmail.mcFiles..............................................................................376 18.4.2.TypicallyUsedsendmail.mcParameters..................................................................377 18.5.Generatingthesendmail.cfFile............................................................................................381 18.6.InterpretingandWritingRewriteRules................................................................................381 18.6.1.sendmail.cfRandSCommands...............................................................................382 18.6.2.SomeUsefulMacroDefinitions...............................................................................382 18.6.3.TheLefthandSide....................................................................................................382 18.6.4.TheRighthandSide..................................................................................................383 18.6.5.ASimpleRulePatternExample...............................................................................384 18.6.6.RulesetSemantics.....................................................................................................385 18.7.ConfiguringsendmailOptions..............................................................................................387 18.8.SomeUsefulsendmailConfigurations..................................................................................389 18.8.1.TrustingUserstoSettheFrom:Field......................................................................389 18.8.2.ManagingMailAliases.............................................................................................389 18.8.3.UsingaSmartHost...................................................................................................390 18.8.4.ManagingUnwantedorUnsolicitedMail(Spam)...................................................392 18.8.5.ConfiguringVirtualEmailHosting..........................................................................395 18.9.TestingYourConfiguration...................................................................................................397 18.10.Runningsendmail...............................................................................................................401 18.11.TipsandTricks....................................................................................................................402 18.11.1.ManagingtheMailSpool.......................................................................................402 18.11.2.ForcingaRemoteHosttoProcessitsMailQueue.................................................403 18.11.3.AnalyzingMailStatistics.......................................................................................403 ix 19.GettingEximUpandRunning........................................................................................................406 19.1.RunningExim.......................................................................................................................407 19.2.IfYourMailDoesn’tGetThrough........................................................................................408 19.3.CompilingExim....................................................................................................................409 19.4.MailDeliveryModes............................................................................................................410 19.5.MiscellaneousconfigOptions...............................................................................................411 19.6.MessageRoutingandDelivery.............................................................................................412 19.6.1.RoutingMessages.....................................................................................................412 19.6.2.DeliveringMessagestoLocalAddresses.................................................................413 19.6.3.AliasFiles.................................................................................................................414 19.6.4.MailingLists.............................................................................................................415 19.7.ProtectingAgainstMailSpam..............................................................................................416 19.8.UUCPSetup..........................................................................................................................417 20.Netnews.............................................................................................................................................419 20.1.UsenetHistory.......................................................................................................................419 20.2.WhatIsUsenet,Anyway?.....................................................................................................420 20.3.HowDoesUsenetHandleNews?.........................................................................................421 21.CNews..............................................................................................................................................424 21.1.DeliveringNews....................................................................................................................424 21.2.Installation.............................................................................................................................425 21.3.ThesysFile...........................................................................................................................427 21.4.TheactiveFile.......................................................................................................................431 21.5.ArticleBatching....................................................................................................................432 21.6.ExpiringNews.......................................................................................................................435 21.7.MiscellaneousFiles...............................................................................................................437 21.8.ControlMessages..................................................................................................................438 21.8.1.ThecancelMessage..................................................................................................439 21.8.2.newgroupandrmgroup.............................................................................................439 21.8.3.ThecheckgroupsMessage........................................................................................439 21.8.4.sendsys,version,andsenduuname...........................................................................441 21.9.CNewsinanNFSEnvironment...........................................................................................441 21.10.MaintenanceToolsandTasks.............................................................................................442 22.NNTPandthenntpdDaemon.........................................................................................................445 22.1.TheNNTPProtocol..............................................................................................................446 22.1.1.ConnectingtotheNewsServer................................................................................446 22.1.2.PushingaNewsArticleontoaServer......................................................................447 22.1.3.ChangingtoNNRPReaderMode............................................................................448 22.1.4.ListingAvailableGroups..........................................................................................449 22.1.5.ListingActiveGroups..............................................................................................449 22.1.6.PostinganArticle.....................................................................................................449 22.1.7.ListingNewArticles.................................................................................................450 22.1.8.SelectingaGrouponWhichtoOperate...................................................................450 22.1.9.ListingArticlesinaGroup.......................................................................................451 22.1.10.RetrievinganArticleHeaderOnly.........................................................................451 22.1.11.RetrievinganArticleBodyOnly............................................................................452 22.1.12.ReadinganArticlefromaGroup...........................................................................452 x
Description: