
DNS: 인터넷 전화번호부와 0.1초의 여정 (완전정복)
www.naver.com을 치면 일어나는 일. Recursive Query부터 Root 서버의 역할, DNS 레코드 타입(A, CNAME, MX), TTL, 그리고 DNS 캐시 포이즈닝 공격까지 심층 분석합니다.

www.naver.com을 치면 일어나는 일. Recursive Query부터 Root 서버의 역할, DNS 레코드 타입(A, CNAME, MX), TTL, 그리고 DNS 캐시 포이즈닝 공격까지 심층 분석합니다.
내 서버는 왜 걸핏하면 뻗을까? OS가 한정된 메모리를 쪼개 쓰는 처절한 사투. 단편화(Fragmentation)와의 전쟁.

미로를 탈출하는 두 가지 방법. 넓게 퍼져나갈 것인가(BFS), 한 우물만 팔 것인가(DFS). 최단 경로는 누가 찾을까?

프론트엔드 개발자가 알아야 할 4가지 저장소의 차이점과 보안 이슈(XSS, CSRF), 그리고 언제 무엇을 써야 하는지에 대한 명확한 기준.

이름부터 빠릅니다. 피벗(Pivot)을 기준으로 나누고 또 나누는 분할 정복 알고리즘. 왜 최악엔 느린데도 가장 많이 쓰일까요?

회사 첫 날이었다. 시니어가 말했다.
"테스트 서버 접속해봐요. IP는
192.168.45.237이에요."
나는 멍하니 메모장을 켰다. 숫자를 적었다. 다음날 또 물어봤다. 또 적었다. 일주일이 지나자 나는 깨달았다.
인간은 숫자를 기억하도록 설계되지 않았다.그런데 우리는 매일 수십 개의 웹사이트에 접속한다. www.google.com, www.youtube.com, www.github.com. 이 이름들은 기억하지만, 그 뒤에 숨어있는 IP 주소 142.250.207.174, 172.217.174.206을 외우는 사람은 없다.
컴퓨터는 숫자(IP)만 이해하고, 인간은 이름(도메인)만 기억한다. 이 둘을 연결해주는 시스템이 바로 DNS(Domain Name System)다.
처음엔 "그냥 주소록 아니야?"라고 생각했다. 하지만 파고들수록 이건 단순한 변환기가 아니었다. 이건 0.1초 만에 전 세계 계층 구조를 순회하는 분산 데이터베이스였다. Root 서버, TLD 서버, Authoritative 서버. 캐싱, TTL, Anycast.
내가 주소창에 도메인을 입력하고 엔터를 치는 순간, 내 뒤에서 일어나는 일들을 정리해본다.
DNS를 이해하려면, DNS가 왜 생겨났는지 알아야 했다.
1970년대 ARPANET 시절, 인터넷에 연결된 컴퓨터는 고작 몇 백 대였다. 당시엔 HOSTS.TXT라는 단 하나의 텍스트 파일에 모든 컴퓨터의 이름과 주소를 적어서 관리했다.
# HOSTS.TXT (1975년 어느 날)
10.0.0.51 SRI-ARC
10.0.0.52 MIT-AI
10.0.0.73 BBN-TENEX
...
스탠퍼드 연구소(SRI)가 이 파일을 중앙에서 관리했고, 사람들은 FTP로 주기적으로 이 파일을 다운로드받아야 했다.
문제는 네트워크가 커지면서 시작됐다.폴 모카페트리스(Paul Mockapetris)는 이 문제를 해결하기 위해 계층적 분산 데이터베이스 시스템을 제안했다. 이게 바로 DNS였다.
핵심 아이디어는 간단했다.
"한 곳에서 모든 정보를 관리하지 말고, 책임을 나눠서 가지자."
.com 도메인은 .com TLD 서버가 관리한다.google.com은 구글이 직접 관리한다.이 구조가 지금까지 40년 넘게 인터넷의 근간으로 작동하고 있다는 사실이 와닿았다.
처음엔 DNS를 "전화번호부"라는 비유로 이해했다. 이름을 찾으면 번호가 나온다. 간단하다.
하지만 실제로 DNS 쿼리를 추적해보니, 이건 전화번호부가 아니었다.
DNS는 우편 체계에 가깝다.편지를 보낼 때 우리는 "서울시 강남구 테헤란로 123"이라고 쓴다. 우체국은 이걸 한 번에 찾지 않는다.
DNS도 똑같다. www.google.com을 찾을 때:
브라우저에 www.naver.com을 입력했을 때, 정확히 무슨 일이 일어나는지 정리해본다.
브라우저는 최근 방문 기록을 메모리에 저장한다.
# Chrome의 내부 DNS 캐시 (chrome://net-internals/#dns)
www.naver.com -> 223.130.195.200 (TTL: 300초 남음)
캐시 히트 → DNS 조회 스킵. 가장 빠른 경로다.
브라우저 캐시에 없으면 운영체제에 물어본다.
# macOS/Linux
$ dscacheutil -cachedump -entries Host
# Windows
$ ipconfig /displaydns
여기도 없으면 진짜 DNS 서버에 물어봐야 한다.
이제 ISP(통신사) DNS 서버에게 물어본다. 이 서버를 Recursive Resolver라고 부른다.
내 컴퓨터 -> KT DNS (168.126.63.1)
"www.naver.com IP 주세요!"
여기서 중요한 건, Recursive Resolver는 나를 대신해서 전 세계를 돌아다니며 답을 찾아온다는 점이다. 나는 단 한 번만 요청하면 된다.
ISP DNS는 가장 먼저 Root 서버에게 물어본다.
KT DNS -> Root 서버 (198.41.0.4)
"www.naver.com 어디 있어요?"
Root: "난 몰라. 하지만 .com을 관리하는 TLD 서버는 알아.
a.gtld-servers.net (192.5.6.30) 한테 가봐."
전 세계에 Root 서버는 13개의 원본 서버(a.root-servers.net ~ m.root-servers.net)가 있다. 하지만 실제론 Anycast 기술로 수백 곳에 복제되어 있다.
ISP DNS는 이제 .com TLD 서버에게 간다.
KT DNS -> .com TLD 서버 (192.5.6.30)
"naver.com 어디 있어요?"
TLD: "난 몰라. 하지만 naver.com을 관리하는 네임서버는 알아.
ns1.naver.com (125.209.248.6) 한테 가봐."
TLD는 Top-Level Domain의 약자다. .com, .org, .kr, .io 같은 최상위 도메인을 관리한다.
마지막으로 네이버의 Authoritative 서버에게 물어본다.
KT DNS -> ns1.naver.com (125.209.248.6)
"www.naver.com IP 주세요!"
Naver DNS: "223.130.195.200이야. 이게 최종 답이야."
Authoritative는 "권위 있는"이란 뜻이다. 이 서버가 최종 정답을 가지고 있다.
ISP DNS는 이 IP를 받아서:
KT DNS 캐시:
www.naver.com -> 223.130.195.200 (TTL: 300초)
이 모든 과정이 0.1초 안에 끝난다.
DNS는 단순히 IP만 저장하지 않는다. 다양한 레코드 타입이 있고, 각각 다른 역할을 한다.
| 레코드 타입 | 역할 | 예시 | 활용 |
|---|---|---|---|
| A | 도메인 → IPv4 주소 | example.com → 93.184.216.34 | 가장 기본적인 레코드. 웹사이트 호스팅의 핵심 |
| AAAA | 도메인 → IPv6 주소 | example.com → 2606:2800:220:1:: | IPv6 지원. 차세대 주소 체계 |
| CNAME | 도메인 별칭 (Alias) | www.example.com → example.com | IP 변경 시 한 곳만 수정하면 됨 |
| MX | 메일 서버 지정 | example.com → mail.google.com (우선순위: 10) | 이메일 수신용. 우선순위 낮을수록 먼저 시도 |
| NS | 네임서버 지정 | example.com → ns1.aws.com | "이 도메인 관리는 AWS Route53이 해" |
| TXT | 텍스트 정보 | example.com → "v=spf1 include:_spf.google.com ~all" | SPF 인증, 구글 서치 콘솔 인증 등 |
| SOA | 권한 시작 (Start of Authority) | - | 도메인 관리 정보 (관리자 이메일, 갱신 주기, 시리얼 번호) |
| PTR | IP → 도메인 (역방향) | 34.216.184.93.in-addr.arpa → example.com | 스팸 필터링에 사용. 메일 서버가 진짜인지 확인 |
| SRV | 서비스 위치 지정 | _minecraft._tcp.example.com → server.example.com:25565 | 게임 서버, VoIP 등 포트 정보 포함 |
| CAA | 인증서 발급 기관 제한 | example.com → letsencrypt.org | Let's Encrypt만 SSL 인증서 발급 가능 |
blog.company.com으로 블로그를 운영한다고 해보자. 처음엔 A 레코드로 설정했다.
# 초기 설정
blog.company.com A 52.123.45.67
나중에 서버를 AWS에서 Vercel로 옮겼다. IP가 바뀌었다. A 레코드를 수정해야 했다.
# 서버 이전 후
blog.company.com A 76.223.47.193 # 변경됨!
CNAME을 쓰면 이런 문제가 없다.
# CNAME 설정
blog.company.com CNAME company.vercel.app
# Vercel이 IP를 바꿔도 CNAME은 그대로
company.vercel.app A 76.223.47.193 # Vercel이 관리
IP가 바뀌어도 CNAME 레코드는 건드릴 필요가 없다. 이게 별칭의 힘이다.
DNS 설정에서 가장 헷갈렸던 게 TTL(Time To Live)이었다.
TTL은 "이 정보를 몇 초 동안 믿어도 되는지"를 나타낸다.
www.example.com 300 A 93.184.216.34
↑
TTL (초 단위)
이 레코드는 "300초(5분) 동안은 내 캐시를 믿고, 그 이후엔 다시 물어봐"라는 뜻이다.
| TTL | 장점 | 단점 | 언제 쓰나 |
|---|---|---|---|
| 긴 TTL (86400초 = 24시간) | DNS 서버 부하 감소, 응답 속도 빠름 | IP 변경 시 반영이 느림 (최대 24시간 소요) | 안정적인 프로덕션 서버 |
| 짧은 TTL (60초 = 1분) | IP 변경 즉시 반영 | DNS 조회 트래픽 증가, 약간의 속도 저하 | 서버 이전, A/B 테스트, 긴급 점검 |
클라우드 마이그레이션 시에는 TTL 관리가 핵심이다. 예를 들어 AWS에서 GCP로 이전하는 경우를 생각해보자.
D-Day에 IP를 바꿨는데 TTL이 86400초(24시간)였다면, 일부 사용자가 24시간 동안 접속 오류를 겪을 수 있다. ISP DNS들이 구 IP를 하루 동안 캐싱하기 때문이다.
올바른 절차는 이렇다.
D-7일: TTL을 300초(5분)로 줄인다.
D-1일: TTL이 전파될 때까지 대기. (기존 TTL인 24시간 후)
D-Day: IP를 변경한다.
D+1일: TTL을 다시 86400초로 복구한다.
서버 이전 일주일 전부터 TTL을 줄여놔야 한다. 이게 DNS 관리의 핵심이었다.
dig와 nslookup으로 DNS 추적하기이론만으론 부족했다. 직접 DNS 경로를 추적해봤다.
dig +trace로 계층 구조 보기$ dig +trace www.google.com
; <<>> DiG 9.10.6 <<>> +trace www.google.com
;; global options: +cmd
. 518400 IN NS a.root-servers.net.
. 518400 IN NS b.root-servers.net.
. 518400 IN NS c.root-servers.net.
;; Received 239 bytes from 192.168.1.1#53(로컬 DNS) in 12 ms
com. 172800 IN NS a.gtld-servers.net.
com. 172800 IN NS b.gtld-servers.net.
;; Received 1176 bytes from 198.41.0.4#53(a.root-servers.net) in 23 ms
google.com. 172800 IN NS ns1.google.com.
google.com. 172800 IN NS ns2.google.com.
;; Received 384 bytes from 192.5.6.30#53(a.gtld-servers.net) in 89 ms
www.google.com. 300 IN A 142.250.76.100
;; Received 59 bytes from 216.239.32.10#53(ns1.google.com) in 21 ms
Root(.) → TLD(.com) → Authoritative(ns1.google.com) 순으로 찾아가는 걸 직접 볼 수 있다.
nslookup으로 특정 레코드 조회# A 레코드 조회
$ nslookup www.github.com
Server: 168.126.63.1
Address: 168.126.63.1#53
Non-authoritative answer:
Name: www.github.com
Address: 140.82.121.4
# MX 레코드 조회 (메일 서버)
$ nslookup -type=MX google.com
Server: 168.126.63.1
Address: 168.126.63.1#53
google.com mail exchanger = 10 smtp.google.com.
dig로 TTL 확인$ dig www.naver.com
;; ANSWER SECTION:
www.naver.com. 268 IN A 223.130.195.200
↑
TTL (268초 남음)
같은 명령어를 1분 후에 다시 치면 TTL이 줄어든 걸 볼 수 있다.
$ dig www.naver.com
www.naver.com. 208 IN A 223.130.195.200
↑
60초 감소
# 구글 DNS(8.8.8.8)에 직접 물어보기
$ dig @8.8.8.8 www.github.com
# Cloudflare DNS(1.1.1.1)에 물어보기
$ dig @1.1.1.1 www.github.com
ISP DNS를 거치지 않고 특정 Public DNS에 직접 질의할 수 있다.
DNS는 1983년에 설계됐다. 당시엔 보안이 고려되지 않았다.
공격자가 가짜 DNS 응답을 ISP DNS 서버에 주입한다.
공격자 -> ISP DNS
"bank.com의 IP는 6.6.6.6이야" (피싱 사이트 IP)
ISP DNS는 이걸 믿고 캐싱
사용자 -> ISP DNS
"bank.com IP 주세요?"
ISP DNS: "6.6.6.6이야" (피싱 사이트로 유도됨)
해결책: DNSSEC (DNS Security Extensions)
DNSSEC는 DNS 응답에 디지털 서명을 추가한다.
Root 서버의 공개키
↓ 서명 검증
.com TLD 서버의 공개키
↓ 서명 검증
bank.com Authoritative 서버의 응답
↓ 서명 검증
최종 IP
Chain of Trust를 통해 각 단계의 응답이 진짜인지 검증한다.
전통적인 DNS는 UDP/53 포트로 평문 전송된다. ISP는 내가 어떤 사이트를 방문하는지 전부 볼 수 있다.
내 컴퓨터 -> ISP DNS (평문)
"www.wikileaks.org IP 주세요?"
ISP: "아하, 이 사람 wikileaks 보네?" (로그 저장)
해결책 1: DoH (DNS over HTTPS)
DNS 쿼리를 HTTPS(443 포트)로 암호화한다.
내 컴퓨터 -> Cloudflare DoH 서버 (1.1.1.1)
HTTPS로 암호화된 DNS 쿼리
ISP: "뭔가 HTTPS 통신하는데... 내용은 모르겠네"
Chrome, Firefox는 기본적으로 DoH를 사용한다.
해결책 2: DoT (DNS over TLS)DNS 전용 암호화 채널(853 포트)을 사용한다.
내 컴퓨터 -> DNS 서버 (853 포트, TLS 암호화)
DoH와 차이점:
구글 Public DNS(8.8.8.8)를 쓰면 전 세계 어디서든 빠르다. 어떻게 가능할까?
Anycast 라우팅 덕분이다.
1.2.3.4 IP → 서울에 있는 단 하나의 서버
미국에서 접속 → 서울까지 왕복 (200ms 지연)
Anycast (8.8.8.8 방식)
8.8.8.8 IP → 전 세계 수백 개 서버가 동시에 광고 (BGP)
서울에서 접속 → 가장 가까운 서버(서울 데이터센터)로 자동 라우팅
미국에서 접속 → 가장 가까운 서버(LA 데이터센터)로 자동 라우팅
네트워크 라우팅 프로토콜(BGP)이 자동으로 가장 가까운 서버를 찾아준다.
이제 나는 이해했다. 8.8.8.8은 "한 대의 서버"가 아니라 전 세계에 퍼져있는 서버 군단이었다.
동료가 도메인을 새로 샀다. DNS 설정도 다 했다. 근데 접속이 안 됐다.
이유: DNS 전파 시간 (Propagation Delay)전 세계 ISP DNS들이 캐시를 갱신하는 데 시간이 걸린다. 예전엔 24~48시간이 걸렸는데, 요즘은 보통 1시간 내로 끝난다.
# 전파 상태 확인
$ dig @8.8.8.8 new-domain.com # 구글 DNS에선 보임
$ dig @168.126.63.1 new-domain.com # KT DNS에선 안 보임 (아직 전파 안 됨)
해결책: 기다리거나, /etc/hosts로 로컬 테스트
$ sudo vi /etc/hosts
93.184.216.34 new-domain.com
개발 중인 서버(localhost:3000)에 dev.myapp.com이라는 도메인을 붙이고 싶었다.
$ sudo vi /etc/hosts
127.0.0.1 dev.myapp.com
이제 브라우저에서 http://dev.myapp.com:3000 접속 가능.
팀원들도 같은 도메인을 써야 한다면, 내부 DNS 서버를 띄운다.
# dnsmasq 설정
$ echo "address=/dev.myapp.com/192.168.1.100" >> /etc/dnsmasq.conf
$ sudo systemctl restart dnsmasq
친구가 물었다. "8.8.8.8이 더 빨라?"
일반적으론 맞다. 구글 DNS는:
한국 사이트(네이버, 카카오)는 통신사 DNS가 더 빠를 수 있다. 이유는 CDN 최적화 때문이다.
KT DNS 사용:
naver.com → 223.130.195.200 (KT 네트워크 내 CDN)
8.8.8.8 사용:
naver.com → 223.130.195.95 (일반 서버)
통신사 DNS는 CDN 서버 위치를 고려해서 가장 가까운 IP를 준다.
결론: 국내 사이트 위주면 통신사 DNS, 해외 사이트/프라이버시 중요하면 8.8.8.8 또는 1.1.1.1.com, .net, .kr 같은 최상위 도메인. ICANN이 관리./etc/hosts (Linux/Mac), C:\Windows\System32\drivers\etc\hosts (Windows). DNS보다 우선순위 높음.A: DNS 전파 시간(Propagation Delay) 때문일 수 있습니다.
레지스트라(GoDaddy, Cloudflare 등)에서 DNS 설정을 바꾸면, 전 세계 ISP DNS들이 이 정보를 받아서 캐시를 갱신해야 합니다. 예전엔 24~48시간 걸렸지만, 요즘은 보통 1시간 이내에 완료됩니다.
확인 방법:# 구글 DNS에선 보이는지 확인
$ dig @8.8.8.8 yourdomain.com
# 통신사 DNS에선 보이는지 확인
$ dig @168.126.63.1 yourdomain.com # KT
$ dig @210.220.163.82 yourdomain.com # SK
둘 다 응답이 오면 전파 완료입니다.
A: 두 가지 경우에 씁니다.
1. 로컬 개발 테스트$ sudo vi /etc/hosts
127.0.0.1 dev.myapp.com
192.168.1.50 staging.company.com
브라우저에서 dev.myapp.com을 입력하면 DNS 조회 없이 바로 127.0.0.1로 연결됩니다.
127.0.0.1 facebook.com
127.0.0.1 twitter.com
이러면 해당 사이트가 localhost로 연결돼서 접속이 안 됩니다. (생산성 도구로 쓰는 사람도 있습니다)
주의: hosts 파일은 DNS보다 우선순위가 높습니다. 실수로 잘못 설정하면 정상 사이트도 안 열릴 수 있습니다.
# KT DNS
$ dig @168.126.63.1 www.naver.com | grep "Query time"
Query time: 12 msec
# 구글 DNS
$ dig @8.8.8.8 www.naver.com | grep "Query time"
Query time: 18 msec
결론: 국내 사이트 위주로 쓰면 통신사 DNS, 해외 사이트 많이 쓰거나 프라이버시 중요하면 8.8.8.8 또는 1.1.1.1 추천.
A: 둘 다 도메인을 연결하지만, 가리키는 대상이 다릅니다.
A 레코드: 도메인 → IP 주소example.com A 93.184.216.34
CNAME 레코드: 도메인 → 다른 도메인
www.example.com CNAME example.com
언제 CNAME을 쓰나?
서버 IP가 자주 바뀌는 경우. 예를 들어 Vercel, Netlify 같은 호스팅 서비스는 IP를 예고 없이 바꿉니다.
# A 레코드 사용 시 (나쁨)
blog.mysite.com A 76.223.47.193 # Vercel IP
# Vercel이 IP 바꾸면 → 수동으로 A 레코드 수정 필요
# CNAME 사용 시 (좋음)
blog.mysite.com CNAME mysite.vercel.app
# Vercel이 IP 바꿔도 → 내 CNAME은 그대로 유지
주의: 루트 도메인(example.com)에는 CNAME을 쓸 수 없습니다. (DNS 표준 제약) 대신 ALIAS 레코드를 지원하는 DNS 제공자(Cloudflare, Route53)를 쓰면 가능합니다.
A: 기본은 UDP, 조건부로 TCP입니다.
UDP/53 (일반적인 경우)# UDP로 질의 (기본)
$ dig @8.8.8.8 google.com
# TCP로 강제 질의
$ dig @8.8.8.8 +tcp google.com
A: 가능합니다. 각 서브도메인에 별도의 레코드를 설정하면 됩니다.
# Zone File 예시
example.com A 93.184.216.34 # 메인 사이트
www.example.com A 93.184.216.34 # 메인 사이트
blog.example.com A 52.123.45.67 # 블로그 서버 (다른 IP)
api.example.com A 13.209.84.123 # API 서버 (AWS)
cdn.example.com CNAME d111111abcdef8.cloudfront.net # CDN
실제로 많은 회사가 이렇게 운영합니다.
www.company.com: 메인 웹사이트blog.company.com: 블로그 (Notion, WordPress)api.company.com: API 서버admin.company.com: 관리자 대시보드DNS를 공부하면서 이해했던 것들을 정리해본다.
처음엔 "이름 → 숫자 변환"으로만 생각했다. 하지만 파고들수록 계층적 분산 시스템, 캐싱 전략, 보안, Anycast 라우팅까지 엮여있는 복잡한 인프라였다.
결국 이거였다: DNS는 인터넷의 신경계다. 이게 멈추면 전 세계 웹사이트가 전부 IP 주소로만 접속 가능한 세상이 된다.
TTL을 처음 봤을 때 "이게 왜 필요하지?"라고 생각했다. 하지만 서버 이전을 겪으면서 와닿았다.
TTL이 길면: 안정적이고 빠르지만, IP 변경이 느리다. TTL이 짧으면: IP 변경이 빠르지만, DNS 조회가 잦아진다.
팁: 평소엔 TTL 86400초(24시간). 서버 이전 일주일 전부터 300초(5분)로 줄인다. 이전 완료 후 다시 복구.
8.8.8.8은 하나의 서버가 아니라 전 세계 수백 대의 서버 군단이다. 네트워크 라우팅(BGP)이 자동으로 가장 가까운 서버로 연결해준다.
이게 바로 확장성의 핵심이다. 사용자가 늘어나도 서버를 추가하면 되고, DDoS 공격도 분산시킬 수 있다.
DNS는 1983년에 만들어졌다. 당시엔 인터넷이 학술용이었기 때문에 보안이 고려되지 않았다.
DNS 문제를 만났을 때:
# 1. 기본 조회
dig example.com
# 2. 계층 구조 추적
dig +trace example.com
# 3. 특정 DNS 서버 질의
dig @8.8.8.8 example.com
# 4. 특정 레코드 타입 조회
dig -t MX example.com
# 5. TTL 확인 (캐시 만료 시간)
dig example.com | grep -A1 "ANSWER SECTION"
이 명령어들을 익히고 나니, DNS 문제를 10분 안에 해결할 수 있게 됐다.
DNS는 "보이지 않지만 항상 작동하는 시스템"이다. 우리가 주소창에 도메인을 입력할 때마다, 0.1초 만에 전 세계 계층 구조를 순회하고, 캐싱 전략을 적용하고, 가장 가까운 서버로 라우팅한다.
나는 이제 알았다. 인터넷의 편리함 뒤에는 40년 된 분산 시스템이 숨어있다는 걸.My first day at work. A senior engineer said:
"Connect to the test server. The IP is
192.168.45.237."
I stared blankly. Opened a notepad. Wrote down the numbers. The next day, I asked again. Wrote it down again. After a week, I had an epiphany.
Humans aren't designed to memorize numbers.Yet every day, we visit dozens of websites. www.google.com, www.youtube.com, www.github.com. We remember these names, but nobody memorizes the IPs behind them: 142.250.207.174, 172.217.174.206.
Computers only understand numbers (IPs). Humans only remember names (domains). The system bridging this gap is DNS (Domain Name System).
At first, I thought, "Isn't this just an address book?" But the deeper I dug, the more I realized: this isn't a simple translator. It's a distributed database that traverses a global hierarchy in 0.1 seconds. Root servers, TLD servers, Authoritative servers. Caching, TTL, Anycast.
When I type a domain into my browser and hit Enter, here's what happens behind the scenes.
To understand DNS, I had to learn why it was invented.
In the 1970s ARPANET era, the internet had only a few hundred connected computers. Back then, a single text file called HOSTS.TXT stored every computer's name and address.
# HOSTS.TXT (circa 1975)
10.0.0.51 SRI-ARC
10.0.0.52 MIT-AI
10.0.0.73 BBN-TENEX
...
Stanford Research Institute (SRI) managed this file centrally. People periodically downloaded it via FTP.
The problem started as the network grew.Paul Mockapetris proposed a hierarchical distributed database system to solve this. That was DNS.
The core idea was simple.
"Don't manage all information in one place. Distribute responsibility."
.com domains are managed by .com TLD servers.google.com is managed directly by Google.This architecture has been the backbone of the internet for over 40 years.
Initially, I understood DNS through the "phonebook" metaphor. You look up a name, you get a number. Simple.
But when I actually traced a DNS query, I realized: this isn't a phonebook.
DNS is more like a postal system.When you mail a letter, you write "123 Teheran-ro, Gangnam-gu, Seoul." The post office doesn't find it in one step.
DNS works the same way. When you look up www.google.com:
When you type www.naver.com into your browser, here's exactly what happens.
Your browser stores recent visit records in memory.
# Chrome's internal DNS cache (chrome://net-internals/#dns)
www.naver.com -> 223.130.195.200 (TTL: 300 seconds remaining)
Cache hit → Skip DNS lookup. This is the fastest path.
If the browser cache misses, it asks the operating system.
# macOS/Linux
$ dscacheutil -cachedump -entries Host
# Windows
$ ipconfig /displaydns
If it's not there either, we need to query a real DNS server.
Now we ask the ISP (Internet Service Provider) DNS server. This server is called a Recursive Resolver.
My computer -> KT DNS (168.126.63.1)
"Give me the IP for www.naver.com!"
Here's the key: The Recursive Resolver travels the world on your behalf to find the answer. You only need to ask once.
The ISP DNS first asks the Root server.
KT DNS -> Root server (198.41.0.4)
"Where's www.naver.com?"
Root: "I don't know. But I know the TLD server that manages .com:
a.gtld-servers.net (192.5.6.30). Try them."
There are 13 original Root servers worldwide (a.root-servers.net ~ m.root-servers.net). But in reality, they're replicated to hundreds of locations via Anycast technology.
The ISP DNS now goes to the .com TLD server.
KT DNS -> .com TLD server (192.5.6.30)
"Where's naver.com?"
TLD: "I don't know. But I know the nameserver managing naver.com:
ns1.naver.com (125.209.248.6). Try them."
TLD stands for Top-Level Domain. It manages domains like .com, .org, .kr, .io.
Finally, we ask Naver's Authoritative server.
KT DNS -> ns1.naver.com (125.209.248.6)
"Give me the IP for www.naver.com!"
Naver DNS: "223.130.195.200. That's the final answer."
Authoritative means "having authority". This server holds the final truth.
The ISP DNS receives this IP and:
KT DNS cache:
www.naver.com -> 223.130.195.200 (TTL: 300 seconds)
All of this happens in 0.1 seconds.
DNS doesn't just store IPs. There are various record types, each serving a different purpose.
| Record Type | Purpose | Example | Real-World Use |
|---|---|---|---|
| A | Domain → IPv4 address | example.com → 93.184.216.34 | The most basic record. Core of web hosting |
| AAAA | Domain → IPv6 address | example.com → 2606:2800:220:1:: | IPv6 support. Next-generation addressing |
| CNAME | Domain alias | www.example.com → example.com | Change IP in one place, update everywhere |
| MX | Mail server designation | example.com → mail.google.com (priority: 10) | Email receiving. Lower priority = tried first |
| NS | Nameserver designation | example.com → ns1.aws.com | "AWS Route53 manages this domain" |
| TXT | Text information | example.com → "v=spf1 include:_spf.google.com ~all" | SPF auth, Google Search Console verification |
| SOA | Start of Authority | - | Domain management info (admin email, refresh rate, serial number) |
| PTR | IP → Domain (reverse) | 34.216.184.93.in-addr.arpa → example.com | Spam filtering. Verify mail server authenticity |
| SRV | Service location | _minecraft._tcp.example.com → server.example.com:25565 | Game servers, VoIP with port info |
| CAA | Certificate authority restriction | example.com → letsencrypt.org | Only Let's Encrypt can issue SSL certificates |
Say you run a blog at blog.company.com. Initially, you set up an A record.
# Initial setup
blog.company.com A 52.123.45.67
Later, you move servers from AWS to Vercel. The IP changes. The A record needs updating.
# After server migration
blog.company.com A 76.223.47.193 # Changed!
With CNAME, this problem disappears.
# CNAME setup
blog.company.com CNAME company.vercel.app
# Even if Vercel changes IPs, CNAME stays the same
company.vercel.app A 76.223.47.193 # Vercel manages this
Even when the IP changes, the CNAME record needs no touching. That's the power of aliasing.
The most confusing part of DNS configuration was TTL (Time To Live).
TTL indicates "how many seconds can you trust this information?"
www.example.com 300 A 93.184.216.34
↑
TTL (in seconds)
This record means "trust my cache for 300 seconds (5 minutes), then ask again afterward."
| TTL | Pros | Cons | When to Use |
|---|---|---|---|
| Long TTL (86400s = 24h) | Reduced DNS server load, fast responses | IP changes take up to 24h to propagate | Stable production servers |
| Short TTL (60s = 1m) | IP changes reflected immediately | Increased DNS query traffic, slight speed penalty | Server migrations, A/B testing, emergency maintenance |
When migrating between cloud providers, TTL management is critical. Take an AWS to GCP migration as an example.
If the IP is changed on D-Day while TTL is 86400 seconds (24 hours), some users will experience connection errors for up to 24 hours. ISP DNS servers keep caching the old IP for the full TTL duration.
The correct procedure:
D-7 days: Lower TTL to 300 seconds (5 minutes).
D-1 day: Wait for propagation. (After the old TTL of 24 hours expires)
D-Day: Change the IP.
D+1 day: Restore TTL to 86400 seconds.
You must lower TTL a week before server migration. This was the core of DNS management.
dig and nslookupTheory wasn't enough. I traced DNS paths myself.
dig +trace$ dig +trace www.google.com
; <<>> DiG 9.10.6 <<>> +trace www.google.com
;; global options: +cmd
. 518400 IN NS a.root-servers.net.
. 518400 IN NS b.root-servers.net.
. 518400 IN NS c.root-servers.net.
;; Received 239 bytes from 192.168.1.1#53(Local DNS) in 12 ms
com. 172800 IN NS a.gtld-servers.net.
com. 172800 IN NS b.gtld-servers.net.
;; Received 1176 bytes from 198.41.0.4#53(a.root-servers.net) in 23 ms
google.com. 172800 IN NS ns1.google.com.
google.com. 172800 IN NS ns2.google.com.
;; Received 384 bytes from 192.5.6.30#53(a.gtld-servers.net) in 89 ms
www.google.com. 300 IN A 142.250.76.100
;; Received 59 bytes from 216.239.32.10#53(ns1.google.com) in 21 ms
You can directly see the journey: Root(.) → TLD(.com) → Authoritative(ns1.google.com).
nslookup# A record lookup
$ nslookup www.github.com
Server: 168.126.63.1
Address: 168.126.63.1#53
Non-authoritative answer:
Name: www.github.com
Address: 140.82.121.4
# MX record lookup (mail server)
$ nslookup -type=MX google.com
Server: 168.126.63.1
Address: 168.126.63.1#53
google.com mail exchanger = 10 smtp.google.com.
dig$ dig www.naver.com
;; ANSWER SECTION:
www.naver.com. 268 IN A 223.130.195.200
↑
TTL (268 seconds remaining)
Run the same command 1 minute later, and you'll see the TTL decrease.
$ dig www.naver.com
www.naver.com. 208 IN A 223.130.195.200
↑
60 seconds decreased
# Query Google DNS (8.8.8.8) directly
$ dig @8.8.8.8 www.github.com
# Query Cloudflare DNS (1.1.1.1)
$ dig @1.1.1.1 www.github.com
You can query specific Public DNS servers directly without going through your ISP DNS.
DNS was designed in 1983. Back then, security wasn't considered.
An attacker injects fake DNS responses into ISP DNS servers.
Attacker -> ISP DNS
"bank.com's IP is 6.6.6.6" (phishing site IP)
ISP DNS believes it and caches
User -> ISP DNS
"Give me bank.com's IP?"
ISP DNS: "6.6.6.6" (user redirected to phishing site)
Solution: DNSSEC (DNS Security Extensions)
DNSSEC adds digital signatures to DNS responses.
Root server's public key
↓ verify signature
.com TLD server's public key
↓ verify signature
bank.com Authoritative server's response
↓ verify signature
Final IP
Through a Chain of Trust, each step's response is verified as genuine.
Traditional DNS uses UDP port 53 in plaintext. ISPs can see every site you visit.
My computer -> ISP DNS (plaintext)
"Give me the IP for www.wikileaks.org?"
ISP: "Aha, this person is viewing wikileaks" (logs saved)
Solution 1: DoH (DNS over HTTPS)
Encrypt DNS queries via HTTPS (port 443).
My computer -> Cloudflare DoH server (1.1.1.1)
DNS query encrypted via HTTPS
ISP: "Some HTTPS traffic... but I can't read the content"
Chrome and Firefox use DoH by default.
Solution 2: DoT (DNS over TLS)Use a dedicated encrypted channel for DNS (port 853).
My computer -> DNS server (port 853, TLS encrypted)
DoH vs DoT:
Google Public DNS (8.8.8.8) is fast anywhere in the world. How is this possible?
Anycast routing makes it happen.
IP 1.2.3.4 → one single server in Seoul
Access from USA → round trip to Seoul (200ms latency)
Anycast (8.8.8.8 approach)
IP 8.8.8.8 → hundreds of servers worldwide advertising simultaneously (BGP)
Access from Seoul → auto-routed to closest server (Seoul datacenter)
Access from USA → auto-routed to closest server (LA datacenter)
Network routing protocol (BGP) automatically finds the nearest server.
I finally understood. 8.8.8.8 isn't "one server"—it's a legion of servers spread across the globe.
A colleague bought a new domain. Set up DNS. But it wouldn't connect.
Reason: DNS Propagation DelayISP DNS servers worldwide need time to refresh their caches. It used to take 24-48 hours, but nowadays it usually finishes within 1 hour.
# Check propagation status
$ dig @8.8.8.8 new-domain.com # Shows up on Google DNS
$ dig @168.126.63.1 new-domain.com # Doesn't show on KT DNS (not propagated yet)
Solution: Wait, or test locally via /etc/hosts
$ sudo vi /etc/hosts
93.184.216.34 new-domain.com
I wanted to attach dev.myapp.com to my development server (localhost:3000).
$ sudo vi /etc/hosts
127.0.0.1 dev.myapp.com
Now I can access http://dev.myapp.com:3000 in the browser.
If team members need the same domain, spin up an internal DNS server.
# dnsmasq configuration
$ echo "address=/dev.myapp.com/192.168.1.100" >> /etc/dnsmasq.conf
$ sudo systemctl restart dnsmasq
A friend asked: "Is 8.8.8.8 faster?"
Generally, yes. Google DNS is:
For Korean sites (Naver, Kakao), ISP DNS might be faster. The reason: CDN optimization.
Using KT DNS:
naver.com → 223.130.195.200 (CDN within KT network)
Using 8.8.8.8:
naver.com → 223.130.195.95 (general server)
ISP DNS considers CDN server locations and gives you the closest IP.
Conclusion: For mostly Korean sites, use ISP DNS. For international sites or privacy concerns, use 8.8.8.8 or 1.1.1.1..com, .net, .kr. Managed by ICANN./etc/hosts (Linux/Mac), C:\Windows\System32\drivers\etc\hosts (Windows). Higher priority than DNS.A: It's likely due to DNS Propagation Delay.
When you change DNS settings at a registrar (GoDaddy, Cloudflare, etc.), ISP DNS servers worldwide need to receive this information and refresh their caches. It used to take 24-48 hours, but nowadays it usually completes within 1 hour.
How to check:# Check if Google DNS sees it
$ dig @8.8.8.8 yourdomain.com
# Check if ISP DNS sees it
$ dig @168.126.63.1 yourdomain.com # KT
$ dig @210.220.163.82 yourdomain.com # SK
If both respond, propagation is complete.
A: Two main cases.
1. Local development testing$ sudo vi /etc/hosts
127.0.0.1 dev.myapp.com
192.168.1.50 staging.company.com
When you type dev.myapp.com in your browser, it connects to 127.0.0.1 without DNS lookup.
127.0.0.1 facebook.com
127.0.0.1 twitter.com
This redirects those sites to localhost, making them inaccessible. (Some people use this as a productivity tool)
Warning: The hosts file has higher priority than DNS. If you misconfigure it, even normal sites won't open.
# KT DNS
$ dig @168.126.63.1 www.naver.com | grep "Query time"
Query time: 12 msec
# Google DNS
$ dig @8.8.8.8 www.naver.com | grep "Query time"
Query time: 18 msec
Conclusion: If you mostly use Korean sites, use ISP DNS. If you use many international sites or privacy is important, use 8.8.8.8 or 1.1.1.1.
A: Both connect domains, but what they point to differs.
A record: Domain → IP addressexample.com A 93.184.216.34
CNAME record: Domain → Another domain
www.example.com CNAME example.com
When to use CNAME?
When server IPs change frequently. For example, hosting services like Vercel and Netlify change IPs without notice.
# Using A record (bad)
blog.mysite.com A 76.223.47.193 # Vercel IP
# If Vercel changes IP → must manually update A record
# Using CNAME (good)
blog.mysite.com CNAME mysite.vercel.app
# If Vercel changes IP → your CNAME stays unchanged
Warning: You cannot use CNAME on the root domain (example.com). (DNS standard constraint) Instead, use ALIAS records if your DNS provider supports it (Cloudflare, Route53).
# Query via UDP (default)
$ dig @8.8.8.8 google.com
# Force query via TCP
$ dig @8.8.8.8 +tcp google.com
A: Yes. Set separate records for each subdomain.
# Zone File example
example.com A 93.184.216.34 # Main site
www.example.com A 93.184.216.34 # Main site
blog.example.com A 52.123.45.67 # Blog server (different IP)
api.example.com A 13.209.84.123 # API server (AWS)
cdn.example.com CNAME d111111abcdef8.cloudfront.net # CDN
Many companies actually operate this way.
www.company.com: Main websiteblog.company.com: Blog (Notion, WordPress)api.company.com: API serveradmin.company.com: Admin dashboard