This is G o o g l e's cache of http://www.debianclub.com/node/47 as retrieved on 15 Feb 2007 21:49:37 GMT.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
This cached page may reference images which are no longer available. Click here for the cached text only.
To link to or bookmark this page, use the following url: http://www.google.com/search?hl=en&q=cache%3Ahttp%3A%2F%2Fwww.debianclub.com%2Fnode%2F47&btnG=Search


Google is neither affiliated with the authors of this page nor responsible for its content.

User login

Links

debianclub.com
debian.org
ubuntuclub.com
blognone.com

Syndicate

Syndicate content

ลูกเล่นของ BIND9 DNS Server!

|

จากบทความของ คุณ wd "ติดตั้ง​ DNS ​แบบง่าย" ทำให้นึกถึงเทคนิคเล็ก ๆ น้อย ๆ ที่ผมใช้บ่อยมาก ๆ ก็คือ กรณีที่เราต้องการจะได้รายชื่อ

client001 = 192.168.1.101
client002 = 192.168.1.102
client003 = 192.168.1.103
.
.
.
client100 = 192.168.1.200

จะเห็นว่า ถ้าต้องนั่งพิมพ์นี่ ต้องปาดเหงื่อกันเลยทีเดียว -_-' หรือผู้เชี่ยวชาญบางท่านอาจบอกว่า เขียนสคริปต์เอาก็ได้ ใช่ครับทำอย่างนั้นก็ไม่ผิด แต่ทาง BIND Server มีทางเลือกที่ดีกว่าให้ครับผม นั่นก็คือ

Syntax: $GENERATE range lhs type rhs [ comment ]

  • range = start-stop หรือ start-stop/step ถ้าไม่กำหนด step จะเป็น 1
  • lhs = ข้อมูลของ Record โดยมีเครื่องหมาย $ แทนตัวเลขที่เรากำหนดใน range และกำหนดค่าเพิ่มเติมได้ ${offset[,width[,base]]}
    • offset = ตัวเลขที่จะบวกเพิ่ม หรือลบออก จากตัวเลขที่กำหนดใน range
    • width = ความกว้างของตัวเลขที่จะแสดงใน Record เช่น 3 ตัวเลขที่ได้คือ 001, 002 เป็นต้น
    • base = ฐานของเลข d สำหรับฐานสิบ, o สำหรับฐานแปด, x หรือ X สำหรับฐานสิบหก
  • type = ชนิดของ Record : PTR, CNAME, DNAME, A, AAAA และ NS
  • rhs = ข้อมูลของ Record กำหนดเช่นเดียวกับ lhs

ตัวอย่าง
# vi example.com.zone

.
.
.
$GENERATE 101-200 client${-100,3,d} A 192.168.1.$

# vi example.com.reverse

.
.
.
$GENERATE 101-200 $ PTR client${-100,3,d}

# /etc/init.d/bind9 restart

ทดสอบลองดูตัวสุดท้ายเลยละกันครับ ถ้าได้ ก็น่าจะได้ทั้งหมด แต่จะทดสอบทั้งหมดก็ไม่ว่ากันครับ อิอิ :)

# nslookup client100.example.com

Server: 192.168.1.1
Address: 192.168.1.1#53

Name: client100.example.com
Address: 192.168.1.200

# nslookup 192.168.1.200

Server: 192.168.1.1
Address: 192.168.1.1#53

200.1.168.192.in-addr.arpa name = client100.example.com.

ผลที่ได้เป็นไปตามที่กำหนดไว้ข้างต้น ประหยัดแรงไปได้เยอะเลยครับผม

แจ่มจริงๆ

แจ่มจริงๆ อ่านจบผมนำไปใช้เลยครับ ขอบคุณครับ