Thursday, April 03, 2008

DNS SRV

ย้อนนิดนึงก่อน
คราวก่อนได้เคยเขียนเรื่อง SVN Checkout ซึ่งเป็น tools ใช้ในการดูด code มาเป็น version คล้ายๆ CVS

อย่าสับสนกับ CSV นะ อันนั้นมันคือ comma spreaded value หรือ comma spreaded variable
เป็นการบอกว่าแบ่ง field ต่างๆของข้อมูลด้วยเครื่องหมาย คอมม่า (,) เฉยๆ ซึ่งถ้าเปิดด้วย excel ก็จะแบ่งเป็น col และ row ชัดเจนเหมือนเป็นไฟล์ excel ธรรมดา ที่ไม่มีกราฟหรือรูปหรือฟอร์แมตใดๆ

วันนี้อยากเขียนถึง SRV เพราะเกิดอาหารลืมเล็กน้อย มันคืออะไร
ดูข้อมูลจาก

http://en.wikipedia.org/wiki/SRV_record#Load_balancing_with_SRV
http://www.voip-info.org/wiki-DNS+SRV

ก็จะรู้ว่ามันคือ Record นึงใน DNS หรือ Domain Name Server นั่นเอง
DNS มันจะทำหน้าที่ Resolve จาก Name มาเป็น IP ให้ได้ จากคำถามว่า Domain นั้นอยู่ไหน
(ในทางกลับกันก็น่าจะได้ ต้องไปดูเรื่อง DNS ต่อนะครับ)
มันจะดูว่าตัวเองรู้จักไหมเป็นเจ้าของ host นั้นที่ต้องการไหม หรือมีสิทธิ์ในการตอบคำถามนั้นหรือเปล่า
ถ้ารู้ก็ตอบเลย แต่ถ้าไม่รู้จะมีสองวิธี
โดยการถามต่อให้ทราบว่า package ที่เข้ามาจะต้องไปทางไหนต่อ จาก DNS ที่อยู่สูงขึ้นไปให้เอง เสียสละสุดๆ
หรือแค่บอกทางที่จะต้องไปถามต่อเองก็ได้ คือบอกตำแหน่งของ DNS ตัวนั้น ก็ชี้บอกทางเหมือนเราถามทาง คนข้างทางคงไม่ไปส่งเราถึงที่ถูกไหม

มันเรียนรู้โดยเก็บไว้เป็น Record
ตอนเรียนเราเรียนแค่ A กะ MX (ที่จริงน่าจะมากกว่านี้ แต่ที่ยังหลงเหลือในความทรงจำโดยไม่ต้องเปิดอ่านมีเท่านี้หละ)

A คือ host
MX คือ mail

เอ้อมีเรื่อง CNAME อะไรอีกนี่หละ ต้องไปหา wiki มาเพิ่ม

SRV ก็คืออีกชนิดนึงของ Record เข้าใจว่าไว้ทำพวก load balance ได้ โยจะ redirect ไปยังเครื่องที่ควรจะไปได้

มี Format แบบเนี้ย

An SRV record has the form:

_Service._Proto.Name TTL Class SRV Priority Weight Port Target

Service: the symbolic name of the desired service.
Proto: the protocol of the desired service; this is usually either TCP or UDP.
Name: the domain name for which this record is valid.
TTL: standard DNS time to live field.
Class: standard DNS class field (this is always IN).
Priority: the priority of the target host, lower value means more preferred.
Weight: A relative weight for records with the same priority.
Port: the TCP or UDP port on which the service is to be found.
Target: the canonical hostname of the machine providing the service.

An example SRV record might look like this using bind syntax:

_sip._tcp.example.com. 86400 IN SRV 0 5 5060 sipserver.example.com.

Or like this using djbdns syntax:

S_sip._tcp.example.com:::5060:5:0:86400:

This points to a server named sipserver.example.com listening on TCP port 5060 for SIP protocol connections. The priority given here is 0, and the weight is 5.

As with PTR records, SRV records must point to the canonical name of the host. Aliases or CNAMEs cannot be used as valid targets.

ก็ยังไม่รู้อยู่ดีว่าจะ setup connection manager สำหรับ openfire ยังไงอะ

No comments: