DEV Community

Cover image for วิธีติดตั้งและกำหนดค่าเบื้องต้นสำหรับเซิร์ฟเวอร์ DNS บน Ubuntu 22.04 LTS แบบง่าย ๆ
Pargorn Ruasijan
Pargorn Ruasijan

Posted on • Originally published at pargorn.com

วิธีติดตั้งและกำหนดค่าเบื้องต้นสำหรับเซิร์ฟเวอร์ DNS บน Ubuntu 22.04 LTS แบบง่าย ๆ

การติดตั้งและกำหนดค่าเซิร์ฟเวอร์ DNS บนระบบปฏิบัติการ Ubuntu เป็นขั้นตอนที่สำคัญสำหรับการบริหารจัดการการแปลงชื่อโดเมนเป็นที่อยู่ IP ในเครือข่ายของคุณอย่างมีประสิทธิภาพ การทำงานของเซิร์ฟเวอร์ DNS ช่วยให้เว็บไซต์และแอปพลิเคชันของคุณสามารถถูกเข้าถึงได้โดยง่ายและมีประสิทธิภาพ

Image description

ขั้นตอนที่ 1 ติดตั้ง BIND

  • อัปเดทและติดตั้ง BIND
sudo apt update && sudo apt install bind9
Enter fullscreen mode Exit fullscreen mode

ขั้นตอนที่ 2 กำหนดค่าตัวเลือกของ BIND

  • แก้ไขไฟล์ named.conf.options เพื่อกำหนดค่าตัวเลือกของ BIND
sudo nano /etc/bind/named.conf.options
Enter fullscreen mode Exit fullscreen mode
  • แก้ไขไฟล์ดังตัวอย่าง
options {
    directory "/var/cache/bind";

    // ถ้าต้องการดึงข้อมูลจากเซิร์ฟเวอร์ DNS อื่น
    forwarders {
        8.8.8.8;
        8.8.4.4;
    };

    // ที่อยู่ของ IP สำหรับการส่ง query DNS เข้ามา
    listen-on { 192.168.64.33; };

    // เปิดใช้งานการบันทึก query
    querylog yes;

    // อนุญาตให้ query จาก local
    allow-query { localhost; 192.168.64.0/24; };
};
Enter fullscreen mode Exit fullscreen mode

ขั้นตอนที่ 3 กำหนดค่าโซนของโดเมน pargorn.com

  • แก้ไขข้อมูลโซน
sudo nano /etc/bind/named.conf.local
Enter fullscreen mode Exit fullscreen mode
  • เพิ่มข้อมูลโซน
zone "pargorn.com" {
    type master;
    file "/etc/bind/db.pargorn.com";
};
Enter fullscreen mode Exit fullscreen mode

ขั้นตอนที่ 4 สร้างไฟล์โซนของโดเมน pargorn.com

  • คัดลอกไฟล์ และแก้ไขไฟล์
sudo cp /etc/bind/db.local /etc/bind/db.pargorn.com
sudo nano /etc/bind/db.pargorn.com
Enter fullscreen mode Exit fullscreen mode
  • แก้ไขไฟล์ db.pargorn.com
$TTL    604800
@       IN      SOA     ns.pargorn.com. root.pargorn.com. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns.pargorn.com.
ns      IN      A       192.168.64.33
Enter fullscreen mode Exit fullscreen mode
  • บันทึกและปิดไฟล์ ### ขั้นตอนที่ 5 รีสตาร์ท BIND
  • รีสตาร์ท BIND เพื่อนำการเปลี่ยนแปลงไปใช้
sudo systemctl restart bind9
Enter fullscreen mode Exit fullscreen mode

ขั้นตอนที่ 6 เพิ่ม DNS

  • เพิ่ม DNS IP Address

Image description

Image description

ขั้นตอนที่ 7 ทดสอบ DNS

  • ใช้เครื่องมือเช่น nslookup หรือ dig เพื่อทดสอบ DNS
nslookup ns.pargorn.com
Enter fullscreen mode Exit fullscreen mode

Image description

เราได้ทำการติดตั้งและกำหนดค่าเซิร์ฟเวอร์ DNS บน Ubuntu เรียบร้อยแล้ว คุณสามารถปรับแต่งตามความต้องการของคุณได้ตามต้องการ

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more