Unveiling the Mystery Behind the Scenes: How the Internet Works

Gabriel Affonso
5 min readApr 1, 2024

--

In my last post,

I explored the foundational skills that set the stage for my development adventure. I delved into Git, the version control system that keeps code organized and dove into the web development trifecta: HTML, CSS and JavaScript.

Learning HTML’s structure and semantics, leveraging the styling power of CSS (including flexbox and grid) and programming with JavaScript provided a base for understanding web pages. But as I experimented, a new question arose: how does it all work behind the scenes?

This post takes us on a new quest — exploring the inner workings of the internet. We’ll delve into a networking protocol that makes the web tick, Hypertext Transfer Protocol (HTTP) and discover how web browsers translate code into the websites we see and interact with every day.

But before diving in, let’s address a fundamental question: how do we access information online in the first place? This is where the Domain Name System (DNS) comes into play. Imagine the internet as a giant city and websites as individual buildings. Each building has a unique address that helps people find it. However, instead of long strings of numbers, IP addresses, we use memorable names like nytimes.com to access these online locations. Here’s where DNS steps in, acting like a giant phonebook for the internet.

How Does DNS Work?

When you type a domain name into your web browser, a fascinating journey unfolds behind the scenes. Here’s a breakdown of the key players involved in a DNS resolution:

  • DNS Resolver: This acts like a librarian, receiving your request (the domain name) and initiating the search for the corresponding IP address;
  • Root Nameservers: These are the first point of reference, similar to an index in a library, directing the resolver to the appropriate TLD (Top-Level Domain) nameserver;
  • TLD Nameserver: Think of this as a specific section in the library, like “.com” or “.net”. It stores information for domains within its category;
  • Authoritative Nameserver: This is the final destination, holding the actual address (IP address) for the requested website.

The DNS resolver sends queries through these different servers until it reaches the authoritative nameserver, retrieves the IP address and delivers it back to your browser. With the IP address in hand, your browser can finally connect to the website and display its content.

There’s more to DNS than meets the eye! Let’s explore some additional concepts:

  • DNS Caching: To optimize performance, frequently accessed DNS records are stored temporarily on your computer or the DNS resolver. This eliminates the need to repeat the entire lookup process for these websites, resulting in faster loading times;
  • DNS Record Types: These records provide various functionalities beyond IP addresses. For instance, MX records specify mail server locations and CNAME records act like aliases for domain names.

This is especially important for cybersecurity, as malicious actors can try to spoof DNS records to redirect you to fraudulent websites.

Understanding Domain Names

While domain names are user-friendly, they don’t actually “belong” to anyone. Instead, you register the right to use a specific domain name for a certain period. This registration process involves companies called registrars.

HTTP: The Language of the Web

Now that we know how to find websites by their addresses (domain names), let’s delve into the network protocol that makes the magic happen: Hypertext Transfer Protocol (HTTP). HTTP acts as a set of rules for how clients, web browsers, and servers communicate to exchange information. It functions using a client-server model. Web browsers act as clients, initiating requests for resources like HTML documents, images or videos from web servers.

This communication occurs through a request-response cycle. The client sends an HTTP request to the server, specifying the desired resource. The server processes the request and sends back an HTTP response containing the requested data or an error message if something goes wrong.

An HTTP request typically consists of a request method (like GET or POST), the URL of the resource being requested and additional headers that provide context about the request. There are various HTTP methods, each serving a specific function. GET is used to retrieve resources, while POST is used to submit data to a server.

The server responds with an HTTP status code indicating the outcome of the request. A common code is 200 OK, that means that the request was successful.

This is just a glimpse into HTTP.

By understanding how these concepts work together, you gain a deeper appreciation for the complex yet seamless experience of browsing the web.

While exploring the inner workings of the internet might seem purely technical, understanding these concepts empowers you to be more cyber aware. Here’s a few examples:

  • Securing Your Connection: Understanding HTTP allows you to recognize the importance of HTTPS, the secure version of the protocol. HTTPS encrypts communication between your browser and the server, protecting your data from eavesdropping. Look for the padlock icon and “HTTPS” in the address bar to ensure a secure connection;
  • Building a Strong Defense: Knowledge about web technologies empowers you to make informed decisions about online security. For instance, understanding web hosting can help you choose reliable providers with robust security measures in place to protect your data.

Illuminating Internet Dynamics with Tcpdump

As we traverse the labyrinth of internet intricacies, let’s forge connections between DNS, HTTP and the loyal sentinel, tcpdump.

Peering into DNS Dynamics:

Within the DNS realm, tcpdump emerges as a silent sentinel dumping traffic on a network. By intercepting DNS queries and responses, tcpdump unveils the orchestration of domain translations. Imagine tcpdump as a vigilant watcher, deciphering the dialogue between your system and the DNS infrastructure, depending on the filter of course. As your device sends out queries in pursuit of web destinations, tcpdump intercepts these messages, unraveling the journey from domain name to IP address. It elucidates the exchange between DNS resolvers, root nameservers, TLD nameservers and authoritative nameservers, offering a panoramic view of the DNS ecosystem.

Delving into HTTP Horizons:

Transitioning to the realm of HTTP, tcpdump assumes a pivotal role as a custodian of digital exchanges. As web browsers engage in dialogues with servers, tcpdump stands sentinel, capturing the symphony of HTTP requests and responses. Picture tcpdump as a vigilant observer, dissecting the nuances of client-server interactions. It intercepts the entreaties dispatched by your browser — the GETs, the POSTs — and scrutinizes the responses, decoding the HTTP status codes dictating the outcome of each rendezvous. In this capacity, tcpdump offers insights into the lexicon of web discourse, revealing the heartbeat of online communication.

As we navigate the digital landscape armed with tcpdump’s insights and wireshark’s graphical help, we embark on a journey of digital empowerment, safeguarding our digital assets and fortifying our cyber citadels against the ever-present specter of cyber threats.

#InternetBasics #tcpdump #TechExploration #CyberSecurity #packetsniffer

--

--