สำนักวิทยบริการและเทคโนโลยีสารสนเทศ (สวส.)

Office of Academic Resources and Information Technology

DNS Setup สำหรับ IPv6

1. ติดตั้ง DNS บน Ubunut ด้วย software bind9 ด้วยคำสั่ง 
   # sudo aptitude install bind9
2. ทำการตั้งค่า config ของโปรแกรม เพื่อให้บริการ Name Server ด้วย IPv6 เบื้องต้นด้วยโปรแกรม Editor ทั่วไปในที่นี้ใช้คำสั่ง
  # sudo vi /etc/bind/name.conf.local
----------------------------------------------------------------------
//
// Do any local configuration here
//
zone "rmutsv.ac.th" {
        type master;
        file "/etc/bind/db.rmutsv.ac.th";
        notify yes;
};
zone "1.0.0.1.c.0.0.9.8.c.3.0.1.0.0.2.ip6.arpa" {
        type master;
        file "/etc/bind/db.1001-900c-03c8-2001.ip6.arpa";
        notify yes;
};
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
--------------------------------------------------------------------
3. จากนั้นทำการกำหนด zone file ที่มีชื่อตามที่เราตั้งไว้ในที่นี้ชื่อ db.rmutsv.ac.th ด้วยคำสั่ง
  #vi /etc/bind/db.rmutsv.ac.th
  และทำการเพิ่มค่า config ตามตัวอย่าง
-----------------------------------------------------------------------------------
 $TTL 3d ; Default TTL (bind 8 needs this, bind 9 ignores it)
rmutsv.ac.th.      IN      SOA     ubuntu6.rmutsv.ac.th. admin.rmutsv.ac.th. (
                        20140719        ;Serial number (YYYYMMdd)
                        24h             ; Refresh time
                        30m             ; Retry time
                        2d              ; Expire time
                        3d              ; Default TTL (bind 8 ignore this, bind 9 needs it)
)
                                        ; Name server entries
rmutsv.ac.th.        IN      NS      ubuntu6
rmutsv.ac.th.        IN      NS      www6
@                       IN      MX      10      mail6.rmutsv.ac.th.
mail6                   IN      AAAA    2001:3c8:900c:1001::2
ubuntu6              IN      AAAA    2001:3c8:900c:1001::2
www6                 IN      AAAA    2001:3c8:900c:1001::3
www3                 IN      CNAME   ubuntu6
------------------------------------------------------------------------
** ค่า paramitor Syntex ต่าง ๆ สามารถหาข้อมูลเพิ่มเติมได้ที่ http://www.debianhelp.co.uk/dnsrecords.htm
4. จากนั้นสร้าง zone file ที่มีชื่อว่า "db.1001-900c-03c8-2001.ip6.arpa" ตามตำแหน่งที่ระบุใน fiel name.conf.local ด้วยคำสั่ง 
  #vi db.1001-900c-03c8-2001.ip6.arpa
และทำการเพิ่มค่า config ตามตัวอย่าง
----------------------------------------------------------------------
$ORIGIN 1.0.0.1.c.0.0.9.8.c.8.0.1.0.0.2.ip6.arpa.
$TTL 3d ; Default TTL (bine 8 needs this, bind 9 ignores it)
@       IN      SOA     ubuntu6.rmutsv.ac.th. admin.rmutsv.ac.th. (
                201407020       ; Serial number (YYYYMMdd)
                24h             ; Refresh time
                30m             ; Retry time
                2d              ; Expire time
                3d              ; Default TTL (bind 8 ignores this, bind 9 needs it)
)
                                IN      NS      ubuntu6.rmutsv.ac.th.
2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN      PTR     bunutu6.rmutsv.ac.th.
3.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN      PTR     www6.rmutsv.ac.th.
---------------------------------------------------------------------------
5. ทำการแก้ไข file name.conf.options เพื่อให้สามารถรองรับ IPv6 Address ตามนี้
  #vi named.conf.options
ทำการแก้ file ตามนี้
-----------------------------------------------------------
/ forwarders {
        //      0.0.0.0;
        // };

        //========================================================================
        // If BIND logs error messages about the root key being expired,
        // you will need to update your keys.  See https://www.isc.org/bind-keys
        //========================================================================
        dnssec-validation auto;

        auth-nxdomain no;    # conform to RFC1035
        listen-on-v6 { any; };
        allow-query { any; };
};
----------------------------------------------------------------
6. ทำการตรวจเช็คความถูกต้องของ file config ด้วยคำสั่งต่อไปนี้
  #named-checkconf /etc/bind/named.conf
  #named-checkzone rmutsv.ac.th /etc/bind/db.rmutsv.ac.th
  #named-checkzone 1.0.0.1.c.0.0.9.0.3.c.8.1.0.0.2.ip6.arpa /etc/bind/db.1001-900c-03c8-2001.ip6.arpa
7. จากนั้นให้ restart service ด้วยคำสั่ง
 #/etc/init.d/bind9 restart
 ดูข้อผิดพลาดของ config ต่างได้ที่ Log file
 # tail -f /var/log/syslog
จากนั้น ทดสอบโดยการแก้ไข file /etc/resolve.conf เพื่อทดสอบเพิ่มค่า
#vi /etc/resolve.conf
search rmutsv.ac.th
nameserver 2001:3c8:900c:1001::2
จากนั้นทดสอบด้วยคำสั่ง host 
#host ubuntu6.rmutsv.ac.th
#host mail6.rmutsv.ac.th
#host www6.rmutsv.ac.th
หรือ คำสั่ง nslookup
# nslookup -type=AAAA ubuntu6.rmutsv.ac.th
Server:         127.0.0.1
Address:        127.0.0.1#53

ubuntu6.rmutsv.ac.th    has AAAA address 2001:3c8:900c:1001::2 
--------------------------------------------------------
หรือทดสอบใน windows
C:\Users\admin>nslookup www6.rmutsv.ac.th
Server:  UnKnown
Address:  2001:3c8:900c:1001::2

Name:    www6.rmutsv.ac.th
Address:  2001:3c8:900c:1001::3
---------------------------------------------------------