本文将向您展示–如何使用DNS在本地环境中配置DNS缓存或转发服务器。当我们学习诸如配置网站和服务器之类的东西时,DNS(域名系统)通常是使服务器正常运行的关键服务器。大多数人会选择使用托管公司或域控制器提供的DNS服务器。
该配置将缓存DNS服务器。这种类型的服务器称为解析器,因为它处理递归查询并可以处理从服务器跟踪DNS数据的麻烦。
要安装绑定包,我们可以使用以下命令。另外,绑定包中还包含了缓存名称服务器包。
# yum install bind bind-chroot Resolving Dependencies --> Running transaction check ---> Package bind.x86_64 32:9.8.2-0.37.rc1.el6_7.7 will be installed --> Processing Dependency: bind-libs = 32:9.8.2-0.37.rc1.el6_7.7 for package: 32:bind-9.8.2-0.37.rc1.el6_7.7.x86_64 ---> Package bind-chroot.x86_64 32:9.8.2-0.37.rc1.el6_7.7 will be installed --> Running transaction check ---> Package bind-libs.x86_64 32:9.8.2-0.37.rc1.el6 will be updated --> Processing Dependency: bind-libs = 32:9.8.2-0.37.rc1.el6 for package: 32:bind-utils-9.8.2-0.37.rc1.el6.x86_64 ---> Package bind-libs.x86_64 32:9.8.2-0.37.rc1.el6_7.7 will be an update --> Running transaction check ---> Package bind-utils.x86_64 32:9.8.2-0.37.rc1.el6 will be updated ---> Package bind-utils.x86_64 32:9.8.2-0.37.rc1.el6_7.7 will be an update --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================== Package Arch Version Repository Size ============================================================================================================================================== Installing: bind x86_64 32:9.8.2-0.37.rc1.el6_7.7 updates 4.0 M bind-chroot x86_64 32:9.8.2-0.37.rc1.el6_7.7 updates 75 k Updating for dependencies: bind-libs x86_64 32:9.8.2-0.37.rc1.el6_7.7 updates 887 k bind-utils x86_64 32:9.8.2-0.37.rc1.el6_7.7 updates 186 k Transaction Summary ============================================================================================================================================== Install 2 Package(s) Upgrade 2 Package(s) Total download size: 5.1 M Is this ok [y/N]: y Downloading Packages: (1/4): bind-9.8.2-0.37.rc1.el6_7.7.x86_64.rpm | 4.0 MB 00:00 (2/4): bind-chroot-9.8.2-0.37.rc1.el6_7.7.x86_64.rpm | 75 kB 00:00 (3/4): bind-libs-9.8.2-0.37.rc1.el6_7.7.x86_64.rpm | 887 kB 00:00 (4/4): bind-utils-9.8.2-0.37.rc1.el6_7.7.x86_64.rpm | 186 kB 00:00 ---------------------------------------------------------------------------------------------------------------------------------------------- Total 1.4 MB/s | 5.1 MB 00:03 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Updating : 32:bind-libs-9.8.2-0.37.rc1.el6_7.7.x86_64 1/6 Installing : 32:bind-9.8.2-0.37.rc1.el6_7.7.x86_64 2/6 Installing : 32:bind-chroot-9.8.2-0.37.rc1.el6_7.7.x86_64 3/6 Updating : 32:bind-utils-9.8.2-0.37.rc1.el6_7.7.x86_64 4/6 Cleanup : 32:bind-utils-9.8.2-0.37.rc1.el6.x86_64 5/6 Cleanup : 32:bind-libs-9.8.2-0.37.rc1.el6.x86_64 6/6 Verifying : 32:bind-chroot-9.8.2-0.37.rc1.el6_7.7.x86_64 1/6 Verifying : 32:bind-utils-9.8.2-0.37.rc1.el6_7.7.x86_64 2/6 Verifying : 32:bind-9.8.2-0.37.rc1.el6_7.7.x86_64 3/6 Verifying : 32:bind-libs-9.8.2-0.37.rc1.el6_7.7.x86_64 4/6 Verifying : 32:bind-libs-9.8.2-0.37.rc1.el6.x86_64 5/6 Verifying : 32:bind-utils-9.8.2-0.37.rc1.el6.x86_64 6/6 Installed: bind.x86_64 32:9.8.2-0.37.rc1.el6_7.7 bind-chroot.x86_64 32:9.8.2-0.37.rc1.el6_7.7 Dependency Updated: bind-libs.x86_64 32:9.8.2-0.37.rc1.el6_7.7 bind-utils.x86_64 32:9.8.2-0.37.rc1.el6_7.7 Complete! Config the Configuration File
为了安全起见,我们需要使用以下命令从绑定样本文件中复制绑定配置文件。需要根据我们安装的版本更改文件的路径。
# cd /var/named/chroot/etc # cp /usr/share/doc/bind-9.8.2/sample/etc/named.conf /var/named/chroot/etc # cp /usr/share/doc/bind-9.8.2/sample/etc/named.rfc1912.zones /var/named/chroot/etc
我们可以在您喜欢的编辑器中编辑绑定配置文件,并根据以下要求和设置进行必要的更改–
# /var/named/chroot/etc/named.conf options { listen-on port 53 { 127.0.0.1; any; }; listen-on-v6 port 53 { ::1; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; allow-query { localhost; any; }; allow-query-cache { localhost; any; }; recursion yes; dnssec-enable yes; dnssec-validation yes; dnssec-lookaside auto; /* Path to ISC DLV key */ bindkeys-file "/etc/named.iscdlv.key"; managed-keys-directory "/var/named/dynamic"; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; include "/etc/named.rfc1912.zones";
现在,使用以下命令更新对配置文件的必需权限。
# chown root:named named.conf named.rfc1912.zones
我们建议您使用以下命令在重新启动服务之前检查DNS配置文件–
# named-checkconf named.conf
现在,绑定服务的安装和配置已完成。我们使用以下命令启动绑定(命名)服务。
# service named restart
在系统启动时启用自动启动绑定服务。
# chkconfig named on
使用以下命令将查询直接发送到DNS服务器。
Syntax: nslookup <domain name> <caching dns server name/IP address>
# nslookup google.com 192.168.87.150 [Sample Output:] Server: 192.168.87.158 Address: 192.168.87.158#53 Non-authoritative answer: Name: google.com Address: 216.58.220.46
如果配置上述配置,那么我们已经在Linux系统上成功配置了缓存DNS服务器,可以将其用作本地环境中的缓存服务器。