linux下如何搭建简单的DNS Server

阅读更多

环境:lenovo PC, SUSE Linux 11.1 32bit,BIND 9.5.0-P2

安装步骤:

  1. 采用yast自动安装。安装内容包括:bind,bind-chrootenv ,bind-devel,bind-libs,bind-utils

配置步骤:

  1. whereis named,找到bind的配置文件所在目录。如下在/etc/named.conf

    pandora-test:~ # whereis named
    named: /usr/sbin/named /etc/named.conf /etc/named.d /usr/share/man/man8/named.8.gz

  2. 修改named.conf
    2.1. 去掉注释并修改监听端口: listen-on port 53 { 172.16.39.86; };
    2.2. 添加域名解析和反向解析配置:

    zone "p.com" in {
    type master;
    file "p.com.zone";
    };

    zone "39.16.172.in-addr.arpa" in{
    type master;
    file "172.16.39.zone";
    };

    2.3 添加2.2中所指定的域名解析和反向解析的具体配置文件。如:p.com.zone,172.16.39.zone

    在文件夹/var/lib/named下进行添加

    p.com.zone文件内容如下:

    $TTL 1000
    @ IN SOA @ root (
        42 ; serial (d. adams)
        200S ; refresh
        4H ; retry
        1D ; expiry
        100S ) ; minimum
    @ IN NS 172.16.39.86;
    @ IN A 172.16.39.86;
    www A 172.16.39.86;
    pboss A 172.16.39.86;
    confluence A 172.16.39.86;
    redis A 172.16.39.86;
    mysql A 172.16.39.86;
    svn A 172.16.8.159;
    hudson A 172.16.8.159;
    mvnrepo A 172.16.8.159;
    jira A 172.16.8.159;

    172.16.39.zone文件内容如下:

    $TTL 1000
    @ IN SOA localhost. root.localhost. (
        42 ; serial (d. adams)
        200 ; refresh
        400 ; retry
        6000 ; expiry
        1000 ) ; minimum

    IN NS localhost.
    86 IN PTR www.p.com.

验证步骤:

    1. 启动dns server 服务:service named start

    2. 修改本地dns的配置,将首选dns的地址配置为运行dns server的服务器地址

    3. 运行命令:nslookup www.p.com

         返回结果如下:

               服务器: www.p.com
               Address: 172.16.39.86

               名称: www.p.com
               Address: 172.16.39.86

    如果返回内容为:** server can't find ww.p.com: NXDOMAIN

    则表示dns server配置有误,需检查相关配置

你可能感兴趣的:(bind,dns,linux)