为了正常的体验网站,请在浏览器设置里面开启Javascript功能!
首页 > Ubuntuserver环境Bind9安装设置指南

Ubuntuserver环境Bind9安装设置指南

2018-06-15 9页 pdf 503KB 1阅读

用户头像 个人认证

招财进宝

暂无简介

举报
Ubuntuserver环境Bind9安装设置指南Bind9安装设置指南你可以免费:拷贝、分发、呈现和表演当前作品制作派生作品是必须基于以下条款:署名。你必须明确标明作者的名字。.非商业用途。你不可将当前作品用于商业目的。保持一致。如果你基于当前作品更改、变换或构造新作品,你应当按照与当前协议完全相同的协议分发最终作品。对于任何二次使用或分发,你必须让其他人明确当前作品的授权条款在得到作者的明确允许下,这里的某些条款可以放弃目录[隐藏]1HOWTOSetupBIND9DNSServer(如何安装设置Bind9DNS服务器)o1.1Repositories软件库o1....
Ubuntuserver环境Bind9安装设置指南
Bind9安装设置指南你可以免费:拷贝、分发、呈现和演当前作品制作派生作品是必须基于以下条款:署名。你必须明确标明作者的名字。.非商业用途。你不可将当前作品用于商业目的。保持一致。如果你基于当前作品更改、变换或构造新作品,你应当按照与当前完全相同的协议分发最终作品。对于任何二次使用或分发,你必须让其他人明确当前作品的授权条款在得到作者的明确允许下,这里的某些条款可以放弃目录[隐藏]1HOWTOSetupBIND9DNSServer(如何安装设置Bind9DNS服务器)o1.1Repositories软件库o1.2InstallingBIND9(安装BIND9)o1.3BIND9Scenarios1.3.1CachingServer(缓冲服务器)1.3.2MasterServer(主服务器)1.3.3SlaveServer(从服务器)1.3.4Hybrids(混和模式)1.3.5StealthServers(私密服务器)o1.4DNSRecordTypes(DNS记录类型)1.4.1AddressRecords(地址记录)1.4.2AliasRecords(别名记录)1.4.3MailExchangeRecords(邮件交换记录)1.4.4NameServerRecords(域名服务器记录)o1.5ConfiguringBIND9(配置BIND9)1.5.1CachingServer(缓冲服务器)1.5.2MasterServer(主服务器)1.5.3SlaveServer(从服务器)o1.6ChrootingBIND91.6.1TheChrootEnviroment(Chroot环境)1.6.2BIND9'sConfiguration(BIND9的配置)1.6.3Ubuntu'ssyslogdDaemonConfiguration(Ubuntu的syslogd守护进程配置)1.6.4RestartthesyslogserverandBIND9(重启syslog服务及BIND9)o1.7Starting,Stopping,andRestartingBIND9(开始、停止和重启BIND9)1.7.1Status(状态)o1.8Tips&Tricks(提示与技巧)o1.9AdditionalPossibilities(附加功能)o1.10FurtherInformation(更多信息)1.10.1OnlineRecources(在线资源)1.10.2PrintedResources(印刷资源)[编辑]HOWTOSetupBIND9DNSServer(如何安装设置Bind9DNS服务器)原文出处:原文作者:授权许可:创作共享协议Attribution-ShareAlike2.0GNU自由文档许可证翻译人员:FireHare校正人员:purewind贡献人员:适用版本:ThisHOWTOisaimedtoatpeoplelookingtolearnhowtoconfigureandmaintainaDNSserver,suchasforanetworkortoserveDNSzonesforadomainname.本指南是写给那些想学习如何配置和维护DNS服务器的人,例如为某个网络或者DNSzones(DNS域)提供DomainName(域名)服务[编辑]Repositories软件库BIND9isavailableinthecoreUbunturepository.NoadditionalrepositoryneedstobeenabledforBIND9.BIND9已经包含在Ubuntu核心库中,BIND9并不需要启用其它附加库。Beforewebegin,youshouldbefamiliarwithRootSudo.在我们开始之前,您应该熟悉RootSudo。[编辑]InstallingBIND9(安装BIND9)TheServer服务器$sudoapt-getinstallbind9UsefulTools(ForTesting)有用的工具(测试用)$sudoapt-getinstallbind9-hostdnsutilsDocumentation(Optional)文档(可选)$sudoapt-getinstallbind9-doc[编辑]BIND9ScenariosTherearemanysetupsBIND9maybeconfigured.BIND9可以安装配置成许多类型。Themostusefulsetupsare:最常用的配置有:[编辑]CachingServer(缓冲服务器)Thiscanbeusefulforabroadbandconnectiontoahostorsmallnetwork.BycachingDNSqueries,youreducethebandwidthusedand(hopefully)reducingyourbandwidthused(andhopefullyevenyourbroadbandbill!).这对于宽带连接的主机或小网络来说是有用的。通过缓冲DNS队列,您可以减少带宽的消耗,或者说有望减少您带宽的使用(甚至有望减少您宽带费用)。[编辑]MasterServer(主服务器)BIND9canbeusedtoserveDNSrecords(groupsofrecordsarereferredtoaszones)foraregistereddomainnameoranimaginaryone(butonlyifusedonarestrictednetwork)BIND9可以用于为已注册或虚拟的(仅用于受限网络中)域名提供DNS记录(指向域的记录组)。[编辑]SlaveServer(从服务器)AslaveDNSserverisusedtocomplementaMasterDNSserverbyservingacopyofthezone(s)configuredontheMasterserver.Slaveserversarerecommendedinlargersetups(largernetworksorontheinternet)ifyouintendtopoweraregistereddomainname,sincetheyensurethatyourDNSzoneisstillavailable,evenifyourMasterserverisnotonline.从服务器用于提供一个在主服务器中配置域的完整备份。如果您想要支持一个注册的域名,建议将从服务器用在较大的机构(较大的网络或在因特网上)。因为这样做可以确保您的DNS域甚至在您主服务器没有在线的情况下依然可用。[编辑]Hybrids(混和模式)YoucanevenconfigureBIND9tobeaCachingandMasterDNSserversimultaneously,aCachingandaSlaveserverorevenaCaching,MasterandSlaveserver.Allthatisrequiredissimplycombiningthediffernetconfigurationexamplesfromthisdocument.您甚至可以将BIND9同时配置成一个缓冲和主服务器,一个缓冲服务器和一个从服务器,甚至是一个缓冲、主、从服务器。而所有这一切只需将本文档中不同配置简单的合并在一起就可以了。What'sthis?[编辑]StealthServers(私密服务器)TherearealsotwoothercommonDNSserversetups(usedwhenworkingwithzonesforregistereddomainnames),StealthMasterandStealthSlave.TheseareeffectivelythesameasMasterandSlaveDNSservers,butwithaslightorganisationaldifference.还有另外两种常用的DNS服务器的安装(使用注册域名运行):私有主服务器和私有从服务器。它们的作用与主、从DNS服务是相同的,但在组织结构上有所不同。Forexample,youhave3DNSservers;A,BandC.例如,您有3个DNS服务器:A、B和C。AistheMaster,BandCareslaves.A是主服务器,B和C是从服务器。IfyouconfigureyourregistereddomaintouseAandBasyourdomain'sDNSservers,thenCisaStealthSlave.It'sstillaslave,butit'snotgoingtobeaskedaboutthezoneyouareservingtotheinternetfromAandB如果您将A和B配置成您的域DNS服务器,然后C是一个私密从服务器。它也是个从服务器,但您为互联网提供服务的A和B不会去询问其中的域。IfyouconfigureyourregisterddomaintouseBandCasyourdomain'sDNSservers,thenAisastealthmaster.AnyadditionalrecordsoreditstothezonearedoneonA,butcomputersontheinternetwillonlyeveraskBandCaboutthezone.如果您将B和C配置成您的域DNS服务器,然后A是一个私密主服务器。任何附加的记录或对区域的编辑都做在A上,但在互联网上的计算机只会询问B和C中的域。[编辑]DNSRecordTypes(DNS记录类型)TherearelotsofdifferentDNSrecordtypes,butforasomeonereadingthisdocument,youneedonlydealwiththeserecordtypesDNS记录类型是有很多不同的,但对于阅读本文档的人来说,您只需要处理以下这些记录类型[编辑]AddressRecords(地址记录)Themostcommonlyusedtypeofrecord.最常用的记录类型wwwINA1.2.3.4[编辑]AliasRecords(别名记录)UsedtocreateanaliasfromanexistingArecord.YoucannotcreateaCNAMErecordpointingtoanotherCNAMErecord.常用于为一个已有的A记录创建别名。您不能创建一个CNAME记录指向另一个CNAME记录。mailINCNAMEwwwwwwINA1.2.3.4[编辑]MailExchangeRecords(邮件交换记录)Usedtodefinewhereemailshouldbesentto.MustpointtoanArecord,notaCNAME.常用于定义邮件发往何处。必须指向一个A记录,不能是CNAME。INMXmail.example.com.[...]mailINA1.2.3.4[编辑]NameServerRecords(域名服务器记录)Usedtodefinewhichserversservecopiesofthiszone.ItmustpointtoanArecord,notaCNAME.常用于定义哪个服务器提供该区域的拷贝。它必须指向一个A记录,不能是CNAME。ThisiswhereMasterandSlaveserversaredefinied.Stealthserversareintentionallyomitted.这是定义主、从服务器的地方。私密服务器被有意省略。INNSns.example.com.[...]nsINA1.2.3.4[编辑]ConfiguringBIND9(配置BIND9)BIND9ConfigurationfilesarestoredinBIND9配置文件被保存在/etc/bind/Themainconfigurationisstoredinthefollowingfiles主配置文件被保存在下列文件中/etc/bind/named.conf/etc/bind/named.conf.options/etc/bind/named.conf.local[编辑]CachingServer(缓冲服务器)Thedefaultconfigurationissetuptoactasacachingserverbydefault.缺省状态下默认是当作缓冲服务器来配置安装的。AllthatisrequiredissimplyaddingtheIPnumbersofyourISP'sDNSservers.所有的要求只是简单的添加您ISP的DNS服务器的IP而已。Simplyuncommentandeditthefollowing:只需反注释并编辑下列内容:named.conf.options:[...]forwarders{1.2.3.4;5.6.7.8;};[...](where1.2.3.4and5.6.7.8aretheIPnumbersofyourISP'sDNSservers)(其中1.2.3.4和5.6.7.8是您ISP商DNS服务器的IP。[编辑]MasterServer(主服务器)ToaddaDNSzonetoBIND9,turningBIND9intoaMasterserver,allyousimplyhavetodois:要添加DNS域到BIND9,让BIND9成为主服务器,您只需如下所示:named.conf.local:[...]zone"example.com"{typemaster;file"/etc/bind/db.example.com";};[...]Nowuseanexistingzonefileasatemplate现在使用一个已有域文件作为$sudocp/etc/bind/db.local/etc/bind/db.example.comNow,toeditourzone现在,编辑我们的域db.example.com:;;BINDdatafileforlocalloopbackinterface;$TTL604800@INSOAlocalhost.root.localhost.(1;Serial604800;Refresh86400;Retry2419200;Expire604800);NegativeCacheTTL;@INNSlocalhost.@INA127.0.0.1Editlocalhost.totheFQDNofyourserver,withanadditional"."attheend.编辑localhost.指向您服务器的FQDN,在其后有一个附加的"."。Eg:例如:db.example.com:;;BINDdatafileforlocalloopbackinterface;$TTL604800@INSOAbox.example.com.root.localhost.(1;Serial604800;Refresh86400;Retry2419200;Expire604800);NegativeCacheTTL;@INNSlocalhost.@INA127.0.0.1Editroot.localhosttobeyouremailaddress,butwitha"."insteadofthe"@",andanother"."attheend.编辑root.localhost指向你的邮件地址,不过要用"."代替"@",另一个"."放在末尾。Eg:例如:johndoe@exmaple.comshouldbeaddedasjohndoe.example.com.johndoe@exmaple.com将使用johndoe.example.com.的形式添加。IncrementtheSerialnumber(youmustincrementtheserialnumberforeverytimeyoumakeanychangestothezonefileandreloadthezonebyrestartingBIND9.IfyoumakemultiplechangesbeforerestartingBIND9,simplyincrementtheserialonce.增加序列号(您必须在您每次对域文件做更改并通过重启BIND9重新引导域时增加您的序列号。如果您在重启BIND9之前做了多处改变,只需增加一次序列号即可)。Tip:Manypeopleliketousethelastdateeditedastheserialofazone,suchas2005010100whichisyyyymmddss(wheresisserial)技巧:许多人喜欢使用最新的日期作为域的序列号,例如以yyyymmddss的形式2005010100。Now,youcanaddDNSrecordstothebottomofthezone.Doremembertoincrementtheserialasyouaddentriesthough.现在,您可以将DNS记录添加在域的底部。记住在您添加条目之后要增加序列号。[编辑]SlaveServer(从服务器)First,onthemasterserver,youhavetoallowthezonetransfer.Thesamplezonedefinitionin/etc/bind/named.conf.localshouldlikethis:首先,在主服务器上,您必须允许域可以传输。这个在/etc/bind/named.conf.local中域定义的示例如下所示:[...]zone"example.com"{typemaster;file"/etc/bind/db.example.com";allow-transfer{@ip_slave;};};[...]Ontheslave,youhavetoproceedtothesameinstallationthatwasdoneonthemaster.Theneditthe/etc/bind/named.conf.localandaddthefollowingdeclarationforthezone:在从服务器上,您还必须象主服务器上一样做同样处理。然后编辑/etc/bind/named.conf.local并为域添加下列声明:[...]zone"example.com"{typeslave;file"/etc/bind/db.example.com";masters{@ip_master;};};[...]Restarttheserver,youshouldseein/var/log/syslogsomethinglike:重启服务器,您将在/var/log/syslog类似下面的提示:syslog.5.gz:May1423:33:53smithnamed[5064]:zoneexample.com/IN:transferredserial2006051401syslog.5.gz:May1423:33:53smithnamed[5064]:transferof'example.com/IN'from10.0.0.202#53:endoftransfer[编辑]ChrootingBIND9ChrootingBIND9isarecommendedsetupfromasecurityperspective.Inachrootenviroment,BIND9hasaccesstoallthefilesandhardwaredevicesitneeds,butisunabletoaccessanythingitshouldnotneed.ChrootingBIND9从安全角度来说是被推荐的安装。在chroot环境中,BIND9可以访问所有它所需的文件和硬件,但不能访问它所不需要的。TochrootBIND9,simplycreateachrootenviromentforitandaddtheadditionalconfigurationbelow要chrootBIND9,只需为它创建一个chroot环境并在下面添加额外配置。[编辑]TheChrootEnviroment(Chroot环境)Createthefollowingdirectorystructure创建下面目录结构$sudomkdir-p/chroot/named$cd/chroot/named$sudomkdir-pdevetc/namedb/slavevar/runSetpermissionsforchrootenvironment为chroot环境设置权限$sudochownroot:root/chroot$sudochmod700/chroot$sudochownbind:bind/chroot/named$sudochmod700/chroot/namedCreateormovethebindconfigurationfile.创建或移动bind配置文件。$sudotouch/chroot/named/etc/named.confor或$sudocp/etc/named.conf/chroot/named/etcGivewritepermissionstotheuserbindfor/chroot/named/etc/namedb/slavedirectory.将/chroot/named/etc/namedb/slave目录的写权限赋予bind用户。$sudochownbind:bind/chroot/named/etc/namedb/slaveThisiswherethefilesforallslavezoneswillbekept.Thisincreasessecurity,bystoppingtheabilityofanattackertoeditanyofyourmasterzonefilesiftheydogainaccessasthebinduser.Accordingly,allslavefilenamesinthe/chroot/named/etc/named.conffilewillneedtohavedirectorynamesthatdesignatetheslavedirectory.Anexamplezonedefinitionislistedbelow.所有的从域将放置在此处。这样可以增强安全性,如果攻击者得到了bind用户的权限,他们也没有办法修改您的主域文件。因此在/chroot/named/etc/named.conf文件中的所有的从文件名都必须带着指向从目录的目录名。下面列出了一个域定义的示例:zone“my.zone.com.”{typeslave;file“slaves/my.zone.com.dns”;masters{10.1.1.10;};};CreatethedevicesBIND9requires创建BIND9的环境$sudomknod/chroot/named/dev/nullc13$sudomknod/chroot/named/dev/randomc18Givetheuserbindaccesstothe/chroot/named/var/rundirectorythatwillbeusedtostrorePIDandstatisticaldata.给bind用户访问/chroot/named/var/run目录的权限,该目录用于保存PID和状态数据$sudochownbind:bind/chroot/named/var/run[编辑]BIND9'sConfiguration(BIND9的配置)Editthebindstartupoptionsfoundin/etc/default/bind9.Changethelinethereads:在/etc/default/bind9中编辑bind启动选项。原来选项如下:/etc/default/bind9:OPTIONS=”-ubind”Sothatitreads现在改为/etc/default/bind9:OPTIONS="-ubind-t/var/named-t/chroot/named-c/etc/named.conf"The-toptionchangestherootdirectoryfromwhichbindoperatestobe/chroot/named.The-coptiontellsBindthattheconfigurationfileislocatedat/etc/named.conf.Rememberthatthispathisrelativetotherootsetby-t.选项-t将bind操作的根目录改成/chroot/named,选项-c则告诉bind配置文件在/etc/named.conf。记住用-t设置的是相对路径。Thenamed.conffilemustalsorecieveextraoptionsinordertoruncorrectlybelowisaminimalsetofoptions:named.conf文件也必须接受额外的选项以便正常运行,下面是最小的选项集:/chroot/named/etc/named.conf:options{directory"/etc/namedb";pid-file"/var/run/named.pid";statistics-file"/var/run/named.stats";};[编辑]Ubuntu'ssyslogdDaemonConfiguration(Ubuntu的syslogd守护进程配置)/etc/init.d/sysklogd:[...]SYSLOGD="-usyslog-a/chroot/named/dev/log"[...](AuthorNote:Checkthisconfig)(注意:检查该配置)[编辑]RestartthesyslogserverandBIND9(重启syslog服务及BIND9)$sudo/etc/init.d/sysklogdrestart$sudo/etc/init.d/bind9restartAtthispointyoushouldcheck/var/log/messagesforanyerrorsthatmayhavebeenthrownbybind.这里,您要检查/var/log/messages是否有bind引起的错误。[编辑]Starting,Stopping,andRestartingBIND9(开始、停止和重启BIND9)UsethefollowingcommandtostartBIND9:使用下列命令开始BIND9:$sudo/etc/init.d/bind9startTostopit,use:停止它,使用:$sudo/etc/init.d/bind9stopFinally,torestartit,run最后,要重启它,运行:$sudo/etc/init.d/bind9restart[编辑]Status(状态)TocheckthestatusofyourBIND9installation:要检查您的BIND9安装状态:$host$recordlocalhostor或$dig$record@localhost(wherelocalhostisthesystemyouaresettingBIND9upon.Ifnotlocalhost,usetheappropriateIPnumber.)(在这里localhost是您安装BIND9的系统。如果不要localhost,那么使用适当的IP地址。)[编辑]Tips&Tricks(提示与技巧)[编辑]AdditionalPossibilities(附加功能)YoucanmonitoryourBIND9serverusagebyinstallingthebindgraphpackagefromtheUniverse(ToenableUniverse-seeAddingRepositoriesHowto)andfollowingconfigurationdetailsasoutlinedinbindgraph'sREADMEdocuments您可以从Universe库中安装bindgraph包(要激活Universe库-请参见AddingRepositoriesHowto),并用它来监视您的BIND9服务器的使用,配置细节可以在bindgraphREADME文档中找到。[编辑]FurtherInformation(更多信息)[编辑]OnlineRecources(在线资源)"ISC'sBIND9Manual"TLDP's"DNSHOWTO"(ForGeneralOverview)"ChrootBINDHowto"[编辑]PrintedResources(印刷资源)"DNS&BIND"-PaulAlbitz&CricketLiu-4thEditi
/
本文档为【Ubuntuserver环境Bind9安装设置指南】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索