เว็บนี้มีลิงก์ affiliate — หากสมัครผ่านลิงก์ เราได้รับค่าคอมมิชชัน · Affiliate links: we earn a commission at no extra cost to you. รายละเอียด

DNS คืออะไร ทำงานอย่างไร และทำไมต้องรู้เรื่อง DNS

What is DNS (Domain Name System)? How it works, DNS record types, and common DNS troubleshooting.

DNS คืออะไร ทำงานอย่างไร และทำไมต้องรู้เรื่อง DNS
แนะนำAsiaGB.com — Web Hosting & VPS คุณภาพสูง พร้อมทีม Support ภาษาไทย 24 ชั่วโมง SSD NVMe และ uptime รับประกัน 99.9%

AsiaGB.com — Premium hosting & VPS with Thai support, NVMe SSD, and 99.9% uptime guarantee.

เยี่ยมชม AsiaGB →

DNS คืออะไร

DNS (Domain Name System) คือระบบที่แปลงชื่อโดเมนที่มนุษย์อ่านได้ เช่น "google.com" ให้เป็น IP Address ที่คอมพิวเตอร์ใช้ติดต่อกัน เช่น "142.250.185.14" DNS ทำงานเหมือนสมุดโทรศัพท์ของ Internet โดยใช้เซิร์ฟเวอร์ที่เรียกว่า DNS Resolver, Root Nameserver, TLD Nameserver และ Authoritative Nameserver ร่วมกัน

DNS (Domain Name System) translates human-readable domain names like "google.com" into IP addresses like "142.250.185.14" that computers use to connect. It functions as the internet's phone book, using DNS Resolvers, Root Nameservers, TLD Nameservers, and Authoritative Nameservers.

DNS ทำงานอย่างไร

เมื่อพิมพ์โดเมนในเบราว์เซอร์ ระบบส่งคำขอไปยัง DNS Resolver ของ ISP (หรือที่กำหนดเอง เช่น 8.8.8.8) ถ้า Resolver ไม่มี Cache จะถามไปยัง Root Nameserver → TLD Nameserver → Authoritative Nameserver ของโดเมน ซึ่งตอบกลับด้วย IP Address จากนั้นเบราว์เซอร์จึงเชื่อมต่อไปยัง IP นั้น

When you type a domain, your browser queries a DNS Resolver (your ISP's or a custom one like 8.8.8.8). If not cached, the Resolver queries Root Nameserver → TLD Nameserver → Authoritative Nameserver, which returns the IP address. The browser then connects to that IP.

ประเภท DNS Record

DNS Records คือชุดข้อมูลที่บอกว่าโดเมนชี้ไปที่ไหน ประกอบด้วยหลายประเภท แต่ละอย่างมีหน้าที่ต่างกัน Record ที่ใช้บ่อยที่สุดคือ A Record, AAAA Record, MX Record, CNAME Record, TXT Record และ NS Record

DNS Records are data sets defining where a domain points. The most commonly used are A Records, AAAA Records, MX Records, CNAME Records, TXT Records, and NS Records — each serving a distinct purpose.

A Record และ AAAA Record

A Record เป็น Record พื้นฐานที่สำคัญที่สุด ทำหน้าที่ชี้ชื่อโดเมนหรือ Subdomain ไปยัง IPv4 Address ของเซิร์ฟเวอร์ AAAA Record ทำหน้าที่เดียวกันแต่สำหรับ IPv6 Address สมัยใหม่ควรตั้งทั้งสองเพื่อรองรับทั้ง IPv4 และ IPv6

A Record is the most fundamental DNS record, pointing a domain or subdomain to an IPv4 server address. AAAA Records do the same for IPv6. Modern setups should configure both for full compatibility.

MX Record

MX (Mail Exchanger) Record ระบุว่า Email ที่ส่งมาที่โดเมนของคุณต้องไปที่ Mail Server ใด มี Priority (ตัวเลข) กำกับ ตัวเลขน้อย = Priority สูงกว่า ถ้าต้องการ Redundancy ตั้ง MX Record หลายตัวที่ต่าง Priority

MX (Mail Exchanger) Records specify which mail server handles email for your domain, with Priority numbers (lower = higher priority). Multiple MX records provide redundancy.

CNAME Record

CNAME (Canonical Name) Record ทำหน้าที่สร้าง Alias โดยชี้โดเมนหนึ่งไปที่อีกโดเมนหนึ่ง เช่น www.example.com → example.com หรือ shop.example.com → store.shopify.com ข้อจำกัดคือ CNAME ไม่สามารถตั้งที่ Root Domain (@) ได้

CNAME (Canonical Name) Records create aliases pointing one domain to another — like www.example.com → example.com or shop.example.com → store.shopify.com. Important: CNAME cannot be set at the root domain (@).

TTL คืออะไร มีผลต่อ DNS อย่างไร

TTL (Time to Live) คือค่าที่บอกว่า DNS Resolver ควร Cache ข้อมูลไว้นานแค่ไหน (เป็นวินาที) ค่า TTL ต่ำ (เช่น 300 วินาที = 5 นาที) ทำให้ DNS เปลี่ยนแปลงเร็ว แต่เพิ่ม Load บน DNS Server ค่า TTL สูง (86400 วินาที = 1 วัน) ลด Query แต่เปลี่ยนแปลงช้า

TTL (Time to Live) defines how long DNS Resolvers cache your records in seconds. Low TTL (300 = 5 min) enables fast propagation but increases DNS server load. High TTL (86400 = 1 day) reduces queries but slows changes.

DNS Propagation คืออะไร

DNS Propagation คือระยะเวลาที่การเปลี่ยนแปลง DNS ใช้ในการกระจายไปยัง DNS Server ทั่วโลก โดยทั่วไปใช้เวลา 1-48 ชั่วโมง แต่มักเร็วกว่านั้นมากถ้าตั้ง TTL ต่ำ ระหว่าง Propagation ผู้เข้าชมบางรายอาจเห็นเว็บเก่า บางรายเห็นเว็บใหม่

DNS Propagation is the time it takes for DNS changes to spread globally — typically 1-48 hours, though often much faster with low TTL settings. During propagation, some visitors may see the old site while others see the new one.

แก้ปัญหา DNS ที่พบบ่อย

ปัญหา DNS ที่พบบ่อยได้แก่ เว็บขึ้น "Server Not Found" แม้โดเมนถูกต้อง Email ส่งไม่ถึง หรือ SSL Certificate ไม่ออก การ Debug เริ่มจากตรวจสอบ DNS Records ด้วย nslookup หรือ dig และตรวจสอบ Nameserver ว่าชี้ถูกต้องหรือไม่

Common DNS issues: "Server Not Found" despite correct domain, email delivery failures, or SSL certificates not issuing. Debug by checking DNS records with nslookup or dig, and verify nameservers point correctly.

คำถามที่พบบ่อย (FAQ)

DNS Propagation ใช้เวลานานแค่ไหน?
ขึ้นอยู่กับ TTL ที่ตั้งไว้ ถ้า TTL เป็น 86400 (1 วัน) อาจรอนาน 48 ชั่วโมงในกรณีเลวร้ายสุด แต่ถ้าตั้ง TTL เป็น 300 (5 นาที) ล่วงหน้า มักเสร็จภายใน 15-30 นาที ปัจจุบัน ISP ส่วนใหญ่ Refresh DNS ทุก 1-4 ชั่วโมง
ทำไมเปลี่ยน IP แล้วเว็บยังชี้ที่เก่า?
เพราะ DNS Resolver ของคุณหรือ ISP ยังมี Cache อยู่ ลอง Flush DNS (ipconfig /flushdns บน Windows หรือ sudo systemd-resolve --flush-caches บน Linux) หรือเปลี่ยนไปใช้ DNS ชั่วคราวเช่น 8.8.8.8
Cloudflare DNS Proxy (สีส้ม) ต่างจาก DNS Only อย่างไร?
Proxy สีส้ม ทำให้ Traffic วิ่งผ่าน Cloudflare เพื่อได้ CDN + DDoS + SSL จาก Cloudflare DNS Only (เมฆสีเทา) ชี้ DNS ตรงไปที่ Origin Server ไม่ผ่าน Cloudflare เลย
TXT Record ใช้ทำอะไร?
TXT Record เก็บข้อมูล Text สำหรับหลายวัตถุประสงค์ เช่น SPF สำหรับ Email Authentication, DKIM Key, DMARC Policy, Domain Verification ของ Google/Facebook และ ACME Challenge สำหรับ SSL Certificate