构建缓存域名服务器



1.建立named.conf主配置文件

  • 在参考范本文件建立named.conf文件时,注意要将默认的“listen-on port 53 { 127.0.0.1; };”修改为“listen-on port 53 { 192.168.1.5; };”或者直接注释掉这一行,这样才能为局域网内其他客户机提供服务(否则只能本机使用)
  • 如果使用forwarders转发机制,则需要指定的转发DNS服务器可用(例如网通、电信等ISP提供的公共DNS服务器等)
  • 使用转发机制时,可以不添加根区域

配置文件

options {
        ……
        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";
        recursion  yes;
        …… 
};
zone "." IN {
        type hint;
        file "named.ca";
};

修改配置文件

options {
        ……
        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";
        recursion  yes;
        forwarders { 202.106.0.20; 202.106.148.1; };
};

2.确认建立named.ca根区域数据文件

[root@bourn named]# grep -v "^;" named.ca


.            518400    IN    NS    M.ROOT-SERVERS.NET.
.            518400    IN    NS    A.ROOT-SERVERS.NET.
.            518400    IN    NS    B.ROOT-SERVERS.NET.
.            518400    IN    NS    C.ROOT-SERVERS.NET.
.            518400    IN    NS    D.ROOT-SERVERS.NET.
.            518400    IN    NS    E.ROOT-SERVERS.NET.
.            518400    IN    NS    F.ROOT-SERVERS.NET.
.            518400    IN    NS    G.ROOT-SERVERS.NET.
.            518400    IN    NS    H.ROOT-SERVERS.NET.
.            518400    IN    NS    I.ROOT-SERVERS.NET.
.            518400    IN    NS    J.ROOT-SERVERS.NET.
.            518400    IN    NS    K.ROOT-SERVERS.NET.
.            518400    IN    NS    L.ROOT-SERVERS.NET.

A.ROOT-SERVERS.NET.    3600000    IN    A    198.41.0.4
A.ROOT-SERVERS.NET.    3600000    IN    AAAA    2001:503:ba3e::2:30
B.ROOT-SERVERS.NET.    3600000    IN    A    192.228.79.201
C.ROOT-SERVERS.NET.    3600000    IN    A    192.33.4.12
D.ROOT-SERVERS.NET.    3600000    IN    A    128.8.10.90
E.ROOT-SERVERS.NET.    3600000    IN    A    192.203.230.10
F.ROOT-SERVERS.NET.    3600000    IN    A    192.5.5.241
F.ROOT-SERVERS.NET.    3600000    IN    AAAA    2001:500:2f::f
G.ROOT-SERVERS.NET.    3600000    IN    A    192.112.36.4
H.ROOT-SERVERS.NET.    3600000    IN    A    128.63.2.53
H.ROOT-SERVERS.NET.    3600000    IN    AAAA    2001:500:1::803f:235
I.ROOT-SERVERS.NET.    3600000    IN    A    192.36.148.17
J.ROOT-SERVERS.NET.    3600000    IN    A    192.58.128.30
J.ROOT-SERVERS.NET.    3600000    IN    AAAA    2001:503:c27::2:30
K.ROOT-SERVERS.NET.    3600000    IN    A    193.0.14.129
K.ROOT-SERVERS.NET.    3600000    IN    AAAA    2001:7fd::1
L.ROOT-SERVERS.NET.    3600000    IN    A    199.7.83.42
M.ROOT-SERVERS.NET.    3600000    IN    A    202.12.27.33
M.ROOT-SERVERS.NET.    3600000    IN    AAAA    2001:dc3::35


[root@bourn named]#

3.启动named服务

service named start

4.验证缓存域名服务器

Windows

C:\Documents and Settings\Administrator> nslookup www.google.com
Server:  192.168.1.5
Address:  192.168.1.5

Non-authoritative answer:
Name:    www-china.l.google.com
Addresses:  64.233.189.147, 64.233.189.104, 64.233.189.99
Aliases:  www.google.com, www.l.google.com

Linux

[root@localhost ~]# vi /etc/resolv.conf
    nameserver 192.168.1.5

results matching ""

    No results matching ""