Marcin Jahn | Dev Notebook
  • Home
  • Programming
  • Technologies
  • Projects
  • About
  • Home
  • Programming
  • Technologies
  • Projects
  • About
  • An icon of the Networking section Networking
    • HTTP Protocol
    • OSI Model
    • TCP Procol
    • UDP Protocol
    • WebSocket
    • HSTS
    • DNS
    • Server Name Indication
    • gRPC
  • An icon of the Security section Security
    • OAuth2
      • Sender Constraint
    • Cryptography
      • Cryptography Basics
    • TPM
      • Overiew
      • TPM Entities
      • TPM Operations
  • An icon of the Linux section Linux
    • Gist of Linux Tooling
    • Unknown
    • SELinux
    • Containers
    • Bash Scripting
    • Linux From Scratch
    • Networking
  • An icon of the Kubernetes section Kubernetes
    • Meaning and Purpose
    • Cluster
    • Dev Environment
    • Kubernetes API
    • Objects
    • Pods
    • Scaling
    • Events
    • Storage
    • Configuration
    • Organizing Objects
    • Services
    • Ingress
    • Helm
  • An icon of the Observability section Observability
    • Tracing
  • An icon of the Databases section Databases
    • ACID
    • Glossary
    • Index
    • B-Tree and B+Tree
    • Partitioning and Sharding
    • Concurrency
    • Database Tips
  • An icon of the SQL Server section SQL Server
    • Overview
    • T-SQL
  • An icon of the MongoDB section MongoDB
    • NoSQL Overview
    • MongoDB Overview
    • CRUD
    • Free Text Search
  • An icon of the Elasticsearch section Elasticsearch
    • Overview
  • An icon of the Git section Git
    • Git
  • An icon of the Ansible section Ansible
    • Ansible
  • An icon of the Azure section Azure
    • Table Storage
    • Microsoft Identity
  • An icon of the Google Cloud section Google Cloud
    • Overview
  • An icon of the Blockchain section Blockchain
    • Overview
    • Smart Contracts
    • Solidity
    • Dapps
  • Home Assistant
    • Home Assistant Tips
  • An icon of the Networking section Networking
    • HTTP Protocol
    • OSI Model
    • TCP Procol
    • UDP Protocol
    • WebSocket
    • HSTS
    • DNS
    • Server Name Indication
    • gRPC
  • An icon of the Security section Security
    • OAuth2
      • Sender Constraint
    • Cryptography
      • Cryptography Basics
    • TPM
      • Overiew
      • TPM Entities
      • TPM Operations
  • An icon of the Linux section Linux
    • Gist of Linux Tooling
    • Unknown
    • SELinux
    • Containers
    • Bash Scripting
    • Linux From Scratch
    • Networking
  • An icon of the Kubernetes section Kubernetes
    • Meaning and Purpose
    • Cluster
    • Dev Environment
    • Kubernetes API
    • Objects
    • Pods
    • Scaling
    • Events
    • Storage
    • Configuration
    • Organizing Objects
    • Services
    • Ingress
    • Helm
  • An icon of the Observability section Observability
    • Tracing
  • An icon of the Databases section Databases
    • ACID
    • Glossary
    • Index
    • B-Tree and B+Tree
    • Partitioning and Sharding
    • Concurrency
    • Database Tips
  • An icon of the SQL Server section SQL Server
    • Overview
    • T-SQL
  • An icon of the MongoDB section MongoDB
    • NoSQL Overview
    • MongoDB Overview
    • CRUD
    • Free Text Search
  • An icon of the Elasticsearch section Elasticsearch
    • Overview
  • An icon of the Git section Git
    • Git
  • An icon of the Ansible section Ansible
    • Ansible
  • An icon of the Azure section Azure
    • Table Storage
    • Microsoft Identity
  • An icon of the Google Cloud section Google Cloud
    • Overview
  • An icon of the Blockchain section Blockchain
    • Overview
    • Smart Contracts
    • Solidity
    • Dapps
  • Home Assistant
    • Home Assistant Tips

DNS

Here’s a diagram of how DNS works:

How DNS works

We assume that there is some internal DNS server that we’re reaching out to first. It could be a DNS server hosted on our gateway.

The image presents the worst-case scenario, assuming that nothing was cached.

  1. If the entry is in the DNS cache of the internal DNS server, and the TTL of that entry has not expired, then the response is supplied immediately to the client. Similarly, if the client is requesting an entry that’s hosted on the server in a zone file, the answer is supplied immediately to the client.
  2. If the entry is not in the cache of the internal DNS server, or if it is in the cache but the TTL of that entry has expired, then the internal server forwards the request to its upstream providers (often called forwarders) to refresh the entry. If the query is in the cache of the forwarder, it will simply return the answer. If this server has the authoritative name server for the domain, it will simply query that host (skipping ahead in the process to Step 5).
  3. If the forwarder does not have the request in the cache, it will in turn request upstream. In this case, though, it will likely query the root name servers. The goal in this is to find the “authoritative name server” that has the actual entries (in a zone file) for that domain. In this case, the query is made to the root name servers for “.com”.
  4. The root name server will not return the actual answer, but will instead return the authoritative name server for the top-level domain (TLD)—in this case, for .com.
  5. After the forwarder gets this response, it updates its cache with that name server entry, then makes the actual query against that server.
  6. The authoritative server for “.com” returns the authoritative DNS server for “example.com”.
  7. The forwarder server then makes a request against this final authoritative name server. 8. The authoritative name server for example.com returns the actual query “answer” to the forwarder server.
  8. The forwarder name server caches that answer, then sends a reply back to your internal name server.
  9. Your internal DNS server also caches that answer, then forwards it back to the client. The client caches the request in its local cache, then passes the requested information (the DNS response) to the application that requested it (like a web browser)

Layers

Logically, there are various layers of DNS:

  1. Local/Internal DNS
  2. External DNS (like 8.8.8.8)
  3. Root Servers (.)
  4. TLD Servers (e.g., .com)
  5. Other Authoritative Servers

There are 13 Root Servers (in reality these are rather clusters than servers).

New Approaches

DNS requests are made without encryption. That basically means that ISPs can track the websited that you visit. There are two approaches to circumvent that: DoH and DoT.

DoH

DNS over HTTPS - it basically turns DNS servers into HTTP(S) servers listening on 443 for DNS queries.

DoT

DNS over TLS. It’s the standard DNS, but encrypted with TLS.

Source

  • Linux for Networking Professionals
←  HSTS
Server Name Indication  →
© 2023 Marcin Jahn | Dev Notebook | All Rights Reserved. | Built with Astro.