见字如面,大家好,我是小斐,今天带来关于LDNS的最佳实践,关于bind9的在生产环境中的使用,本篇文章争取言简意赅的说明bind9在内部企业中的应用。 环境说明: 系统:Ubuntu22。04。1LTS 机器:两台做主从(主服务器和辅助服务器) 主:192。168。10。200 从:192。168。10。201bind9安装默认安装目录 默认情况下,BIND将安装在usrlocal中,并将文件放在它的这些子目录中:sbinnamed和所有与BIND相关的系统管理工具,例如rndc、dnsseckeygen、namedcheckconf等。bin非管理员用户的工具你会在这里找到dig、host和nsupdatelib目标代码库shareBIND的手册页和各种子目录includeC头文件 编译时未更改默认目录的BIND将使用以下目录(相对于根目录)etc配置文件(例如named。conf、rndc。conf)varrunnamed创建和使用的运行时文件源码编译安装新建构建目录下载的源码包放置在该目录中rootdns01:homemkdirbulidsrootdns01:homebulidspwdhomebulidswget可能会比较慢rootdns01:homebulidswgethttps:downloads。isc。orgiscbind99。18。9bind9。18。9。tar。xzrootdns01:homebulidstarxvfbind9。18。9。tar。xz进入解压后的目录中rootdns01:homebulidsbind9。18。9pwdhomebulidsbind9。18。9查看编译选项参数帮助rootdns01:homebulidsbind9。18。9。configurehelp编译依赖库安装rootdns01:homebulidsbind9。18。9aptgetinstallgcczlib1gdevbuildessentialpkgconfigautoconfautomakelibtoollibssldevlibcapdevlibxml2libxml2devlibfstrmdevlibprotobufcdevliblmdbdevlibmaxminddbdevlibidn2devlibreadlinedevlibjsoncdevfstrmbinprotobufccompiler源码编译libuv依赖辅助服务器使用了libuv1。44。2版本rootdns01:homebulidslibuv1。42。0wgethttps:dist。libuv。orgdistv1。42。0libuvv1。42。0。tar。gzrootdns01:homebulidstarzxvflibuvv1。42。0。tar。gzrootdns01:homebulidscdlibuv1。42。0rootdns01:homebulidslibuv1。42。0pwdhomebulidslibuv1。42。0rootdns01:homebulidslibuv1。42。0shautogen。shrootdns01:homebulidslibuv1。42。0。configurerootdns01:homebulidslibuv1。42。0makej4rootdns01:homebulidslibuvv1。42。0makeinstallrootdns01:homebulidslibuvv1。42。0ldconfig源码编译jemalloc官方推荐更换内存分配器为jemalloc解决OOM问题提高性能rootdns01:homebulidswgethttps:github。comjemallocjemallocreleasesdownload5。3。0jemalloc5。3。0。tar。bz2rootdns01:homebulidstarxjvfjemalloc5。3。0。tar。bz2rootdns01:homebulidscdjemalloc5。3。0rootdns01:homebulidsjemalloc5。3。0。configurerootdns01:homebulidsjemalloc5。3。0makej8rootdns01:homebulidsjemalloc5。3。0makeinstallrootdns01:homebulidsjemalloc5。3。0ldconfig官方关于内存OOM问题分析https:www。isc。orgblogsjemallocglitch源码编译bind9编译帮助执行。configurehelprootdns01:homebulidscdbind9。18。9rootdns01:homebulidsbind9。18。9。configureprefixusrlocalbindwithopensslwithjsoncenablelargefilewithlibidn2enablefullreportenablednstapdisabledohrootdns01:homebulidsbind9。18。9makerootdns01:homebulidsbind9。18。9makeinstall 编译安装完成后如下所示:usrlocalbind 编译参数说明:prefixusrlocalbind定义安装目录如不定义则安装默认目录安装sysconfdirPERFIXetc如定义安装目录就根据prefix参数定义的目录创建下一级配置文件所在目录localstatedirPERFIXvar如定义安装目录就根据prefix参数目录创建下一级目录named运行动态生成的文件目录withopenssl开启opensslwithjsoncHTTP统计信息格式enablelargefile2G以上大文件支持withlibidn2dig国际化通用域名IDN支持enablefullreport编译显示全部报告enablednstap开启dnstap日志记录disabledoh关闭DNSoverHTTPS 编译官方文档说明:bind9运行bind服务器配置角色主服务器:负责至少解析一个域内的域名,维护所负责解析的域数据库,可对该域数据进行读写操作辅服务器:负责从主服务器或其他辅服务器中复制相关解析库,为主服务器缓解解析压力缓存服务器:不负责域名解析,仅仅作为缓存,加速解析速度转发服务器:发现非本机负责的请求后,不再向根发起请求,而是直接转发给指定的一台或多台服务器,自身并不保存查询 为了命令方便,把bind9相关的命令加入环境变量,使得命令不需要绝对路径执行rootdns01:usrlocalbindvimetcprofileexportPATH{PATH}:usrlocalbindbin:usrlocalbindsbin在文件末尾输入这行环境变量rootdns01:usrlocalbindsourceetcprofilerootdns01:usrlocalbindnamedV查看bind9版本信息和默认路径 主服务器PrimaryAuthoritativeNameServer为了安全以非root运行rootdns01:usrlocalbindgroupaddg53rbindrootdns01:usrlocalbinduseraddu53ssbinnolginrbindgbind授权bind目录named权限rootdns01:usrlocalbindchownRbind:bindusrlocalbind使用rndcconfgen生成rndc。conf配置文件rootdns01:usrlocalbindetcusrlocalbindsbinrndcconfgenusrlocalbindetcrndc。confrndc。conf配置文件是运行rndc工具所需rndc是官方推荐管理bind的远程管理工具rndc以953端口运行rootdns01:usrlocalbindetcvimrndc。confStartofrndc。confkeyrndckey{algorithmhmacsha256;secretOcpnouni6hob6Bw9aWAYBoCSYNJQVKfG3XsYVm56k;};options{defaultkeyrndckey;defaultserver127。0。0。1;defaultport953;};Endofrndc。conf取rndc。conf文件中最后10行的前面9行重定向named。conf文件中,再去掉每一行前面的符号rootdns01:usrlocalbindetctail10rndc。confhead9sedsgnamed。conf上面为什么这么做呢是因为rndc要管理bind必须在named。conf中导入rndckey信息和controls信息 named。conf主服务器配置keyrndckey{algorithmhmacsha256;secretOcpnouni6hob6Bw9aWAYBoCSYNJQVKfG3XsYVm56k;};rndc通道controls{inet127。0。0。1port953allow{127。0。0。1;}keys{rndckey;};};日志输出新建日志文件夹logslogging{channelexamplelog{filelogsexample。logversions3size250k;severityinfo;};categorydefault{examplelog;};};为本地主机提供正向映射区域zonelocalhost{typeprimary;fileetclocalhostforward。db;这个文件不需要改变notifyno;};为环回口提供反向映射区域127。0。0。1zone0。0。127。inaddr。arpa{typeprimary;fileetclocalhost。rev;这个文件不需要改变notifyno;};DNS全局选项配置文件includeusrlocalbindetcnamed。conf。options;自定义区域配置文件includeusrlocalbindetcnamed。conf。local;默认区域,例如localhost,其反向和根提示includeusrlocalbindetcnamed。conf。defaultzones; localhostforward。db主服务器配置TTL3hlocalhost。SOAlocalhost。nobody。localhost。421d12h1w3hNSlocalhost。A127。0。0。1AAAA::1 localhost。rev主服务器配置TTL1DINSOAlocalhost。root。localhost。(2007091701;serial30800;refresh7200;retry604800;expire300);minimumINNSlocalhost。1INPTRlocalhost。 named。conf。options主服务器配置options{versionnotcurrentlyavailable;隐藏bind版本,为了安全考虑directoryusrlocalbind;运行时数据的目录pidfileusrlocalbindvarrunnamed。pid;pid文件recursionno;全局递归关闭allowquery{any;};面向所有源IP提供解析服务allowquerycache{none;};面向所有源IP不提供查询缓存listenonport53{any;};监听IPv4的53端口可改为本机IP192。168。10。200forwarders{除了本地配置的域名,其他都转发DNS查询到上级DNS服务器223。5。5。5;114。114。114。114};forwardonly;针对外网域名只转发上级DNS中dnssecvalidationno;DNSSEC验证关闭listenonv6{none;};关闭监听IPv6的53端口}; named。conf。local主服务器配置example。com提供映射区域zoneexample。com{这是主服务器区域typeprimary;filezonesprimary。example。com;notifyyes;启动区域传输alsonotify{192。168。10。201;};允许从服务器可以复制allowtransfer{192。168。10。201;从服务器IP};};创建反向区域文件192。168。10。xzone10。168。192。inaddr。arpa{typeprimary;filezonesdb。192。168。10;notifyyes;启动区域传输alsonotify{192。168。10。201;};允许从服务器可以复制allowtransfer{192。168。10。201;从服务器IP};}; 区域配置文件:example。com以这个域名为例catprimary。example。com文件;BINDdatafileforexample。comTTL604800INSOAns01。example。com。admin。example。com。(2022120601;Serial604800;Refresh86400;Retry2419200;Expire604800);NegativeCacheTTLINNSns01。example。com。INA192。168。10。200INAAAA::1ns01INA192。168。10。200catdb。192。168。10文件192。168。10。rev官方示例配置文件命名方式:网络位。rev;BINDreversedatafileforlocal192。168。10。XXXnetTTL604800INSOAns01。example。com。admin。example。com。(2022120601;Serial604800;Refresh86400;Retry2419200;Expire604800);NegativeCacheTTL;INNSns01。example。com。200INPTRns01。example。com。 新建systemd管理配置文件: vimlibsystemdsystemnamed。service〔Unit〕DescriptionBINDDomainNameServerDocumentationman:named(8)Afternetwork。targetWantsnsslookup。targetBeforensslookup。target〔Service〕TypeforkingEnvironmentFileusrlocalbindetcnamedExecStartusrlocalbindsbinnamedOPTIONSExecReloadusrlocalbindsbinrndcreloadExecStopusrlocalbindsbinrndcstopRestartonfailure〔Install〕WantedBymultiuser。targetAliasbind9。service 在创建named环境变量文件vimnamedrunresolvconf?RESOLVCONFnostartupoptionsfortheserverOPTIONSubindcusrlocalbindetcnamed。conf指定启用用户和启动配置文件 主服务器启动rootdns01:usrlocalbindetcsystemctldaemonreloadrootdns01:usrlocalbindetcsystemctlstartnamed。service 启动失败排错: 执行上述操作,无法看到具体的错误信息,故想到named可以前台允许,打印运行信息:g前台运行u启用用户c指定启动配置文件rootdns01:usrlocalbindsbinnamedubindc。。etcnamed。confg06Dec202213:23:17。270loadingconfigurationfromusrlocalbindsbin。。etcnamed。conf06Dec202213:23:17。274directoryusrlocalbindvarrunisnotwritable06Dec202213:23:17。274usrlocalbindetcnamed。conf。options:3:parsingfailed:permissiondenied06Dec202213:23:17。274loadingconfiguration:permissiondenied06Dec202213:23:17。274exiting(duetofatalerror) 发现问题directoryusrlocalbindvarrunisnotwritable指定的运行时数据目录不可写,发现没用创建该目录,新建该目录,并授权bind:rootdns01:usrlocalmkdirpusrlocalbindvarrunrootdns01:usrlocalchownRbind:bindusrlocalbindrootdns01:usrlocalbindsbinnamedubindc。。etcnamed。confg第二次运行还是报错,不过是新的错误06Dec202213:33:44。844notusingconfigfileloggingstatementforloggingduetogoption06Dec202213:33:44。844checkingloggingconfigurationfailed:filenotfound06Dec202213:33:44。844loadingconfiguration:filenotfound06Dec202213:33:44。844exiting(duetofatalerror)检查配置文件named。conf 发现日志记录配置文件路径写错了,log应改为logs文件夹: 因为我新建的文件夹就是logs文件夹,故日志记录开启日志记录,但由于路径设置错误,故启动失败。 修改为:touchexample。logchownRbind:bindusrlocalbind 启动: rootdns01:usrlocalbindetcsystemctlstartnamed。service rootdns01:usrlocalbindetcsystemctlstatusnamed。service named启动成功 验证主服务器是否有效:这里的主服务器也即是权威服务器修改客户端机器DNS和DNS后缀搜索列表vimetcnetplan00installerconfig。yamlThisisthenetworkconfigwrittenbysubiquitynetwork:ethernets:ens33:addresses:192。168。10。20024gateway4:192。168。10。254nameservers:addresses:〔192。168。10。200〕修改主服务器DNS地址search:〔example。com〕输入搜索域列表可选version:2配置生效netplanapply dig命令测试验证:digns01。example。com 如上图所示,解析成功,主服务器(primaryDNS)安装完成。辅助服务器SecondaryAuthoritativeNameServer 1、源码编译安装(同上) 2、辅助服务器启动配置 rndc。conf辅助服务器配置rootdns02:homebulidsbind9。18。9cdusrlocalbindrootdns02:usrlocalbindlsbinetcincludelibsbinshare新建目录rootdns02:usrlocalbindmkdirlogsrootdns02:usrlocalbindmkdirzonesrootdns02:usrlocalbindmkdirpvarrun最终目录结构rootdns02:usrlocalbindlsbinetcincludeliblogssbinsharevarzones为了安全以非root运行rootdns02:usrlocalbindgroupaddg53rbindrootdns02:usrlocalbinduseraddu53ssbinnolginrbindgbind授权bind目录named权限rootdns02:usrlocalbindchownRbind:bindusrlocalbind使用rndcconfgen生成rndc。conf配置文件rootdns02:usrlocalbindetcusrlocalbindsbinrndcconfgenusrlocalbindetcrndc。confrndc。conf配置文件是运行rndc工具所需rndc是官方推荐管理bind的远程管理工具rndc以953端口运行rootdns02:usrlocalbindetcvimrndc。confStartofrndc。confkeyrndckey{algorithmhmacsha256;secretD4Ap4JN71LvPpFeIApwOoNsUPRf98uI3IhDoALs;};options{defaultkeyrndckey;defaultserver127。0。0。1;defaultport953;};Endofrndc。conf取rndc。conf文件中最后10行的前面9行重定向named。conf文件中,再去掉每一行前面的符号rootdns02:usrlocalbindetctail10rndc。confhead9sedsgnamed。conf上面为什么这么做呢是因为rndc要管理bind必须在named。conf中导入rndckey信息和controls信息 named。conf辅助服务器配置keyrndckey{algorithmhmacsha256;secretD4Ap4JN71LvPpFeIApwOoNsUPRf98uI3IhDoALs;};rndc控制通道controls{inet127。0。0。1port953allow{127。0。0。1;}keys{rndckey;};};日志输出logging{channelexamplelog{filelogsexample。logversions3size250k;severityinfo;};categorydefault{examplelog;};};为本地主机提供正向映射区域zonelocalhost{typeprimary;fileetclocalhostforward。db;notifyno;};为环回口提供反向映射区域127。0。0。1zone0。0。127。inaddr。arpa{typeprimary;fileetclocalhost。rev;notifyno;};includeusrlocalbindetcnamed。conf。options;includeusrlocalbindetcnamed。conf。local;includeusrlocalbindetcnamed。conf。defaultzones; localhostforward。db辅助服务器配置同上TTL3hlocalhost。SOAlocalhost。nobody。localhost。421d12h1w3hNSlocalhost。A127。0。0。1AAAA::1 localhost。rev辅助服务器配置同上TTL1DINSOAlocalhost。root。localhost。(2007091701;serial30800;refresh7200;retry604800;expire300);minimumINNSlocalhost。1INPTRlocalhost。 named。conf。options辅助服务器配置options{versionnotcurrentlyavailable;directoryusrlocalbind;pidfileusrlocalbindvarrunnamed。pid;recursionno;allowquery{any;};allowquerycache{none;};listenonport53{192。168。10。201;};修改辅助服务器IP地址forwarders{223。5。5。5;114。114。114。114};forwardonly;dnssecvalidationno;listenonv6{none;};关闭IPv6端口监听authnxdomainno;}; named。conf。local辅助服务器配置我们是example。com的辅助服务器zoneexample。com{这是辅助服务器区域typesecondary;masterfileformattext;默认raw格式打开时乱码显示text文本格式可查看从主服务器更新过来的数据filezonessecondary。example。com;主服务器IPprimaries{192。168。10。200;};注意替换主DNS服务器IP};反向区域文件192。168。10。xzone10。168。192。inaddr。arpa{typesecondary;masterfileformattext;默认raw格式打开时乱码显示text文本格式可查看从主服务器更新过来的数据filezonesdb。192。168。10;primaries{192。168。10。200;};注意替换主DNS服务器IP}; 启动: 新建systemd管理配置文件:vimlibsystemdsystemnamed。service〔Unit〕DescriptionBINDDomainNameServerDocumentationman:named(8)Afternetwork。targetWantsnsslookup。targetBeforensslookup。target〔Service〕TypeforkingEnvironmentFileusrlocalbindetcnamedExecStartusrlocalbindsbinnamedOPTIONSExecReloadusrlocalbindsbinrndcreloadExecStopusrlocalbindsbinrndcstopRestartonfailure〔Install〕WantedBymultiuser。targetAliasbind9。service named文件新建:vimusrlocalbindetcnamedrunresolvconf?RESOLVCONFnostartupoptionsfortheserverOPTIONSubindcusrlocalbindetcnamed。conf指定启用用户和启动配置文件 最后执行权限授权:chownRbind:bindusrlocalbindrootdns02:usrlocalbindzonessystemctldaemonreloadrootdns02:usrlocalbindzonessystemctlstartnamed。servicerootdns02:usrlocalbindzonessystemctlstatusnamed。service查看启动成功 启动后:secondary。example。com和db。192。168。10会从主服务器中自动更新过来,不用自己新建。 添加辅助服务器到区域中:修改主服务器zone区域配置rootdns01:usrlocalbindzonesvimprimary。example。com;BINDdatafileforexample。comTTL604800INSOAns01。example。com。admin。example。com。(2022120602;Serial604800;Refresh86400;Retry2419200;Expire604800);NegativeCacheTTLINNSns01。example。com。INNSns02。example。com。ns01INA192。168。10。200ns02INA192。168。10。201修改主服务器zone反向区域配置rootdns01:usrlocalbindzonesvimdb。192。168。10192。168。254。rev官方示例配置文件命名方式:网络位。rev;BINDreversedatafileforlocal192。168。10。XXXnetTTL604800INSOAns01。example。com。admin。example。com。(2022120602;Serial604800;Refresh86400;Retry2419200;Expire604800);NegativeCacheTTL;INNSns01。example。com。INNSns02。example。com。200INPTRns01。example。com。201INPTRns02。example。com。 修改完后:可看到辅助服务器配置文件立即更新查看辅助区域文件rootdns02:usrlocalbindzonesvimsecondary。example。comORIGIN。TTL604800;1weekexample。comINSOAns01。example。com。admin。example。com。(2022120602;serial604800;refresh(1week)86400;retry(1day)2419200;expire(4weeks)604800;minimum(1week))NSns01。example。com。NSns02。example。com。ORIGINexample。com。ns01A192。168。10。200ns02A192。168。10。201查看辅助区域IP反向映射配置文件rootdns02:usrlocalbindzonesvimdb。192。168。10192。168。254。rev官方示例配置文件命名方式:网络位。revORIGIN。TTL604800;1week10。168。192。inaddr。arpaINSOAns01。example。com。admin。example。com。(2022120602;serial604800;refresh(1week)86400;retry(1day)2419200;expire(4weeks)604800;minimum(1week))NSns01。example。com。NSns02。example。com。ORIGIN10。168。192。inaddr。arpa。200PTRns01。example。com。201PTRns02。example。com。 测试区域配置文件:namedcheckzonerootdns01:usrlocalbindnamedcheckzoneexample。comzonesprimary。example。comzoneexample。comIN:loadedserial2022120601OK上面信息代表区域配置文件没有语法错误rootdns01:usrlocalbindnamedcheckzonedb。192。168。10zonesdb。192。168。10zonedb。192。168。10IN:loadedserial2022120601OK dig测试验证: 缓存服务器CachingNameServers 1、源码编译安装(同上) 2、缓存服务器启动配置 配置和安装方式都和主服务器大同小异,配置文件修改下: named。conf配置:keyrndckey{algorithmhmacsha256;secretOcpnouni6hob6Bw9aWAYBoCSYNJQVKfG3XsYVm56k;};rndc通道controls{inet127。0。0。1port953allow{127。0。0。1;}keys{rndckey;};};允许查询并缓存的内部私有IP地址段aclcorpnets{192。168。4。024;192。168。7。024;};日志输出logging{channelexamplelog{filelogsexample。logversions3size250k;severityinfo;};categorydefault{examplelog;};};根区域提示文件zone。{typehint;fileetcnamed。root;};为本地主机提供正向映射区域zonelocalhost{typeprimary;fileetclocalhostforward。db;notifyno;};为环回口提供反向映射区域127。0。0。1zone0。0。127。inaddr。arpa{typeprimary;fileetclocalhost。rev;notifyno;};为本地IP反向映射区域zone10。168。192。inaddr。arpa{typeprimary;fileetc192。168。10。rev;notifyno;};includeusrlocalbindetcnamed。conf。options;includeusrlocalbindetcnamed。conf。local;includeusrlocalbindetcnamed。conf。defaultzones; 根提示文件下载:named。root放在usrlocalbindetc目录下 named。conf。options配置:options{versionnotcurrentlyavailable;directoryusrlocalbind;pidfileusrlocalbindvarrunnamed。pid;recursionyes;allowquery{corpnets;};allowquerycache{corpnets;};指定哪些主机(IP地址列表)可以访问此服务器的缓存,从而有效地控制递归。listenonport53{192。168。10。200;};dnssecvalidationno;listenonv6{none;};emptyzonesenableyes;};转发服务器ForwardingNameServers 1、源码编译安装(同上) 2、缓存服务器启动配置 配置和安装方式都和主服务器大同小异,配置文件修改下: named。conf配置:keyrndckey{algorithmhmacsha256;secretOcpnouni6hob6Bw9aWAYBoCSYNJQVKfG3XsYVm56k;};rndc通道controls{inet127。0。0。1port953allow{127。0。0。1;}keys{rndckey;};};允许查询并缓存的内部私有IP地址段aclcorpnets{192。168。4。024;192。168。7。024;};日志输出logging{channelexamplelog{filelogsexample。logversions3size250k;severityinfo;};categorydefault{examplelog;};};为本地主机提供正向映射区域zonelocalhost{typeprimary;fileetclocalhostforward。db;notifyno;};为环回口提供反向映射区域127。0。0。1zone0。0。127。inaddr。arpa{typeprimary;fileetclocalhost。rev;notifyno;};为本地IP反向映射区域zone10。168。192。inaddr。arpa{typeprimary;fileetc192。168。10。rev;notifyno;};includeusrlocalbindetcnamed。conf。options;includeusrlocalbindetcnamed。conf。local;includeusrlocalbindetcnamed。conf。defaultzones; named。conf。options配置:该配置应用在内网有内网域名和公网解析交给公共DNS的场景options{versionnotcurrentlyavailable;directoryusrlocalbind;pidfileusrlocalbindvarrunnamed。pid;recursionyes;allowquery{corpnets;};allowquerycache{corpnets;};指定哪些主机(IP地址列表)可以访问此服务器的缓存,从而有效地控制递归。listenonport53{192。168。10。200;};dnssecvalidationno;listenonv6{none;};emptyzonesenableyes;forwarders{223。5。5。5;114。114。114。114;};表示将转发除已定义区域以外的所有查询forwardonly;}; 区域转发服务器配置: 此转发解析器配置仅将区域example。com的递归查询转发到位于192。168。250。3和192。168。230。27的解析器。所有其他递归查询,除了那些针对已定义区域的查询和那些答案已经在其缓存中的查询,都由这个解析器处理。转发解析器将缓存来自公共网络和转发解析器的所有响应。 named。conf配置:keyrndckey{algorithmhmacsha256;secretOcpnouni6hob6Bw9aWAYBoCSYNJQVKfG3XsYVm56k;};rndc通道controls{inet127。0。0。1port953allow{127。0。0。1;}keys{rndckey;};};允许查询并缓存的内部私有IP地址段aclcorpnets{192。168。4。024;192。168。7。024;};日志输出logging{channelexamplelog{filelogsexample。logversions3size250k;severityinfo;};categorydefault{examplelog;};};为本地主机提供正向映射区域zonelocalhost{typeprimary;fileetclocalhostforward。db;notifyno;};为环回口提供反向映射区域127。0。0。1zone0。0。127。inaddr。arpa{typeprimary;fileetclocalhost。rev;notifyno;};为本地IP反向映射区域zone10。168。192。inaddr。arpa{typeprimary;fileetc192。168。10。rev;notifyno;};区域文件转发example。comzoneexample。com{typeforward;forwarders{192。168。10。100;针对example。com的查询转发到192。168。10。100和192。168。10。101上192。168。10。101;};forwardonly;};includeusrlocalbindetcnamed。conf。options;includeusrlocalbindetcnamed。conf。local;includeusrlocalbindetcnamed。conf。defaultzones; named。conf。options配置options{versionnotcurrentlyavailable;directoryusrlocalbind;pidfileusrlocalbindvarrunnamed。pid;recursionyes;allowquery{corpnets;};allowquerycache{corpnets;};指定哪些主机(IP地址列表)可以访问此服务器的缓存,从而有效地控制递归。listenonport53{192。168。10。200;};dnssecvalidationno;listenonv6{none;};emptyzonesenableyes;};bind9混杂模式 不同角色配置起到不同的功能,但是实际情况是主服务器和辅助服务器,可能需要启用缓存和转发服务器的功能,故在实际环境中,主服务器和辅助服务器同时也是缓存服务器和转发服务器,可以把配置进行结合启用。 到此就介绍关于bind9安装和搭建以及基本的运行配置。下一篇将介绍核心配置文件,named。conf配置文件的语法和参数说明。