BIND 9 例子

目前我不打算介绍如何配置Bind,Windows DNS Server,主要是没有时间去写,以后我会加上.

我做过Bind 9做主DNS,windows DNS Server 做辅助DNS,让他们同步数据. 这样可以在WIN DNS看到域名信息,比较直观,也很方便。如果你有兴趣可以自己做试验

这里我只给出一个例子。首先配置/etc/resolv.conf文件

[root@linux src]# cat /etc/resolv.conf
nameserver 127.0.0.1
nameserver 202.96.128.68
nameserver 218.30.103.50
nameserver 202.106.169.100
[root@linux src]#
		

配置/etc/named.conf文件

[root@linux src]# cat /etc/named.conf
// generated by named-bootconf.pl

options {
        directory "/var/named";
        /*
         * 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;
};

//
// a caching only nameserver config
//
controls {
        inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
zone "." IN {
        type hint;
        file "named.ca";
};

zone "localhost" IN {
        type master;
        file "localhost.zone";
        allow-update { none; };
};

zone "0.0.127.in-addr.arpa" IN {
        type master;
        file "named.local";
        allow-update { none; };
};
zone "example.net" IN {
        type master;
        file "example.net";
        allow-update { none; };
};
include "/etc/rndc.key";
		

创建文件/var/named/example.net

[root@linux src]# cat /var/named/example.net
@ IN SOA        example.net. root.example.net. (
                          200211131 ; serial, todays date + todays serial #
                          28800 ; refresh, seconds
                          7200 ; retry, seconds
                          3600000 ; expire, seconds
                          86400 ) ; minimum, seconds
        NS ns.example.net.
@       IN A         192.168.0.1
www     IN A         192.168.0.1
mail    IN A         192.168.0.1
@       MX 10 mail.example.net.
[root@linux src]#
		

重新启动BIND(DNS 服务器)

[root@linux src]# service named restart
Stopping named:
[root@linux src]#                                          [  OK  ]
		

测试

[root@linux src]# ping example.net
PING example.net (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.026 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.030 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=0.018 ms

--- example.net ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 7201ms
rtt min/avg/max/mdev = 0.018/0.024/0.030/0.007 ms


[root@linux src]# ping mail.example.net
PING mail.example.net (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.022 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.036 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=0.032 ms

--- mail.example.net ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.022/0.030/0.036/0.005 ms