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