因為目前學校用來建置 DNS Server 的系統為 CentOS 5.x,系統比較老舊一些,雖然它的支援期到 2017-03-31,但考量到 DNS Server 的負載沒那麼重,所以找了一台比較輕量級的電腦來擔任 DNS Server 的工作,替換下來的主機則可以做其它的用途。
參考網頁:Setup DNS Server On Debian 7 Wheezy | Unixmen
1. 安裝 DNS Server
# apt-get install bind9 bind9utils bind9-doc dnsutils
[@more@]2. 備份原設定檔
# cp /etc/bind/named.conf.local /etc/bind/named.conf.local.$(date +%F)
3. 修改 /etc/bind/named.conf.local 設定檔
zone “test.ilc.edu.tw” IN {
type master;
file “/etc/bind/db.test.ilc.edu.tw”;
};
zone “1.168.192.in-addr.arpa” IN {
type master;
file “/etc/bind/db.1.168.192”;
};
4. 修改 /etc/bind/db.test.ilc.edu.tw 設定檔
# cp /etc/bind/db.local /etc/bind/db.test.ilc.edu.tw
# vim /etc/bind/db.test.ilc.edu.tw
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA dns.test.ilc.edu.tw. root.dns.test.ilc.edu.tw. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS dns.test.ilc.edu.tw.
@ IN A 192.168.1.2
@ IN AAAA ::1
test.ilc.edu.tw. IN A 192.168.1.2
www IN A 192.168.1.1
dns IN A 192.168.1.2
ftp IN A 192.168.1.3
5. 修改 /etc/bind/db.1.168.192 設定檔
# cp /etc/bind/db.127 /etc/bind/db.1.168.192
# vim /etc/bind/db.1.168.192
;
; BIND reverse data file for local loopback interface
;
$TTL 604800
@ IN SOA dns.test.ilc.edu.tw. root.dns.test.ilc.edu.tw. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS dns.test.ilc.edu.tw.
;
1 IN PTR www.test.ilc.edu.tw.
2 IN PTR dns.test.ilc.edu.tw.
3 IN PTR ftp.test.ilc.edu.tw.
6. 重新啟動 DNS Server
# service bind9 restart
7. 進行測試
# host 192.168.1.3 192.168.1.2
Using domain server:
Name: 192.168.1.2
Address: 192.168.1.2#53
Aliases:
3.1.168.192.in-addr.arpa domain name pointer ftp.test.ilc.edu.tw.
# host ftp.test.ilc.edu.tw 192.168.1.2
Using domain server:
Name: 192.168.1.2
Address: 192.168.1.2#53
Aliases:
ftp.test.ilc.edu.tw has address 192.168.1.3
8. 在防火牆中設定
防火牆上的設定
# iptables -A INPUT -p udp -m state –state NEW -m udp –dport 53 -j ACCEPT