欢迎光临
我们一直在努力

Linux 网管 123 — 第7章. 自订的组态及管理内容 -2.DNS

建站超值云服务器,限时71元/月

网域名称伺服器 (DNS) 组态及管理
在我工作的很多地方,我们使用 Linux 作为 DNS 伺服器。它表现的非常好。这一节将会指出使用 Red Hat
发行版内含的标准 BIND 8.x 套件所提供这些服务的 DNS table 组态  
   注意: Red Hat 5.1 及更早的版本使用 BIND 4.x 套件,它的组态档格式有一点点不同。 BIND 8.x 比  
   BIND 4.x 提供更多的功能,而且 4.x 已经不再发展了, 您可能需要考虑升级到最新版的 BIND 套件。
   先安装 BIND RPM 套件 (查看 第10章,使用 Red Hat 套件管理程式 (RPM) 一节 有关使用 RPM 公用程式
   的细节),然後转换您的组态成新的格式。  
幸运地,转换原有的 BIND 4.x 组态档以符合 BIND 8.x 很简单 ! 就像是 BIND 位於文件档的目录下的一部份
(例如, “/usr/doc/bind-8.1.2/” 相对於 BIND version 8.1.2),有一个档叫做 “named-bootconf.pl” ,
这是一个可执行的 Perl 程式。 假设您已经在系统上安装好 Perl,您可以利用这个程式转换您的组态档。键入
下列指令完成它 (以 root 身分):  
  cd /usr/doc/bind-8.1.2
./named-bootconf.pl < /etc/named.boot > /etc/named.conf
mv /etc/named.boot /etc/named.boot-obsolete
  

您现在应该会得到一个可以在 BIND 8.x 下使用的档案 “/etc/named.conf” 。 原有的 DNS table 在新版的
BIND 下也可以使用, 因为 table 的格式还是一样。
  

在 Linux 下组态 DNS 服务与下列步骤有关:  
要起始 DNS 服务, “/etc/host.conf”这个档案看起来应该像下面着个样子:  
  # Lookup names via /etc/hosts first, then by DNS query
order hosts, bind
# We don’t have machines with multiple addresses
multi on
# Check for IP address spoofing
nospoof on
# Warn us if someone attempts to spoof
alert on
  

加大的  spoof 侦测可以增加一点 DNS 搜寻的命中率(管可以忽略),所以如果您不担心这个的话可以  
disable “nospool”及“alert” 项目。  

依需要编辑 “/etc/hosts” 档。一般在这里不必改太多, 但为了增加效率可以增加您最常存取的主机  
(像是本地伺服器) 以避免过度使用 DNS 搜寻在他们身上。  

“/etc/named.conf” 档应该根据下面例组态指出 DNS table  

   (注意:下面的 IP 位址只是例,必须根据您自己的 class 位址更改!):  

options {
        // DNS tables are located in the /var/named directory
        directory "/var/named";

        // Forward any unresolved requests to our ISP’s name server
        // (this is an example IP address only — do not use!)
        forwarders {
                123.12.40.17;
        };

        /*
         * If there is a firewall between you and nameservers you want
         * to talk to, you might need to uncomment the query-source
         * directive below.  Previous versions of BIND always asked
         * questions using port 53, but BIND 8.1 uses an unprivileged
         * port by default.
         */
        // query-source address * port 53;
};

// Enable caching and load root server info
zone "named.root" {
        type hint;
        file "";
};

// All our DNS information is stored in /var/named/mydomain_name.db
// (eg. if mydomain.name = foobar.com then use foobar_com.db)
zone "mydomain.name" {
        type master;
        file "mydomain_name.db";
        allow-transfer { 123.12.41.40; };
};

// Reverse lookups for 123.12.41.*, .42.*, .43.*, .44.* class C’s
// (these are example Class C’s only — do not use!)
zone "12.123.IN-ADDR.ARPA" {
        type master;
        file "123_12.rev";
        allow-transfer { 123.12.41.40; };
};

// Reverse lookups for 126.27.18.*, .19.*, .20.* class C’s
// (these are example Class C’s only — do not use!)
zone "27.126.IN-ADDR.ARPA" {
        type master;
        file "126_27.rev";
        allow-transfer { 123.12.41.40; };
};
  

   小技巧: 注意上面的 allow-transfer 选项,它限制 DNS对於特定 IP 位址的 zone transfer。 举例来说,  
   我们允许位於123.12.41.40 的主机(可能是我们网域上的一个次要 DNS伺服器)请求 zone transfer。如果您
   漏了这个选项,位於 Internet 的任何人都可以请求这个转换。因为这些资讯常被存心不良的人运用,我强
   烈建议您除了到次要 DNS伺服器以外都限制 zone transfer,或使用 loopback address, “127.0.0.1”作为替代。  

现在您可以像在第三步骤组态“/etc/named.conf”档一样,设定位於 “var/named/” 目录的  DNS table 。
第一次组态 DNS 资料库档是个大工程,并且超出本文讨论围。有一些线上及印刷品型式的指南应该参考。然而下
面有提供 一些例。  
位於 “/var/named/mydomain_name.db” 正向查询档的例列:  
  ; This is the Start of Authority (SOA) record.  Contains contact
; & other information about the name server.  The serial number
; must be changed whenever the file is updated (to inform secondary
; servers that zone information has changed).
    @ IN SOA mydomain.name.  postmaster.mydomain.name. (
        19990811        ; Serial number
        3600            ; 1 hour refresh
        300             ; 5 minutes retry
        172800          ; 2 days expiry
        43200 )         ; 12 hours minimum

; List the name servers in use.  Unresolved (entries in other zones)
; will go to our ISP’s name server isp.domain.name.com
        IN NS           mydomain.name.
        IN NS           isp.domain.name.com.

; This is the mail-exchanger.  You can list more than one (if
; applicable), with the integer field indicating priority (lowest
; being a higher priority)
        IN MX           mail.mydomain.name.

; Provides optional information on the machine type & operating system
; used for the server
        IN HINFO        Pentium/350     LINUX

; A list of machine names & addresses
    spock.mydomain.name.    IN A    123.12.41.40   ; OpenVMS Alpha
    mail.mydomain.name.     IN A    123.12.41.41   ; Linux (main server)
    kirk.mydomain.name.     IN A    123.12.41.42   ; Windows NT (blech!)

; Including any in our other class C’s
    twixel.mydomain.name.   IN A    126.27.18.161  ; Linux test machine
    foxone.mydomain.name.   IN A    126.27.18.162  ; Linux devel. kernel

; Alias (canonical) names
    gopher      IN CNAME        mail.mydomain.name.
    ftp         IN CNAME        mail.mydomain.name.
    www         IN CNAME        mail.mydomain.name.
  

位於 “/var/named/123_12.rev” 反向查询档的例列:  
  ; This is the Start of Authority record.  Same as in forward lookup table.
    @ IN SOA mydomain.name.  postmaster.mydomain.name. (
        19990811        ; Serial number
        3600            ; 1 hour refresh
        300             ; 5 minutes retry
        172800          ; 2 days expiry
        43200 )         ; 12 hours minimum

; Name servers listed as in forward lookup table
        IN NS           mail.mydomain.name.
        IN NS           isp.domain.name.com.

; A list of machine names & addresses, in reverse.  We are mapping
; more than one class C here, so we need to list the class B portion
; as well.
    40.41       IN PTR    spock.mydomain.name.
    41.41       IN PTR    mail.mydomain.name.
    42.41       IN PTR    kirk.mydomain.name.

; As you can see, we can map our other class C’s as long as they are
; under the 123.12.* class B addresses
    24.42       IN PTR    tsingtao.mydomain.name.
    250.42      IN PTR    redstripe.mydomain.name.
    24.43       IN PTR    kirin.mydomain.name.
    66.44       IN PTR    sapporo.mydomain.name.

; No alias (canonical) names should be listed in the reverse lookup
; file (for obvious reasons).
  

任何其他的 reverse 搜寻档需要 map 位址,在不同的 class B (像是 126.27.*) 会被建立,并且会和上面
的反向查询档更相似。  

确定 named daemon 正在执行。这个 daemon 通常在系统开机时由“/etc/rc.d/init.d/named” 这个档案启动。  
您也可以手动地启动及停止这个 daemon ; 分别是键入 “named start” 及 “named stop”。  

无论对 DNS table 做了什麽改变,应该键入 “/etc/rc.d/init.d/named restart”重新启动 DNS 伺服器。
您可以使用像是“nslookup”的工具去询问机器以测试您所做的变更。更多有关如何组态 DNS 服务的资料可以
在位於 http://metalab.unc.edu/Linux/HOWTO/DNS-HOWTO-5.html的 “DNS-HOWTO” 指南上找到     
本文Tags:linux   

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Linux 网管 123 — 第7章. 自订的组态及管理内容 -2.DNS
分享到: 更多 (0)

相关推荐

  • 暂无文章