秋水小筑之Blog
http://blog.chinaunix.net/u/5302/showart_238337.html的博客, 幫了大忙,網(wǎng)上的很多文章都試過(guò)了都沒有很好的結(jié)果.
我安裝的centos是單CD的服務(wù)版本.安裝后已經(jīng)有bind了
1.配置文件在/etc/named.conf
//
// named.conf for Red Hat caching-nameserver
//
options {
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
/*
* 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 "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "chenlb.com" IN {
type master;
file "chenlb.com.zone";
allow-query { any; };
allow-transfer { any; };
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
type master;
file "named.ip6.local";
allow-update { none; };
};
zone "255.in-addr.arpa" IN {
type master;
file "named.broadcast";
allow-update { none; };
};
zone "0.in-addr.arpa" IN {
type master;
file "named.zero";
allow-update { none; };
};
include "/etc/rndc.key";
// named.conf for Red Hat caching-nameserver
//
options {
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
/*
* 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 "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "chenlb.com" IN {
type master;
file "chenlb.com.zone";
allow-query { any; };
allow-transfer { any; };
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
type master;
file "named.ip6.local";
allow-update { none; };
};
zone "255.in-addr.arpa" IN {
type master;
file "named.broadcast";
allow-update { none; };
};
zone "0.in-addr.arpa" IN {
type master;
file "named.zero";
allow-update { none; };
};
include "/etc/rndc.key";
只要添加一個(gè)zone就行,看上面
zone "chenlb.com" IN {
type master;
file "chenlb.com.zone";
allow-query { any; };
allow-transfer { any; };
allow-update { none; };
};
type master;
file "chenlb.com.zone";
allow-query { any; };
allow-transfer { any; };
allow-update { none; };
};
2.在/var/named/chroot/var/named/目錄里建個(gè)chenlb.com.zone(上面的file),內(nèi)容如下:
$TTL 86400
@ IN SOA chenlb.com. root.chenlb.com.(
2008050201 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS chenlb.com.
IN MX 10 mail.chenlb.com.
@ IN A 192.168.0.60
www IN A 192.168.0.60
ftp IN A 192.168.0.60
mail IN A 192.168.0.60
@ IN SOA chenlb.com. root.chenlb.com.(
2008050201 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS chenlb.com.
IN MX 10 mail.chenlb.com.
@ IN A 192.168.0.60
www IN A 192.168.0.60
ftp IN A 192.168.0.60
mail IN A 192.168.0.60
3.在/var/named目錄下建鏈接
# ch /var/named
# ln -s /var/named/chroot/var/named/chenlb.com.zone chenlb.com.zone
# ln -s /var/named/chroot/var/named/chenlb.com.zone chenlb.com.zone
4.啟動(dòng)named
# /etc/init.d/named start
5.測(cè)試前添加nds服務(wù)地址
# vi /etc/resolv.conf
在加
nameserver 192.168.0.60
search chenlb.com
說(shuō)明:192.168.0.60是我本機(jī)地址search chenlb.com
現(xiàn)在本機(jī)下可以ping www.chenlb.com了
要在加的機(jī)上可以使用DNS服務(wù),要在防火墻里允許
6.修改/etc/sysconfig/iptables添加下面的
-A RH-Firewall-1-INPUT -p udp -m udp --dport 53 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT
OK,現(xiàn)在在win里添加dns地址192.168.0.60就在ping www.chenlb.com了. 呵呵