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

การกำหนดค่าและการแปลงชื่อ DNS

ทำความเข้าใจการทำงานของ DNS ใน Linux กำหนดค่าไคลเอ็นต์ DNS และแก้ไขปัญหาการแปลงชื่อ

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

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

DNS: Name to Number

Welcome! Today we'll explore DNS (Domain Name System) in Linux. DNS is like the internet's phonebook, translating human-friendly domain names (like google.com) into machine-readable IP addresses (like 142.250.186.174).

Without DNS, you'd have to remember long numbers for every website or service you want to reach!

Your Linux DNS Client

In Linux, the primary configuration file for how your system resolves domain names is /etc/resolv.conf. This file tells your computer which DNS servers to ask when it needs to find an IP address for a hostname.

Think of it as your local DNS directory.

The `nameserver` Directive

The most important line in /etc/resolv.conf is nameserver. It specifies the IP address of a DNS server that your system should use.

  • You can list multiple nameserver entries.
  • Your system will try them in order until it gets a response.
  • Common public DNS servers are Google's (8.8.8.8, 8.8.4.4) or Cloudflare's (1.1.1.1).

View Your Current DNS

Let's see what DNS servers your system is currently configured to use. We can do this by displaying the contents of the /etc/resolv.conf file.

Try running the command below:

cat /etc/resolv.conf

Domain & Search Directives

Besides nameserver, you might also see domain and search directives in /etc/resolv.conf:

  • domain example.com: Sets the default domain name for the local host.
  • search example.com mycorp.local: Specifies a list of domains to try appending to hostnames that aren't fully qualified.

For example, if you ping webserver and search is mycorp.local, it will try webserver.mycorp.local.

Basic Lookups with `host`

The host command is a simple utility for performing DNS lookups. It's great for quickly finding the IP address of a domain or the domain name for an IP address.

It provides concise answers, making it perfect for quick checks.

`host` Command in Action

Let's use host to resolve a common domain. This command will query your configured DNS servers and return the associated IP address(es).

Run the example:

host coddykit.com

Detailed Queries with `dig`

For more detailed DNS information, the dig (Domain Information Groper) command is your go-to tool. It provides a comprehensive output of DNS records, including authoritative nameservers, record types (A, MX, NS, etc.), and more.

It's invaluable for troubleshooting.

`dig`ging for Records

Execute dig to see a full DNS query in action. Notice the different sections of the output, like the ANSWER SECTION, which contains the IP address, and AUTHORITY SECTION, which lists the authoritative nameservers for the domain.

Try it out:

dig coddykit.com

Basic DNS Troubleshooting

If you can't access a website by name but can by IP, it's likely a DNS issue. Here's a quick checklist:

  • Check /etc/resolv.conf: Are the nameserver IPs correct and reachable?
  • Test with ping 8.8.8.8: Can you reach an external DNS server by IP?
  • Use dig google.com @8.8.8.8: Explicitly query a working DNS server to see if resolution works that way.
  • Restart network service: Sometimes a network service restart can help apply changes.

DNS Client Configuration

You've learned about the key components of DNS client configuration in Linux.

Which of the following directives are commonly found in /etc/resolv.conf for configuring DNS client behavior?

Recap: DNS in Linux

Great job! You've learned how DNS works in Linux. You can now:

  • Identify /etc/resolv.conf as the primary DNS client configuration file.
  • Understand the role of nameserver, domain, and search directives.
  • Use host for quick DNS lookups.
  • Use dig for detailed DNS queries.
  • Perform basic troubleshooting for name resolution issues.

Mastering these tools is key to managing network services effectively!

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

บทเรียน “การกำหนดค่าและการแปลงชื่อ DNS” ฟรีหรือไม่

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

คุณจะเรียนรู้อะไรในบทเรียน “การกำหนดค่าและการแปลงชื่อ DNS”

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

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

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

บทเรียน “การกำหนดค่าและการแปลงชื่อ DNS” ใช้เวลานานแค่ไหน

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

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

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

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

  1. การจัดการส่วนติดต่อเครือข่าย
  2. ตารางเส้นทางและเกตเวย์
  3. การกำหนดค่าและการแปลงชื่อ DNS
  4. การกำหนดค่าไฟร์วอลล์ Linux ด้วย nftables
← กลับไปที่ Linux Networking & TCP/IP for Developers