DNS的原理就不說了,這裏只是作個簡單的配置,也是方便本身記憶,在這裏還要十分感謝
redking老大的教程!
要安裝的bind* 、caching-nameserver 包
一、/var/named/chroot/etc/named.conf
這個文件須要本身建立
options {
listen-on port 53 { 192.168.0.9; };
directory "/var/named";
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";
allow-query { 192.168.0.0/24; };
};
zone "." IN {
type hint;
file "named.ca";
};
zone "test.com" IN {
type master;
file "test.com.zone";
};
zone "0.168.192.in-addr.arpa" IN {
type master;
file "0.168.192.in-addr.arpa.zone";
};
檢驗:
named-checkconf /var/named/chroot/etc/named.conf
二、/var/named/chroot/var/named/test.com.zone
正向解析
$TTL 86400
@ IN SOA mail.test.com. root.test.com. (
2009060500 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS mail.test.com.
mail IN A 192.168.0.9
@ IN MX 5 mail.test.com.
mail IN A 192.168.0.9
www IN A 192.168.0.99
檢驗:
named-checkzone test.com /var/named/chroot/var/named/test.com.zone
三、/var/named/chroot/var/named/0.168.192.in-addr.arpa.zone
反向解析
$TTL 86400
@ IN SOA mail.test.com. root.test.com. (
2009060500 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS mail.test.com.
9 IN PTR mail.test.com.
@ IN MX 5 mail.test.com.
9 IN PTR mail.test.com.
99 IN PTR
www.test.com
.
named-checkzone test.com /var/named/chroot/var/named/0.168.192.in-addr.arpa.zone
四、主意文件的權限是644
/var/named/chroot/var/named/
-rw-r--r-- 1 root root 306 Jul 15 04:08 0.168.192.in-addr.arpa.zone
-rw-r--r-- 1 root root 300 Jul 15 03:57 test.com.zone
/var/named/chroot/etc/
-rw-r--r-- 1 root root 486 Jul 15 03:27 named.conf
五、更改你的/etc/resolv.conf
nameserver 192.168.0.9
六、測試
dig -t soa test.com
dig -t mx michael.com
dig mail.michael.com
dig -x 192.168.0.9
nslookup
********************************************************************
輔助DNS
一、在主的DNS named.conf 加一條 allow-transfer {192.168.0.8;}; 意思是容許8這臺機器複製主DNS文件
二、8這臺機named.conf的配置
options {
directory "/var/named";
};
zone "test.com" IN {
type slave;
file "slaves/test.com.zone";
masters { 192.168.0.9; };
};
zone "0.168.192.in-addr.arpa" IN {
type slave;
file "slaves/0.168.192.in-addr.arpa.zone";
masters { 192.168.0.9; };
};
三、重啓named服務後,若是成功的話在 /var/named/chroot/ver/named/slaver 下會出現兩個文件,是從主DNS那裏複雜過來的。若是不成功,有多是iptables的問題。
-rw-r--r-- 1 named named 464 03-09 19:21 0.168.192.in-addr.arpa.zone
-rw-r--r-- 1 named named 427 03-09 19:20 test.com.zone
四、修改 /etc/resolv.conf ,改變成 nameserver 127.0.0.1
五、而後測試下,沒問題就是成功了!
********************************************************************
添加多條網段DNS
options {
listen-on port 53 { 192.168.0.9; };
directory "/var/named";
allow-transfer {192.168.0.8;};
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";
allow-query { 192.168.0.0/24; };
};
zone "." IN {
type hint;
file "named.ca";
};
zone "test.com" IN {
type master;
file "test.com.zone";
};
zone "0.168.192.in-addr.arpa" IN {
type master;
file "0.168.192.in-addr.arpa.zone";
};
zone "dony.boob" IN {
type master;
file "dony.boob.zone";
};
zone "1.168.192.in-addr.arpa" IN {
type master;
file "1.168.192.in-addr.arpa.zone";
};
zone "yoyo.boob" IN {
type master;
file "yoyo.boob.zone";
};
zone "2.168.192.in-addr.arpa" IN {
type master;
file "2.168.192.in-addr.arpa.zone";
};
添加相應的正反向文件,
-rw-r--r-- 1 root root 399 Jul 18 06:05 0.168.192.in-addr.arpa.zone
-rw-r--r-- 1 root root 321 Jul 18 06:48 1.168.192.in-addr.arpa.zone
-rw-r--r-- 1 root root 228 Jul 18 07:18 2.168.192.in-addr.arpa.zone
drwxrwx--- 2 named named 4096 Jul 15 04:14 data
-rw-r--r-- 1 root root 224 Jul 18 06:57 dony.boob.zone
-rw-r----- 1 root named 198 Jul 19 2007 localdomain.zone
-rw-r----- 1 root named 195 Jul 19 2007 localhost.zone
-rw-r----- 1 root named 427 Jul 19 2007 named.broadcast
-rw-r----- 1 root named 2518 Jul 19 2007 named.ca
-rw-r----- 1 root named 424 Jul 19 2007 named.ip6.local
-rw-r----- 1 root named 426 Jul 19 2007 named.local
-rw-r----- 1 root named 427 Jul 19 2007 named.zero
drwxrwx--- 2 named named 4096 Jul 27 2004 slaves
-rw-r--r-- 1 root root 365 Jul 18 06:06 test.com.zone
-rw-r--r-- 1 root root 225 Jul 18 07:17 yoyo.boob.zone