0Pricing
Linux Networking & TCP/IP for Developers · レッスン

DNSの設定と名前解決

LinuxにおけるDNSの仕組みを理解し、DNSクライアントの設定と名前解決の問題のトラブルシューティングを行います。

「DNSの設定と名前解決」はCoddyKit上の無料Linux Networking & TCP/IP for Developersレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これは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の設定と名前解決」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Linux Networking & TCP/IP for Developersコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Linux Networking & TCP/IP for Developersコースには全4レッスンが含まれています。

「DNSの設定と名前解決」で何を学びますか?

LinuxにおけるDNSの仕組みを理解し、DNSクライアントの設定と名前解決の問題のトラブルシューティングを行います。 ブラウザで直接実行するハンズオンコードでLinux Networking & TCP/IP for Developersを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Linux Networking & TCP/IP for Developersを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのLinux Networking & TCP/IP for Developersは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。

「DNSの設定と名前解決」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このLinux Networking & TCP/IP for Developersレッスンでコードを書いて実行できますか?

はい。すべてのLinux Networking & TCP/IP for Developersレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. ネットワークインターフェースの管理
  2. ルーティングテーブルとゲートウェイ
  3. DNSの設定と名前解決
  4. nftablesによるLinuxファイアウォール設定
← Linux Networking & TCP/IP for Developersに戻る