RedHat_(centos5.5)DNS詳細配置說明web
@主DNS服務器配置centos
1、前期準備工做安全
centos 5.5 能上網服務器
2、加載數據包dom
yum -y install caching-nameserver* bind-chroot*ide
所以加載了數據包會有如下這些目錄測試
chroot localdomain.zone named.broadcast named.ip6.local named.zero
data localhost.zone named.ca named.local slaves
ui
3、進行主文件配置spa
一、cd /var/named/chroot/etcdebug
cp -p named.caching-nameserver.conf named.conf
要加-p 由於在複製的時候能夠擁有全部權限
二、修改named.conf文件,內容以下。
options {
listen-on port 53 { any; }; #指定BIND偵聽的本機IP地址53端口收到的DNS查詢請求
listen-on-v6 port 53 { ::1; };
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";
// Those options should be used carefully because they disable port
// randomization
// query-source port 53;
// query-source-v6 port 53;
allow-query { any; }; #接收任何客戶端的DNS查詢請求
allow-query-cache { localhost; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view localhost_resolver {
match-clients { any; }; #指定當前view處理源和目標任意的查詢請求
match-destinations { any; }; #指定當前view處理源和目標任意的查詢請求
recursion yes;
include "/etc/named.zones"; #這一處要跟後面的named.zones的文件相對應
};
這裏只是講述基本功能的實現,沒有考慮安全性的問題,從安全角度來講在指 定 IP地址集合時最好仍是明確指定IP地址或網段,而不要使用「any".
三、cp -p named.rfc1912.zones named.zones
修改named.zones文檔的相應需求,在該文檔的最後添加以下修改過的相應需求
zone "example123.com" IN {
type master;
file "example123.com.zero";
allow-transfer { 192.10.10.55; }; #轉發到輔助服務器去
allow-update { none; };
}; #正向解析區域
zone "100.168.192.in-addr.arpa" IN {
type master;
file "100.168.192.local";
allow-transfer { 192.10.10.55; }; #轉發到輔助服務器去
allow-update { none; };
}; #反向解析區域
四、對正向區域的配置以下
cd /var/named/chroot/var/named
進行這樣的複製與配置
cp -p named.zero example123.com.zero
cp -p named.local 100.168.192.local
修改正向文件的需求example123.com.zero文件,內容以下。
$TTL 86400
@ IN SOA dns.example123.com. root.example123.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS dns.example123.com.
IN MX 10 mail.example123.com.
mail IN A 192.168.100.127
dns IN A 192.168.100.127
www IN CNAME web.example123.com.
web.example123.com. IN A 192.168.100.127
修改反向文件的需求100.168.192.local文件,內容以下。
$TTL 86400
@ IN SOA dns.example123.com. root.example123.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS dns.example123.com.
127 IN PTR mail.example123.com.
127 IN PTR web.example123.com.
通過以上的這些配置,正向區域和反向區域已經配置好了,可是還須要作一些工做
4、修改一些配置
vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 example123.com localhost
::1 localhost6.localdomain6 localhost6
192.168.100.127 mail.example123.com
127.0.0.1 www.example123.com
192.168.100.127 www.example123.com
5、修改/etc/resolv.conf
vi /etc/resolv.conf
; generated by /sbin/dhclient-script
nameserver 192.168.100.127
#nameserver 202.96.134.133
6、一個完整的DNS服務器就成功構建起來了
啓動:service named restart
7、測試結果以下
正向測試
C:\Documents and Settings\Administrator>nslookup www.example123.com
Server: web.example123.com
Address: 192.168.100.127
Name: web.example123.com
Address: 192.168.100.127
Aliases: www.example123.com
反向測試
C:\Documents and Settings\Administrator>nslookup 192.168.100.127
Server: mail.example123.com
Address: 192.168.100.127
Name: web.example123.com
Address: 192.168.100.127
@輔助服務器配置
@輔助服務器的工做,主要是分擔主服務器的解析工做,詳細信息請看下面配置。
1、安裝數據包和主服務器的同樣,其實配置什麼信息都差很少
2、加載數據包
yum -y install caching-nameserver* bind-chroot*
所以加載了數據包會有如下這些目錄
chroot localdomain.zone named.broadcast named.ip6.local named.zero
data localhost.zone named.ca named.local slaves
3、進行主文件配置
一、cd /var/named/chroot/etc
cp -p named.caching-nameserver.conf named.conf
要加-p 由於在複製的時候能夠擁有全部權限
二、修改named.conf文件,內容以下。(這個文檔中的那句轉發命令是在主服務器配置的)
options {
listen-on port 53 { any; }; #指定BIND偵聽的本機IP地址53端口收到的DNS查詢請求
listen-on-v6 port 53 { ::1; };
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";
// Those options should be used carefully because they disable port
// randomization
// query-source port 53;
// query-source-v6 port 53;
allow-transfer { 192.168.100.147; }; #轉發指定到要作輔助DNS的服務器上面去
allow-query { any; }; #接收任何客戶端的DNS查詢請求
allow-query-cache { localhost; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view localhost_resolver {
match-clients { any; }; #指定當前view處理源和目標任意的查詢請求
match-destinations { any; }; #指定當前view處理源和目標任意的查詢請求
recursion yes;
include "/etc/named.zones"; #這一處要跟後面的named.zones的文件相對應
};
這裏只是講述基本功能的實現,沒有考慮安全性的問題,從安全角度來講在指 定 IP地址集合時最好仍是明確指定IP地址或網段,而不要使用「any".
三、cp -p named.rfc1912.zones named.zones
修改named.zones文檔的相應需求,在該文檔的最後添加以下修改過的相應需求
zone "example123.com" IN {
type slave;
masters { 192.168.100.127; };
file "slaves/example123.com.zero";
};
#正向解析區域
zone "100.168.192.in-addr.arpa" IN {
type slave;
masters { 192.168.100.127; };
file "slaves/100.168.192.local";
};
#反向解析區域
四、對正向區域的配置以下
cd /var/named/chroot/var/named
進行這樣的複製與配置
cp -p named.zero example123.com.zero
cp -p named.local 100.168.192.local
修改正向文件的需求example123.com.zero文件,內容以下。
$TTL 86400
@ IN SOA dns.example123.com. root.example123.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS dns.example123.com.
IN MX 10 mail.example123.com.
mail IN A 192.168.100.147
dns IN A 192.168.100.147
www IN CNAME web.example123.com.
web.example123.com. IN A 192.168.100.147
修改反向文件的需求100.168.192.local文件,內容以下。
$TTL 86400
@ IN SOA dns.example123.com. root.example123.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS dns.example123.com.
147 IN PTR mail.example123.com.
147 IN PTR web.example123.com.
通過以上的這些配置,正向區域和反向區域已經配置好了,可是還須要作一些工做
4、修改一些配置
vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
192.10.10.127 ns1.example123.com
192.10.10.147 ns2.example123.com
5、修改/etc/resolv.conf
vi /etc/resolv.conf
; generated by /sbin/dhclient-script
nameserver 192.168.100.147
nameserver 192.168.100.127
二、vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=ns2.example.com #設置主機名
GATEWAY=192.168.100.254
6、一個完整的DNS服務器就成功構建起來了
啓動:service named restart
7、測試結果以下
正向測試
C:\Documents and Settings\Administrator>nslookup www.example123.com
Server: web.example123.com
Address: 192.168.100.147
Name: web.example123.com
Address: 192.168.100.147
Aliases: www.example123.com
反向測試
C:\Documents and Settings\Administrator>nslookup 192.168.100.127
Server: mail.example123.com
Address: 192.168.100.147
Name: web.example123.com Address: 192.168.100.147