DNS安裝配置全過程_unix linux
來源:互聯網
上載者:User
先從 http://download.chinaunix.net/download/0001000/6.shtml 下載bind,我下載的是bind-9.3.2.tar.gz
我下載的檔案放在/opt/src目錄下
進入目錄解壓縮
[root@linux src]#tar zxvf bind-9.3.2.tar.gz
進如剛解壓出來的目錄
[root@linux src]# cd bind-9.3.2
編譯配置
[root@linux bind-9.3.2]#./configure --prefix=/opt/app/named --enable-threads #--enable-threads開啟多執行緒能力
[root@linux bind-9.3.2]#make
[root@linux bind-9.3.2]#make install
進入/opt/app/named 建立etc目錄
[root@linux bind-9.3.2]#cd /opt/app/named
[root@linux named]# mkdir etc
產生rndc控制命令的key檔案
[root@linux named]# sbin/rndc-confgen > etc/rndc.conf
從rndc.conf檔案中提取named.conf用的key
root@linux named]# cd etc
[root@linux etc]# tail -10 rndc.conf | head -9 | sed s/#\ //g > named.conf
自動在/opt/app/named/etc 產生named.conf檔案
建立區檔案目錄
[root@linux etc]# mkdir /var/named
進入/var/named
[root@linux etc]# cd /var/named
建立localhost.zone檔案
[root@linux named]#vi localhost.zone
$TTL 86400
$ORIGIN localhost.
@ 1D IN SOA @ root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
1D IN NS @
1D IN A 127.0.0.1
建立named.local檔案
[root@linux named]#vi named.local
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.
dig命令直接產生named.root檔案
[root@linux named]#dig > named.root
建立test.com網域名稱正向解析檔案
[root@linux named]#vi test.zone
$ttl 1D
@ IN SOA test.com. root.test.com. (
1053891162
3H
15M
1W
1D )
IN NS test.com.
IN MX 5 test.com.
www IN A 220.202.19.82
建立test.com網域名稱反向解析檔案
[root@linux named]#vi test.local
$TTL 86400
@ IN SOA test.com. root.test.com.(
20031001;
7200;
3600;
43200;
86400);
@ IN NS test.com.
82 IN PTR dns.test.com.
配置named.conf加如以下代碼
[root@linux etc]# vi named.conf
options {
directory "/var/named"; #named區檔案目錄
pid-file "named.pid"; #進程id檔案名稱
};
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
zone "." IN {
type hint;
file "named.root";
};
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 "test.com" IN {
type master;
file "test.zone";
allow-update { none; };
};
zone "19.202.220.in-addr.arpa" IN {
type master;
file "test.local";
allow-update { none; };
};
現在配置完了可以啟動BIND了
/opt/app/named/sbin/named -c /opt/app/named/etc/named.conf
測試DNS
[root@linux etc]# host 220.202.19.82
89.19.202.220.in-addr.arpa domain name pointer dns.test.com.
如上顯示表示DNS反向解析正常
[root@linux etc]# ping www.test.com
PING www.test.com (220.202.19.82) 56(84) bytes of data.
如上顯示表示正向解析正常
DNS配置完成。