#Why this matters
Before a host can reach a server, it needs two things: its own IP settings (address, subnet mask, gateway and name server) via DHCP, and a way to turn domain names like lab.local into IP addresses via DNS.
Because nearly every connection begins with DHCP or DNS, both protocols leave essential trails. In OSINT work, DNS records reveal mail hosts and verification tokens. In digital forensics (raqamli-izquarlik), DHCP lease logs link a MAC address to an IP at a given time, while DNS logs expose malware lookups or data exfiltration inside subdomains.
#How DHCP leases an IP address
The Dynamic Host Configuration Protocol (DHCP) assigns IP settings over UDP: servers listen on port 67 and clients on port 68. Having no IP yet, a client broadcasts to 255.255.255.255 from 0.0.0.0 in a four-step DORA exchange.
- Discover: Client broadcasts to find any DHCP server on the segment.
- Offer: Servers reply with an available IP and configuration options.
- Request: Client broadcasts which offer it accepted so others withdraw theirs.
- Acknowledge (ACK): The chosen server commits the lease and timer.
Configuration travels in options: Option 1 (subnet mask), Option 3 (default gateway), Option 6 (DNS servers) and Option 51 (lease duration). Clients attempt unicast renewal at 50% of the lease (T1) and broadcast rebinding at 87.5% (T2).
#How DNS resolves names to addresses
The Domain Name System (DNS) resolves names over UDP port 53, switching to TCP port 53 for oversized replies or zone transfers (AXFR). Three roles cooperate:
- Stub resolver: The OS library forwarding queries to the resolver from DHCP Option 6.
- Recursive resolver: A caching server that tracks down uncached answers for the client.
- Authoritative nameserver: The server holding official zone records. On a cache miss, the recursive server queries a root server (
.), a TLD server (such as.org), and the domain's authoritative server.
- Stub resolverqueries recursive resolver
- Recursive resolverwalks root, TLD and authoritative NS on miss
- Authoritative NSreturns record with TTL 300
- Recursive resolvercaches for 300s and replies
Each reply includes a TTL (Time to Live) in seconds controlling cache lifetime. Key record types:
| Record | Purpose | OSINT or forensic value |
|---|---|---|
A / AAAA |
Maps name to IPv4 / IPv6 address | Identifies server IP |
CNAME |
Alias to another domain name | Reveals CDN or SaaS providers |
MX |
Mail server hostname and priority | Maps email infrastructure |
NS |
Authoritative nameservers for zone | Shows DNS provider |
TXT |
Arbitrary text strings | Holds SPF, DMARC or tunneling data |
PTR |
Reverse lookup from IP to name | Maps IPs via in-addr.arpa |
#Inspecting DNS and DHCP in practice
Use dig or nslookup for direct lookups and Wireshark for packet inspection.
$ dig @10.10.10.2 web.example.test A +short
192.0.2.40
$ dig @10.10.10.2 example.test TXT +short
"v=spf1 mx -all"
$ dig -x 192.0.2.40 +short
web.example.test.
$ nslookup -type=mx example.test 10.10.10.2
example.test mail exchanger = 10 mail.example.test.In Wireshark, filter with dns, dns.qry.name contains "example.test", dns.flags.response == 0 (queries only) and dhcp (bootp in older versions). Long, high-entropy subdomains like 4a6f686e.c2.lab.local signal DNS tunneling, encoding stolen data inside subdomain labels.
#Defending and common mistakes
- No DHCP Snooping: Without DHCP Snooping on switches, any access port can answer Discover broadcasts and become a rogue gateway or DNS server.
- Unrestricted outbound UDP/53: Route endpoints through internal logging resolvers and block direct port 53 egress.
- Unverified or plaintext DNS: Deploy DNSSEC to sign records against tampering, and DoT or DoH for transport privacy.
- Forgetting TTL caching: Removed records stay cached on resolvers until their TTL reaches zero.
#Summary
- DHCP leases IP settings over UDP 67/68 via DORA, delivering gateway (Option 3) and DNS (Option 6) settings and renewing at T1 (50%) and T2 (87.5%).
- DNS resolves names over UDP/TCP 53 through stub, caching recursive and authoritative servers governed by TTL.
- Record types (
A,AAAA,CNAME,MX,NS,TXT,PTR) support OSINT mapping and forensic analysis. - Combine DHCP Snooping, centralized DNS logging, DNSSEC and
dig/Wiresharkinspection to prevent rogue leases and detect DNS tunneling.