Author Topic: config dns server bind กับ support ipv6  (Read 8848 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2141
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
config dns server bind กับ support ipv6
« on: มกราคม 27, 2011, 06:32:06 PM »
วันนี้ ได้ลองเทส ในส่วนของ dns ที่สามารถใช้งานกับ ipv6 ได้ครับ

ผมลองกับ OS : FreebSD 8 น่ะครับ

แรกเริ่มก็ลง bind9 ก่อนครับ

#cd /usr/ports/dns/bind9
#make install clean

เลือก option "SSL" กับ "LINKS"

ลงเสร็จก็เพิ่ม dns enable ใน rc.conf ครับ

##DNS##
named_enable="YES"

แล้วสั่ง start เลยครับ

#/etc/rc.d/named restart

แล้วทำการแก้ไข config "named.conf" โดย


// IPv6 zone files
// ==========
// golfreeze Testing at 27/01/2011
// ==========
//
// First, load the zone for the IPv6 loopback address.
//
zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.int." {
                type master;
                file "localhost";
};

//
//      If your IPv6 domain is "ipv6domain-test.org", you need below zone.
//
zone "v6.ipv6domain-test.org"        {
                type master;
                file "v6.ipv6domain-test.org";
};

//
//      Reverse lookup zones
//      If you have 3ffe:800::/24 pTLA ID, you need below zone.
//
zone "0.8.e.f.f.3.ip6.arpa"      {
                type master;
                file "3ffe:08";
 };

//
//      If you have 3ffe:801::/32 pNLA ID, you need below zone.
//
zone "1.0.8.0.e.f.f.3.ip6.arpa"  {
                type master;
                file "3ffe:801";
};

เสร็จแล้ว save แล้วออกมาครับ

เสร็จแก้ไขไฟล์ "v6.ipv6domain-test.org"

#cd /etc/namedb/
#vi v6.ipv6domain-test.org

; File:v6.ipv6domain-test.org
; IPv6 Domain Test Organization.
; IP v6 test network
;
@               IN      SOA     ns.ipv6domain-test.org.      root.ipv6domain-test.org. (
                                                2011012703
                                                3H      ; refresh
                                                15M     ; retry
                                                1W      ; expiry
                                                1D )    ; minimum
                IN      NS              ns.ipv6domain-test.org.
                IN      NS              ns2.ipv6domain-test.org.
                IN      NS              ns.ipv4domain-test.org.
                IN      MX      10      mail.ipv6domain-test.org.
;
;
; Network names
;
pTLA-ipv6domain-test         IN      AAAA    3FFE:800::
sTLA-ipv6domain-test         IN      AAAA    3FFE:200:0::
                                                        IN      AAAA    3FFE:200:1000::
pNLA-ipv6domain-test         IN      AAAA    3FFE:801::

;
; Local hosts
; ------------------
host1                   IN      AAAA    3FFE:800::2A8:79FF:FE32:1982
host1                   IN      A       222.222.222.222
;                               IN      AAAA    3FFE:800::80
WWW                     IN      CNAME   host1.v6.ipv6domain-test.org.
;      
host2                   IN      AAAA    2001:200:1000:0:25F:23FF:FE80:1234
;
host3                   IN      AAAA    3FFE:801:1000::2EF:6FFF:FE11:2222
host4                   IN      AAAA    3FFE:801:2000:100:280:9AFF:FE80:3333
;
;  Add more hosts !


###แก้ไข localhost
#vi localhost

;File: localhost
@               IN      SOA     ns.ipv6domain-test.org.      root.ipv6domain-test.org. (
                                        3 ; Serial
                                        3H      ; refresh
                                        15M     ; retry
                                        1W      ; expiry
                                        1D )    ; minimum
;
                IN      NS              localhost.
;
localhost.                              IN      A       127.0.0.1
1.0.0.127.in-addr.arpa.         IN      PTR             localhost.
;
localhost.                              IN      AAAA    ::1
;
$ORIGIN 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.int.
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN      PTR             localhost.


แก้ไขไฟล์ 3ffe:801
#vi 3ffe:801

; file: 3ffe:801
; IP v6 reverse lookup addresses for 3ffe:801::/32 zone
;
;
@               IN      SOA     ns.ipv6domain-test.org.      root.ipv6domain-test.org. (
                                                2011012702
                                                3H      ; refresh
                                                15M     ; retry
                                                1W      ; expiry
                                                1D )    ; minimum
                IN      NS              ns.ipv6domain-test.org.
                IN      NS              ns2.ipv6domain-test.org.
                IN      NS              ns.ipv4domain-test.org.
;
;       Subnet 3ffe:801:1000::/64
;
2.2.2.2.1.1.e.f.f.f.f.6.f.e.2.0.0.0.0.1.1.0.8.0.e.f.f.3.ip6.arpa.         IN      PTR             host3.v6.ipv6domain-test.org.
;
;       Subnet 3ffe:801:2000:100::/64
;
3.3.3.3.0.8.e.f.f.f.a.9.0.8.2.0.0.0.1.0.0.0.0.2.1.0.8.0.e.f.f.3.ip6.arpa.               IN      PTR             host4.v6.ipv6domain-tottaro.org.

เสร็จแล้วทำการ reload config
#rndc reload

เช๊ค dig ได้คือ

cherry# dig host4.v6.ipv6domain-test.org any

; <<>> DiG 9.6.1-P1 <<>> host4.v6.ipv6domain-test.org any
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 192
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 0

;; QUESTION SECTION:
;host4.v6.ipv6domain-test.org. IN    ANY

;; ANSWER SECTION:
host4.v6.ipv6domain-test.org. 86400 IN AAAA  3ffe:801:2000:100:280:9aff:fe80:3333

;; AUTHORITY SECTION:
v6.ipv6domain-test.org. 86400 IN     NS      ns.ipv6domain-test.org.
v6.ipv6domain-test.org. 86400 IN     NS      ns2.ipv6domain-test.org.
v6.ipv6domain-test.org. 86400 IN     NS      ns.ipv4domain-test.org.

;; Query time: 0 msec
;; SERVER: 10.0.1.250#53(10.0.1.250)
;; WHEN: Thu Jan 27 18:37:05 2011
;; MSG SIZE  rcvd: 148
« Last Edit: เมษายน 20, 2011, 06:18:52 PM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2141
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: config dns server bind กับ support ipv6
« Reply #1 on: เมษายน 20, 2011, 05:17:47 PM »
ในส่วนนี้ ต้องทำการ เปิดให้ port 53 listening บน ipv6 ด้วยนะครับผม

#vi /etc/namedb/named.conf

listen-on-v6    { ::1; 2403:xxxx:x:x::250; };

#/etc/rc.d/named restart

ลองเช๊คว่า มันเปิด service รองรับที่ server ไว้ยังก็
#netstat -na | grep -i listen

tcp6       0      0 2403:xxxx:x:x::250.53    *.*                    LISTEN

ทำการ test จากเครื่องอื่นได้คือ
แก้ dns ของเครื่อง Test2 (2403:xxxx:x:x:xxx:xxxx:xxxx:79f0)
#vi /etc/resolv.conf
2403:xxxx:x:x::250

แล้วทำการ dig check record ได้ครับ

Test2#dig host4.v6.ipv6domain-test.org any

ก็จะได้คำตอบ คือ

; <<>> DiG 9.7.2-P3 <<>> host4.v6.ipv6domain-test.org any
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29295
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 0

;; QUESTION SECTION:
;host4.v6.ipv6domain-test.org. IN    ANY

;; ANSWER SECTION:
host4.v6.ipv6domain-test.org. 86400 IN AAAA  3ffe:801:2000:100:280:9aff:fe80:3333


« Last Edit: เมษายน 20, 2011, 05:27:10 PM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2141
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: config dns server bind กับ support ipv6
« Reply #2 on: เมษายน 20, 2011, 06:24:36 PM »
#### วิธีเช๊ค AAAA record ของ host ที่ใช้ ipv6 ใน dns record นะครับ
#dig @2403:xxxx:x:x::250 host3.v6.ipv6domain-test.org any

;; QUESTION SECTION:
;host3.v6.ipv6domain-test.org. IN    ANY

;; ANSWER SECTION:
host3.v6.ipv6domain-test.org. 86400 IN AAAA  3ffe:801:1000:0:2ef:6fff:fe11:2222


#### วิธีเช๊ค reverse record ของ host ที่ใช้ ipv6 ใน dns record นะครับ
dig @2403:xxxx:x:x::250 -x 3ffe:801:1000:0:2ef:6fff:fe11:2222

;; QUESTION SECTION:
;2.2.2.2.1.1.e.f.f.f.f.6.f.e.2.0.0.0.0.0.0.0.0.1.1.0.8.0.e.f.f.3.ip6.arpa. IN PTR

;; ANSWER SECTION:
2.2.2.2.1.1.e.f.f.f.f.6.f.e.2.0.0.0.0.0.0.0.0.1.1.0.8.0.e.f.f.3.ip6.arpa. 86400 IN PTR host3.v6.ipv6domain-test.org.

เท่านี้ก็แสดงว่า dns server เรา support ipv6 แล้วครับผม
ลองดูนะครับ อิอิ
 ;)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2141
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: config dns server bind กับ support ipv6
« Reply #3 on: เมษายน 24, 2011, 08:15:13 AM »
วันนี้ได้ลองเทสการทำงานของ ipv6 บน freebsd ดูครับ เลยลองมาเขียนไว้ ฮ่าๆๆๆ

เริ่มต้นด้วย ได้รับ ipv6 มาครับของผมเป็น (/64) = 2403:xxxx:x:x::250

ส่วน gateway ก็เป็น 2403:xxxx:x:x::1

intername = em0

ทำการ set ที่ไฟล์ /etc/rc.conf

#vi /etc/rc.conf

###IPV6 Testing
ipv6_enable="YES"
ipv6_ifconfig_em0="2403:xxxx:x:x::250"
ipv6_defaultrouter="2403:xxxx:x:x::1"
###IPV6 Test

### restart network
#/etc/rc.d/network_ipv6 restart

ถ้าจะทำการเพิ่ม add interface ip ที่ทำ ipv6 ก็
#ifconfig em0 inet6 add 2403:xxxx:x:x::251
ครับ

ถ้าจะทำการลบ delete interface ip ที่ทำ ipv6 ก็
#ifconfig em0 inet6 2403:xxxx:x:x::251 delete
ครับ

Add specific route to host (เพิ่ม)
#route add -inet6 2403:xxxx:x:x::1

Add specific route to network (เพิ่ม)
#route add -inet6 2001:800:40::1 2403:xxxx:x:x::1

Remove specific route (ลบ)
#route delete -inet6 2001:800:40::/48 fe80::209:c0ff:fe30:4357

Add default IPv6 route (เพิ่ม default route)
#route add -inet6 ::/0 2403:xxxx:x:x::1

Remove default IPv6 route (ลบ default route)
#route delete -inet6 ::/0 2403:xxxx:x:x::1

ในส่วนนี้ kernel ต้องถูก enable แล้วนะครับ ไปดูได้จาก

#uname -a

ถ้าเป็น i386 ก็เข้าไปดูได้ที่ #less /usr/src/sys/i386/conf/NS0_FREEBSD62_INET6

options         INET6                   # IPv6 communications protocols

ถ้าเป็นอย่างนี้ แสดงว่าถูก enable ไว้แล้วครับ แต่ถ้ายังก็ ทำการ compile kernel ให้ support INET6 ครับ

#config NS0_FREEBSD62_INET6
#cd /usr/src

#make kernel KERNCONF=NS0_FREEBSD62_INET6
#make installkernel KERNCONF=NS0_FREEBSD62_INET6

เสร็จแล้วทำการ restart เครื่อง 1 รอบครับ เท่านี้ ก็ลองเทสได้เลยครับผม

ns0# dig @2403:xxxx:x:x::100 www.kame.net any

; <<>> DiG 9.3.3 <<>> @2403:xxxx:x:x::100 www.kame.net any
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45430
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 5

;; QUESTION SECTION:
;www.kame.net.                  IN      ANY

;; ANSWER SECTION:
www.kame.net.           85196   IN      CNAME   orange.kame.net.

;; AUTHORITY SECTION:
kame.net.               85196   IN      NS      orange.kame.net.
kame.net.               85196   IN      NS      mango.itojun.org.

;; ADDITIONAL SECTION:
mango.itojun.org.       2397    IN      A       210.155.141.200
mango.itojun.org.       2398    IN      AAAA    2001:2f0:0:8800::1:1
mango.itojun.org.       2398    IN      AAAA    2001:2f0:0:8800:206:5bff:fe8d:940
orange.kame.net.        85235   IN      A       203.178.141.194
orange.kame.net.        85196   IN      AAAA    2001:200:dff:fff1:216:3eff:feb1:44d7

;; Query time: 0 msec
;; SERVER: 2403:xxxx:x:x::100#53(2403:xxxx:x:x::100)
;; WHEN: Sun Apr 24 08:13:38 2011
;; MSG SIZE  rcvd: 211

แค่นี้ก็แสดงว่า เครื่อง DNS เรา support IPV6 แล้วครับผม อิอิ