Ağ Araçları
TEKNİK REHBER AĞ ARAÇLARI DNS 2026

dig · nslookup
dns sorguları.

Domain çözümlenemiyor mu? DNS zincirini takip et, cevabı bul, sorunu teşhis et.

00 DNS temelleri — record türleri

DNS (Domain Name System), alan adlarını IP adreslerine çeviren hiyerarşik bir sistemdir. İnternetin telefon rehberi.

DNS hiyerarşisi şöyle çalışır:

  example.com sorgusu:

  Client → Recursive Resolver (8.8.8.8)
              ↓ (cache yoksa)
           Root NS (.) → "com NS kim?"
              ↓
           TLD NS (.com) → "example.com NS kim?"
              ↓
           Authoritative NS (ns1.example.com)
              ↓
           Yanıt: 93.184.216.34
              ↓
           Resolver → Client (TTL kadar cache'ler)
    

DNS record türleri

TürAçıklamaÖrnek
AIPv4 adresiexample.com → 93.184.216.34
AAAAIPv6 adresiexample.com → 2606:2800:21f:cb07::...
CNAMECanonical name (alias)www → example.com
MXMail exchange sunucusumail.example.com (öncelik: 10)
NSAuthoritative name serverns1.example.com
PTRReverse lookup (IP → domain)34.216.184.93.in-addr.arpa
TXTMetin kaydı (SPF, DKIM, doğrulama)"v=spf1 include:_spf.google.com ~all"
SOAStart of Authority — zone bilgisiBirincil NS, yönetici e-posta, seri no
SRVServis konumu_mqtt._tcp.example.com
CAASertifika otoritesi kısıtlamasıHangi CA sertifika verebilir

Kurulum

bash
# dig, bind-utils veya dnsutils ile gelir
apt-get install dnsutils    # Debian/Ubuntu
apk add bind-tools          # Alpine
yum install bind-utils      # RHEL/CentOS

01 dig temel kullanım ve çıktı okuma

dig (Domain Information Groper) — DNS sorunlarını teşhis etmek için en kapsamlı araç.

bash
# Temel A sorgusu
dig example.com A

# Belirli DNS sunucusunu kullan
dig @8.8.8.8 example.com A          # Google DNS
dig @1.1.1.1 example.com A          # Cloudflare DNS
dig @192.168.1.1 example.com A      # Yerel router/DNS

# Farklı record türleri
dig example.com AAAA         # IPv6
dig example.com MX           # Mail sunucuları
dig example.com NS           # Name server'lar
dig example.com TXT          # TXT kayıtları (SPF, DKIM vs.)
dig example.com SOA          # Zone başlangıç kaydı
dig example.com ANY          # Tüm record türleri (bazı NS kısıtlar)

dig çıktısını okumak

dig example.com A çıktısı
; <<>> DiG 9.18.24 <<>> example.com A
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12345
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
                                                     ↑           ↑
                                              cevap sayısı    yetki NS sayısı

;; QUESTION SECTION:
;example.com.           IN A          ← sorgu (ne sorduk)

;; ANSWER SECTION:
example.com.    3600    IN  A  93.184.216.34
│               │           │  └─ yanıt (IP adresi)
│               │           └─ record türü
│               └─ TTL (saniye) — cache süresi
└─ domain adı

;; Query time: 15 msec                ← yanıt süresi
;; SERVER: 8.8.8.8#53(8.8.8.8)       ← yanıt veren DNS
;; MSG SIZE  rcvd: 56

Çıktıyı sadeleştirme

bash
# Sadece cevap kısmı
dig +noall +answer example.com A
# example.com.    3600    IN  A  93.184.216.34

# Sadece IP adresi (+short)
dig +short example.com A
# 93.184.216.34

# Birden fazla domain hızlıca sorgula
for domain in google.com github.com cloudflare.com; do
  dig +short "$domain" A
done

# MX öncelik + sunucu
dig +short gmail.com MX
# 5 gmail-smtp-in.l.google.com.
# 10 alt1.gmail-smtp-in.l.google.com.
# (öncelik düşükse öncelikli)

02 Reverse lookup — IP'den domain

IP adresini verip hangi domain adına ait olduğunu sormak — PTR kaydı sorgusu.

bash
# -x ile reverse lookup
dig -x 8.8.8.8
# 8.8.8.8.in-addr.arpa. 21599 IN PTR dns.google.

dig -x 1.1.1.1
# 1.1.1.1.in-addr.arpa. 1799 IN PTR one.one.one.one.

# +short ile sadece domain
dig +short -x 8.8.4.4
# dns.google.

# Manuel PTR sorgusu (ne yapıldığını anlamak için)
# 8.8.8.8 için → 8.8.8.8.in-addr.arpa
dig 8.8.8.8.in-addr.arpa PTR

# IPv6 reverse lookup
dig -x 2001:4860:4860::8888
# PTR kaydı: dns.google.

# Bir ağdaki tüm IP'lerin reverse lookup'ı (script)
for i in $(seq 1 254); do
  result=$(dig +short -x 192.168.1.$i 2>/dev/null)
  [ -n "$result" ] && echo "192.168.1.$i → $result"
done
PTR KAYDININ ANLAMLILIĞI

PTR kaydı ayarlanmamışsa reverse lookup boş döner — bu normal bir durumdur. E-posta sunucusu kuruyorsan PTR kaydı zorunludur — çoğu spam filtresi PTR kaydı olmayan IP'den gelen e-postayı reddeder. Embedded IoT'de genellikle PTR gerekmez.

03 Trace ve authoritative sorgular

DNS zincirinin tamamını takip et — root'tan authoritative NS'e kadar.

bash
# Root'tan başlayarak DNS zincirini izle (+trace)
dig +trace example.com A
# Root NS'leri listeler
# .com TLD NS'leri listeler
# example.com authoritative NS'leri listeler
# Nihai A kaydını gösterir

# Authoritative NS'den doğrudan sorgula
# Önce NS'i bul
dig +short example.com NS
# a.iana-servers.net.

# O NS'e doğrudan sor
dig @a.iana-servers.net example.com A

# Authoritative yanıt mı? Header'daki "aa" flag'ine bak
# flags: qr aa rd → "aa" = authoritative answer

# TTL'in asıl değeri authoritative NS'te görülür
# Recursive resolver TTL'i azaltarak döner (cache ne kadar geçerli)

Kullanışlı dig seçenekleri

+short
Yalnızca yanıt değerini döker — scripting için ideal.
+noall +answer
Tüm bölümleri gizle, sadece ANSWER döndür.
+trace
Root'tan itibaren tüm delegasyonu takip et.
+dnssec
DNSSEC doğrulama bilgisini ekle.
+tcp
UDP yerine TCP kullan (büyük yanıtlar veya zone transfer için).
+time=N
Timeout süresi (saniye).
+retry=N
Yeniden deneme sayısı.
+stats
Sorgu istatistikleri (yanıt süresi, sunucu).
-4 / -6
Yalnızca IPv4 veya IPv6 üzerinden sorgula.
bash — pratik kombinasyonlar
# SPF kaydını oku
dig +short gmail.com TXT | grep spf

# DKIM kaydını oku
dig +short google._domainkey.gmail.com TXT

# DMARC kaydı
dig +short _dmarc.gmail.com TXT

# SRV kaydı — MQTT broker discovery
dig +short _mqtt._tcp.example.com SRV

# Zone transfer denemesi (çoğu sunucu reddeder — test için)
dig @ns1.example.com example.com AXFR

04 nslookup — interaktif mod

nslookup daha eski bir araçtır ama interaktif modu hızlı testler için kullanışlıdır. Windows'ta da çalışır.

bash — non-interaktif
# Basit A sorgusu
nslookup example.com

# Belirli DNS sunucusu
nslookup example.com 8.8.8.8

# MX kaydı
nslookup -type=MX gmail.com

# PTR (reverse lookup)
nslookup 8.8.8.8
nslookup — interaktif mod
# nslookup çalıştır (parametresiz)
nslookup
> set type=MX         ← sorgulama türünü değiştir
> gmail.com           ← sorgula
> set type=NS
> example.com
> server 1.1.1.1      ← farklı DNS sunucusuna geç
> set type=A
> cloudflare.com
> exit
DIG vs NSLOOKUP

nslookup hem eski hem de bazı sistemlerde deprecated sayılır. dig daha doğru, daha esnek ve DNSSEC desteklidir. Scripting ve kapsamlı analiz için dig kullan. nslookup yalnızca hızlı interaktif test veya Windows ortamında (dig kurulu değilse) kullan.

05 host komutu — basit alternatif

host, en basit DNS sorgulama aracıdır. Tek satır çıktı — scripting için idealdir.

bash
# Temel A sorgusu
host example.com
# example.com has address 93.184.216.34
# example.com mail is handled by 0 .

# Belirli sunucu
host example.com 8.8.8.8

# Record türü belirt
host -t MX gmail.com
host -t NS example.com
host -t TXT example.com

# Reverse lookup
host 8.8.8.8
# 8.8.8.8.in-addr.arpa domain name pointer dns.google.

# Tüm kayıtları göster
host -a example.com

# Verbose çıktı
host -v example.com

# Domain varlığını script'te kontrol et
if host example.com >/dev/null 2>&1; then
  echo "DNS çözümleme başarılı"
else
  echo "DNS sorunu var!"
fi

06 Pratik: embedded DNS debug

Embedded cihazda DNS çözümlemesi başarısız — sistematik debug.

/etc/resolv.conf kontrol

/etc/resolv.conf
# Standart resolv.conf
nameserver 192.168.1.1      # birincil DNS
nameserver 8.8.8.8          # yedek DNS
search local                # kısa isim arama domain'i
options ndots:5             # kaç nokta varsa search listesini kullan
options timeout:2           # saniye timeout
options attempts:3          # yeniden deneme sayısı
bash — DNS debug adımları
# 1. resolv.conf var ve doğru mu?
cat /etc/resolv.conf

# 2. DNS sunucusuna ping
ping -c 1 192.168.1.1

# 3. DNS sunucusuna doğrudan sorgu
dig @192.168.1.1 example.com A
# Hata: connection timed out → DNS sunucusu erişilemez
# Hata: SERVFAIL → DNS sunucusu çalışıyor ama cevap üretemedi
# Hata: NXDOMAIN → Domain yok

# 4. Google DNS ile karşılaştır
dig @8.8.8.8 example.com A
# 8.8.8.8 çalışıyorsa: yerel DNS sorunu
# 8.8.8.8 de çalışmıyorsa: network bağlantısı sorunu

# 5. Gecikme ölç
dig @192.168.1.1 example.com A | grep 'Query time'
# Query time: 500 msec → DNS yavaş, timeout sorunu olabilir

dnsmasq — embedded için hafif DNS/DHCP

/etc/dnsmasq.conf — embedded minimal konfig
# Interface — sadece bu interface'de dinle
interface=eth0
bind-interfaces

# Upstream DNS sunucuları
server=8.8.8.8
server=1.1.1.1

# Cache boyutu
cache-size=1000

# Statik host → IP eşlemesi
address=/device.local/192.168.1.100

# DHCP aralığı
dhcp-range=192.168.1.50,192.168.1.150,24h

# Log sorguları (debug için aç, prod'da kapat)
log-queries
log-facility=/var/log/dnsmasq.log
bash
# dnsmasq çalışıyor mu?
systemctl status dnsmasq
# Ya da:
ps aux | grep dnsmasq

# dnsmasq log'unu izle
tail -f /var/log/dnsmasq.log

# dnsmasq DNS cache'ini temizle
kill -HUP $(cat /var/run/dnsmasq.pid)

mDNS / Avahi — .local domain çözümlemesi

bash
# avahi-daemon çalışıyor mu?
systemctl status avahi-daemon

# .local domain'leri tara
avahi-browse -a -r

# Belirli bir servis türünü bul
avahi-browse -r _http._tcp

# .local adresini çöz
avahi-resolve -n raspberry.local

# dig ile mDNS (port 5353, multicast)
dig @224.0.0.251 -p 5353 -t A raspberry.local

# /etc/nsswitch.conf'ta mDNS önceliği kontrol et
grep hosts /etc/nsswitch.conf
# hosts: files mdns4_minimal [NOTFOUND=return] dns
EMBEDDED DNS TASARIMI

Embedded sistemde her DNS sorgusu gecikme ve güvenilirlik riski taşır. Sık erişilen domain'ler için statik /etc/hosts girişi kullan. Bağlantısız çalışma gerekiyorsa IP adreslerini doğrudan kullan. Resolv.conf'ta timeout:1 attempts:1 ile DNS başarısızlığından hızlı geri dönüş sağla.