0Pricing
Linux Networking & TCP/IP for Developers · บทเรียน

การวินิจฉัย DNS ด้วย dig และ nslookup

วินิจฉัยปัญหาการแปลงชื่อบน Linux ด้วย dig, nslookup และ host เพื่อตรวจสอบระเบียน DNS ติดตามเส้นทางการแปลงชื่อ และค้นหาการกำหนดค่าที่ผิดพลาด

การวินิจฉัย DNS ด้วย dig และ nslookup เป็นบทเรียน Linux Networking & TCP/IP for Developers ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Linux Networking & TCP/IP for Developers และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Linux Networking & TCP/IP for Developers มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Why DNS Diagnostics Matter

Many 'network is down' reports are really DNS failures. The host is reachable by IP, but the name will not resolve.

Linux ships tools to inspect resolution directly:

  • dig — flexible, scriptable lookups
  • nslookup — classic interactive tool
  • host — quick one-line answers

This lesson focuses on reading their output to find the real problem.

A Basic dig Query

Run dig followed by a hostname to fetch its A record.

The key part of the output is the ANSWER SECTION, which lists the resolved addresses and their TTL.

dig example.com

Reading the dig Answer Section

Each answer line shows: name TTL class type value.

  • TTL — seconds the record may be cached
  • type — A, AAAA, MX, CNAME, etc.
  • value — the resolved data

Use +short to strip everything except the value.

dig +short example.com

Querying Specific Record Types

Append the record type to look up anything besides an A record.

  • dig example.com MX — mail servers
  • dig example.com AAAA — IPv6
  • dig example.com TXT — text records (SPF, verification)
dig example.com MX

Choosing a Specific Resolver

Use @server to bypass your local resolver and ask a specific DNS server. This isolates whether your local cache is the problem.

Below queries Google Public DNS directly.

dig @8.8.8.8 example.com

Tracing the Resolution Path

dig +trace walks from the root servers down to the authoritative server, printing each delegation step.

This reveals broken delegations or stale glue records that a normal query hides.

dig +trace example.com

Reverse DNS Lookups

To map an IP back to a name, use -x. This queries the PTR record.

Missing PTR records often cause mail delivery and logging issues.

dig -x 8.8.8.8

Using nslookup Interactively

nslookup can run one-shot or interactively. In interactive mode you set type= and switch servers with server.

nslookup -type=MX example.com

Quick Answers with host

host gives compact output, ideal for quick checks.

  • host example.com — A and AAAA
  • host -t NS example.com — nameservers
host -t NS example.com

Interpreting Status Codes

The status field in the dig header is critical:

  • NOERROR — resolved fine
  • NXDOMAIN — name does not exist
  • SERVFAIL — server failed (often DNSSEC or upstream issues)

Checking the Local Resolver Config

Linux resolution settings live in /etc/resolv.conf and /etc/nsswitch.conf.

If dig works but applications fail, suspect nsswitch.conf ordering or a stale resolv.conf.

cat /etc/resolv.conf

Quick Check

Test your understanding of dig output.

Recap

You now diagnose DNS issues directly:

  • dig for flexible, scriptable lookups and +trace
  • @server to isolate resolver problems
  • -x for reverse lookups
  • Read status codes (NOERROR/NXDOMAIN/SERVFAIL)
  • Check /etc/resolv.conf and nsswitch.conf for local issues

These skills complement packet capture and firewall analysis for end-to-end troubleshooting.

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

บทเรียน “การวินิจฉัย DNS ด้วย dig และ nslookup” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “การวินิจฉัย DNS ด้วย dig และ nslookup” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Linux Networking & TCP/IP for Developers ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Linux Networking & TCP/IP for Developers มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “การวินิจฉัย DNS ด้วย dig และ nslookup”

วินิจฉัยปัญหาการแปลงชื่อบน Linux ด้วย dig, nslookup และ host เพื่อตรวจสอบระเบียน DNS ติดตามเส้นทางการแปลงชื่อ และค้นหาการกำหนดค่าที่ผิดพลาด คุณปฏิบัติ Linux Networking & TCP/IP for Developers ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Linux Networking & TCP/IP for Developers หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Linux Networking & TCP/IP for Developers บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “การวินิจฉัย DNS ด้วย dig และ nslookup” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Linux Networking & TCP/IP for Developers นี้ได้ไหม

ได้ บทเรียน Linux Networking & TCP/IP for Developers ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. การจับแพ็กเก็ตด้วย Wireshark/tcpdump
  2. เครื่องมือวัดประสิทธิภาพเครือข่าย
  3. ไฟร์วอลล์ Linux (Netfilter/iptables)
  4. การวินิจฉัย DNS ด้วย dig และ nslookup
← กลับไปที่ Linux Networking & TCP/IP for Developers