2010年1月25日 星期一

Linux設定DNS Server (CentOS 5.4)

檢查bind相關套件,有缺就裝
[root@ns1 ~]# rpm -qa | grep ^bindbind-chroot-9.3.4-10.P1.el5
bind-libs-9.3.4-10.P1.el5
bind-9.3.4-10.P1.el5
bind-utils-9.3.4-10.P1.el5
[root@ns1 ~]# yum -y install bind bind-chroot bind-utils
檢查caching-nameserver相關套件,有缺就裝

[root@ns1 ~]# rpm -q caching-nameservercaching-nameserver-9.3.4-10.P1.el5

[root@ns1 ~]# yum -y install caching-nameserver
重新啟動bind
[root@ns1 ~]# /etc/rc.d/init.d/named restart
設定開機自動執行
[root@ns1 ~]# chkconfig named on
修改DNS的設定檔
[root@ns1 ~]# vi /etc/named.caching-nameserver.conf
options {
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
# 有多少個zone就要有多少個檔案
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 "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
# 依各人domain不同,自行做修改
zone "bear110.com" IN {
type master;
file "named.bear110.com";
 
# 有第二台DNS主機才需要設定
allow-transfer { 100.100.100.100; };
};

# 主機在內網才需要設
zone "0.168.192.in-addr.arpa" {
type master;
file "named.192.168.0";
};
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; };
};
 
建立一個named.bear110.com檔
[root@ns1 ~]# vi /var/named/chroot/var/named/named.bear110.com
$TTL 86400
@ IN SOA ns1.bear110.com. root.bear110.com. (
42 ; Serial
3H ; Refresh
15M ; Retry
1W ; Expire
1D ) ; Minimum
@ IN NS ns1.bear110.com.
@ IN NS ns2.bear110.com.
ns1 IN A 100.100.100.100
ns2 IN A 200.200.200.200
@ IN MX 10 ms1
@ IN MX 20 ms2
ms1 IN A 100.100.100.100
ms2 IN A 200.200.200.200
www IN A 100.100.100.100
ftp IN CNAME www
※ 文字最後沒有一點的話代表會自動補上zone的domain例:ns1=ns1.bear110.com
符號說明:
@:當地的 domain 簡寫,也就是 bear110.com
;:這個符號代表註解,在 ; 之後的文字將被視為無效。
建立一個named.192.168.0檔,主機在內網才需要設
[root@ns1 ~]# vi /var/named/chroot/var/named/named.192.168.0$TTL 86400
@ IN SOA ns1.bear110.com. root.bear110.com. (
42 ; Serial
3H ; Refresh
15M ; Retry
1W ; Expire
1D ) ; Minimum

@ IN NS ns1.bear110.com.
7 IN PTR ns1.bear110.com.
slave DNS 的設定
[root@ns2 ~]# vi /etc/named.caching-nameserver.conf....前面省略....
zone "bear110.com" {
type slave;
file "named.bear110.com";
masters { 100.100.100.100; };
};
將/var/named/chroot/var/named資料夾的使用者和群組都設定成named
[root@slave ~]#chown named:named /var/named/chroot/var/named
在slave DNS當中,這三個zone的類型分別是hint與master,
所以當然要預設存在, 至於那個named.bear110.com就不要存在!
因為這個zone file是由master DNS主機傳送過來的!
最後再重新啟動bind
[root@ns1 ~]# /etc/rc.d/init.d/named restart
測試郵件位址的MX記錄已正確設定
[root@ns1 /]# host -t mx bear110.com 168.95.1.1Using domain server:
Name: 168.95.1.1
Address: 168.95.1.1#53
Aliases:
bear110.com mail is handled by 10 ms1.bear110.com.
[root@ns1 /]# host ms1.bear110.com 168.95.1.1Using domain server:
Name: 168.95.1.1
Address: 168.95.1.1#53
Aliases:
ms1.bear110.com has address 100.100.100.100

沒有留言:

張貼留言