til/applied-sciences/engineering/how-dns-works-and-fails
how-dns-works-and-fails.mdupdated 2026-07-163154 words
ダブルクリックで英日反転
Applied Sciences · Engineering

How a Domain Becomes an IP — and Why Sites Suddenly Break

EN

DNS (Domain Name System) is the internet's shared phone book, translating human-readable domain names into numeric IP addresses. Understanding its layers — records, caches, authoritative servers — is the key to diagnosing outages.

DNS Record Types

  • A record: maps a domain name → IPv4 address (e.g. 203.0.113.10)
  • AAAA record: maps a domain name → IPv6 address
  • CNAME record: alias that forwards one domain name to another domain name

Apex vs Subdomain & Who Manages What

  • Apex (root domain) = example.com itself, often written as "@"
  • Subdomains (www, api…) have records independent of the apex — one can disappear while the other survives
  • Registrar holds ownership; DNS host (CDN or dedicated service) holds the actual records — either side can cause an outage

Cache Layers and Isolation

  • OS/browser DNS cache keeps stale results until TTL expires; flush with ipconfig /flushdns on Windows
  • DoH (DNS over HTTPS): browser resolves DNS on its own encrypted channel, surviving an OS flush — clear browser DNS cache separately
  • Query the authoritative nameserver directly (dig @ns1… ) to bypass all caches and confirm whether a record truly exists

Confirming the Server Is Alive

  • hosts file (C:\Windows\System32\drivers\etc\hosts) overrides DNS locally — useful as a temporary workaround
  • curl --resolve bypasses DNS entirely and hits the IP directly with correct SNI; a valid TLS response proves the server is fine
  • If domain valid + server alive + cert valid + still unreachable → a single missing A record is the culprit; add it in the dashboard
A site going dark despite a valid domain usually means one A record vanished — query the authoritative nameserver, flush caches, and verify the server directly with curl to pinpoint the cause in minutes.
Applied Sciences · Engineering

ドメインが​IPに​変わる​仕組みと、​サイトが​突然開かなくなる​理由

JP

DNS​(Domain Name System=インターネットの​共有電話帳)は、​人が​読める​ドメイン名を​数値の​IPアドレスに​変換する。​レコード・キャッシュ・権威サーバーの​各層を​理解する​ことが、​障害の​素早い​特定に​つながる。

DNSレコードの​種類

  • Aレコード: ドメイン名 → IPv4アドレス​(例: 203.0.113.10)の​対応
  • AAAAレコード: ドメイン名 → IPv6アドレスの​対応
  • CNAMEレコード: ある​ドメイン名を​別の​ドメイン名へ​転送する​エイリアス​(別名)​定義

Apexと​サブドメイン、​管理主体の​違い

  • Apex​(ルートドメイン)​= example.com ​そのもの。​レジストラ管理画面では​「@」と​表記される​ことが​多い
  • サブドメイン​(www、​api等)の​レコードは​Apexとは​独立。​片方だけ​消える​ケースが​ある
  • レジストラ​(所有権管理)と​DNSホスト​(レコード管理)は​別会社の​ことが​あり、​どちら側の​変更でも​障害が​起きる

キャッシュの​層と​問題の​切り分け

  • OS・ブラウザの​DNSキャッシュは​TTL​(有効期限)が​切れるまで​古い情報を​使い続ける。​Windowsでは​ ipconfig /flushdns で​クリア
  • DoH​(DNS over HTTPS=ブラウザが​独自の​暗号化経路で​DNSを​解決する​仕組み)は​OSの​キャッシュを​クリアしても​残る​ため、​ブラウザ側も​別途クリアが​必要
  • 権威ネームサーバー​(​その​ドメインの​最終回答を​持つサーバー)に​直接 dig で​問い​合わせると​キャッシュを​介さず、​レコードの​実在を​確認できる

サーバーの​生存確認と​復旧

  • hostsファイル​(Windows: C:\Windows\System32\drivers\etc\hosts)は​DNSより​優先して​読まれ、​一時的な​回避策と​して​使える
  • curl --resolve で​DNSを​完全に​迂回して​IPに​直接接続し、​SNI​(Server Name Indication=TLSハンドシェイクで​ドメイン名を​サーバーに​伝える​仕組み)​付きで​証明書が​返れば​「サーバーは​生きている」と​確認できる
  • ドメイン有効・サーバー正常・証明書有効なのに​つながらない​場合 → Aレコードが​1行消えているだけ。​管理画面で​追加するだけで​復旧する
有効な​ドメインなのに​サイトが​落ちている​場合、​原因は​ほぼAレコードの​消失。​権威ネームサーバーへの​直接問い​合わせ→キャッシュクリア→curl直接接続の​3ステップで​数分以内に​切り分けられる。
148 notestil