CyberCumbria
Cyber Basics • Lesson 03

How does DNS work?

Computers communicate using IP addresses, but people prefer names. DNS is the system that connects the two.

DNS is the internet's address book.

Imagine having to remember an IP address every time you wanted to visit a website. Instead, we use names such as cybercumbria.co.uk.

The Domain Name System — DNS — helps your device find the IP address associated with that name.

Domain cybercumbria.co.uk
→
DNS Lookup
→
IPv4 Address 203.0.113.42
Important: DNS does not send you the website. It helps your device discover where the website or service can be found.

What happens when you type a website address?

Let's imagine you enter cybercumbria.co.uk into your browser.

1
Your Device

Your browser and operating system first check whether they already know the answer.

↓
2
DNS Resolver

If an answer is not already cached, your device asks its configured DNS resolver.

↓
3
DNS Hierarchy

The resolver can follow the DNS hierarchy to discover which servers know the answer.

↓
4
Authoritative DNS

The authoritative DNS server provides the DNS record for the requested domain.

↓
5
Answer Returned

The resolver returns the answer and can cache it for future requests.

↓
6
Connection Begins

Your browser can now use the returned address to connect to the destination server.

DNS is a hierarchy.

There isn't one giant DNS server containing every domain on the internet. DNS is distributed across many different systems.

ROOT .

Points towards the appropriate top-level domain.

↓
TOP-LEVEL DOMAIN .uk

Helps identify the authoritative servers responsible further down the hierarchy.

↓
AUTHORITATIVE DNS cybercumbria.co.uk

Holds the DNS records for the domain.

Who actually answers your DNS requests?

Your device normally uses the DNS resolver configured by your network. This may ultimately be provided by your ISP, your organisation, or a public DNS service.

Cloudflare 1.1.1.1

A widely used public recursive DNS resolver operated by Cloudflare.

Google Public DNS 8.8.8.8

Google's public recursive DNS service.

Quad9 9.9.9.9

A public DNS resolver with a focus on security and blocking known malicious domains.

Recursive vs authoritative: a recursive resolver finds answers on your behalf. An authoritative DNS server holds the official DNS records for a particular domain.

Your DNS path may have extra steps.

A device does not necessarily communicate directly with a public resolver. Home routers, filtering services and local DNS servers can sit between the device and the upstream resolver.

DEVICE 192.168.1.25

Needs to resolve a domain name.

↓
LOCAL DNS Pi-hole

Can filter domains and answer cached or local DNS requests.

↓
UPSTREAM RESOLVER 1.1.1.1

Handles requests that still need to be resolved externally.

Tools such as Pi-hole use DNS to block requests to selected domains. If a domain is on a blocklist, Pi-hole can prevent the normal DNS resolution process from completing.

DNS stores much more than IP addresses.

Different record types provide different information about a domain and its services.

A
IPv4 address example.com → 203.0.113.42
AAAA
IPv6 address example.com → 2001:db8::42
CNAME
Alias to another hostname www.example.com → example.com
MX
Mail server Where should email for this domain be delivered?
TXT
Text information Verification, SPF and other domain information
NS
Name servers Which authoritative DNS servers manage the zone?
PTR
Reverse DNS IP address → hostname

DNS doesn't start from scratch every time.

DNS answers can be cached. This makes repeated lookups faster and reduces the amount of DNS traffic travelling across the internet.

Cache Remember the answer

Previously resolved information can temporarily be reused.

TTL Time To Live

DNS records contain a TTL that helps determine how long an answer may be cached before it should be refreshed.

Traditional DNS isn't necessarily encrypted.

Traditional DNS queries can reveal which domain names a device is trying to resolve to systems able to observe that DNS traffic.

DoH DNS over HTTPS

Sends DNS queries through an encrypted HTTPS connection.

DoT DNS over TLS

Encrypts DNS using TLS, commonly over a dedicated port.

Encryption protects DNS queries while they are travelling between the client and the encrypted DNS resolver. It does not make internet activity invisible or anonymous.

Why does a SOC analyst care about DNS?

DNS activity can provide valuable evidence about what devices on a network are trying to communicate with.

Suspicious domains

A device repeatedly resolving an unusual or known malicious domain may require investigation.

Command & control

Malware can use DNS while attempting to locate or communicate with attacker-controlled infrastructure.

DNS tunnelling

Attackers can attempt to encode data inside DNS queries and responses to create an unusual communication channel.

Unusual behaviour

Large numbers of queries, strange subdomains or unexpected record types can provide useful investigation clues.

CLIENT 192.168.1.25
QUERY example.com
TYPE A
RESPONSE 203.0.113.42

A single DNS lookup is rarely enough to decide that something is malicious. Analysts combine DNS evidence with other information such as endpoint activity, network connections, threat intelligence and authentication logs.

Ask DNS yourself.

Windows includes nslookup, while Linux systems commonly provide tools such as dig.

Windows nslookup cybercumbria.co.uk
Ask Cloudflare directly nslookup cybercumbria.co.uk 1.1.1.1
Linux dig cybercumbria.co.uk
Try running a normal lookup first, then query a specific resolver. Compare the DNS server used and the answers returned.

Ports: finding the right service.

DNS helped us find the server. Next we'll look at how ports help network traffic reach the correct service running on that server.