5. rndc
● “remote” name daemon control
$ sudo service bind9 restart
$ sudo rndc reload
$ sudo rndc refresh
– แต่ควรใช้งานบน localhost ของ DNS Server (การรับ
ส่ง key จะไม่ encrypt? – ไม่แน่ใจ)
– server คือตัว named เองแต่ run ที่ port 953 (default)
6. config file หลัก (debian)
●
/etc/bind/named.conf
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.defaultzones";
– options – สำาหรับควบคุม named server
– local – สำาหรับ zone file ของเรา
– defaults-zones สำาหรับ predefined zone และ root
● ไม่จำาเป็ นจะต้องไปแก้ไข
7. Two Roles of Name Server
● Cache Server
– ไม่มีขอมูล zone ของตัวเอง
้
– ทำาหน้าที่ resolve address ให้กับ client
● Authoriative Server
– Primary & Secondary DNS
● เป็ น เจ้าของ ของข้อมูลนั้น
8. DNS Cache Server
● บรรทัด nameserver ใน /etc/resolv.conf
– ตอบคำาถามแก่ client ว่า name หรือ address นั้นมี
ip address หรือ ชื่อ hostname เป็ นอะไร
– โดยทั่วไป จะ recursive lookup จนกระทั่งได้คำา
ตอบ แล้วส่งกลับให้ client
9. Primary/Secondary DNS
● เจ้าของข้อมูล
– มี zone files ของตัวเอง
– ใช้ข้อมูลใน zone file สำาหรับตอบ query ที่รับมา
– โดยทั่วไปจะรับ query request จาก DNS Cache Server อีกทีนึง
● Primary Server
– Authorized zone files
● Secondary Server
– เอาข้อมูล zone มาจาก primary อีกที
– เป็ น backup server
10. Dual Roles
● ใช้ DNS Server ทำาหน้าที่ท้ ง Cache Server และ Authoriative
ั
Server ได้ใหม
– CoE dept. ใช้อยู่
● ninedots.coe.psu.ac.th (primary for coe.psu.ac.th)
● fivedots.coe.psu.ac.th (secondary for coe.psu.ac.th)
● ทั้งสองตัวเป็ น DNS Cache Server สำาหรับ 172.30.0.0/16, 172.31.0.0/16
● แต่ไม่ควรทำา
● ดูคำาแนะนำาจาก http://www.intodns.com/
12. DNS Cache Config (ต่อ)
● สำาหรับ DNS Server ภายใน PSU Network จะต้องส่ง
query ให้กับ {ns,ns2}.psu.ac.th
– firewall ของ PSU CC filter เอาไว้ (แก้ปัญหา malware)
– จะต้องเพิ่ม
forward only;
forwaders { 192.100.77.2; 192.100.77.5; };
– ใน options { … };
13. Primary DNS Config
● เพิ่ม zone config ใน
/etc/bind/named.conf.local
– เช่น สำาหรับ domain cheshirecat2012.net
zone "cheshirecat2012.net" {
type master;
file "master/cheshirecat2012.net";
};
type → master/slave/hints/forward
file → path relative กับ “directory” ใน options
(default คือ /var/cache/bind)
14. Zone file
● ต.ย. zone สำาหรับ cheshirecat2012.net
$ORIGIN .
$TTL 14400 ; 4 hours
cheshirecat2012.net IN SOA ns.cheshirecat2012.net. root.cheshirecat2012.net. (
2012112601 ; serial
14400 ; refresh (4 hours)
3600 ; retry (1 hour)
2419200 ; expire (4 weeks)
14400 ; minimum (4 hours)
)
NS ns1.cjv6.net.
NS ns.cheshirecat2012.net.
MX 10 mx.cheshirecat2012.net.
$ORIGIN cheshirecat2012.net.
ns A 192.100.77.175
mx A 192.100.77.175
อยู่ใน /var/cache/bind/master/cheshirecat2012.net
15. Zone file (cont)
● SOA RR (Resource Record)
– name ttl class rr name-server email-addr (sn ref ret ex min)
cheshirecat2012.net IN SOA ns.cheshirecat2012.net. root.cheshirecat2012.net.
● name – cheshirecat2012.net ($ORIGIN .)
● ttl – ใช้ $TTL ที่กำาหนดไว้
● class – IN (internet ไม่ต้องเปลี่ยน)
● rr – SOA ระบุ type ของ record นี้
●
name-server – ns.cheshirecat2012.net
● email-addr – root@cheshirecat2012.net (เปลี่ยน @ เป็ น .)
17. Zone file (cont)
● Other resource records
NS ns1.cjv6.net.
NS ns.cheshirecat2012.net.
MX 10 mx.cheshirecat2012.net.
$ORIGIN cheshirecat2012.net.
ns A 192.100.77.175
mx A 192.100.77.175
18. ทดสอบ
$ sudo service named restart
$ grep named /var/log/syslog
● ถ้าไม่มี error ก็ทดสอบ query ได้
$ host ns.cheshirecat2012.net localhost
19. เพิ่ม resource record ชนิดอื่น
● TXT – description
● AAAA – IPv6 Address
$ORIGIN cheshirecat2012.net.
60 IN TXT “v=spf1 a a:smtp.cheshirecat2012.net ~all”
www 60 IN AAAA 2001:db8:9009::1
smtp 60 IN A 1.2.3.4
21. Reverse Map Address
● ใช้แปลงจาก address เป็ น name
● domain ใช้ “in-addr.arpa”
● Reverse for 172.30.0.0/24
● zone file name “0.30.172.in-addr.arpa”
● Reverse for 172.30/16
● Zone file name “30.172.in-addr.arpa”
●
22. Reverse Zone File
● ข้อมูลใน Zone File
– SOA เหมือนเดิม
– ใช้ PTR Record สำาหรับระบุ address
; for zone 30.172.inaddr.arpa
5.0 IN PTR fivedots.coe.psu.ac.th.
9.0 IN PTR ninedots.coe.psu.ac.th.
; for zone 0.30.172.inaddr.arpa
5 IN PTR fivedots.coe.psu.ac.th.
9 IN PTR ninedots.coe.psu.ac.th.