100 Days of Servers Distributions- Day 6: Exploring DNS and IP Routing

pirvanm - Oct 4 - - Dev Community

Day 6: Exploring DNS and IP Routing – A Journey into the Heart of the Internet
Welcome to Day 6 of our tech adventure! Today, we’re diving into two of the most crucial elements that keep the internet running smoothly: DNS (Domain Name System) and IP routing. While these might sound like technical buzzwords, they play a massive role in how we experience the internet every day—from sending emails to loading a web page in seconds. Let’s break them down into digestible, human-friendly bites.

What is DNS? (And why should you care?)
Imagine you’re in a huge city, and every building has a unique, hard-to-remember address (like 192.168.1.1—sound familiar?). That’s how computers communicate, using IP addresses that look like strings of random numbers. But we humans are better at remembering names than numbers, right? That’s where DNS (Domain Name System) steps in.

DNS acts as the phonebook of the internet. When you type a website name like www.example.com into your browser, DNS translates it into the corresponding IP address. It's like asking a friend for the address of that new restaurant downtown—your friend (the DNS server) tells you where to go!

We'll use Docker to containerize it.

Here's how we can achieve that:

Steps:
Create a simple web application (we’ll use Python with Flask as an example).
Write a Dockerfile to package this application into a Docker container.
Build and run the Docker container.
Let’s break it down.

  1. Create the Application We’ll use Flask to serve your article as a web page. Flask is a lightweight web framework for Python.

File structure:
bash
Copy code
dockerized-article/

├── app/
│ ├── templates/
│ │ └── index.html
│ ├── app.py
├── Dockerfile
├── requirements.txt
Step 1.1: Create the Flask app (app.py)
Inside the app/ directory, create the app.py file to serve the article.

python
Copy code
from flask import Flask, render_template

app = Flask(name)

@app.route('/')
def home():
return render_template('index.html')

if name == 'main':
app.run(host='0.0.0.0', port=5000)
Step 1.2: Create the HTML template (index.html)
Inside the app/templates/ directory, create index.html to display the article content.

html



<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Day 6: Exploring DNS and IP Routing</title>
</head>
<body>
    <h1>Day 6: Exploring DNS and IP Routing</h1>
    <p>Welcome to Day 6 of our tech adventure! Today, we’re diving into two of the most crucial elements that keep the internet running smoothly: DNS (Domain Name System) and IP routing...</p>
    <!-- You can copy and paste the rest of the article here -->
</body>
</html>


Enter fullscreen mode Exit fullscreen mode

Step 1.3: Specify dependencies (requirements.txt)
Create a requirements.txt file in the root of your project directory to specify the Python dependencies:

makefile



Flask==2.1.2


Enter fullscreen mode Exit fullscreen mode
  1. Write a Dockerfile

Next, we’ll create a Dockerfile to define how our application should be packaged into a Docker image.

Create a Dockerfile in the root of your project directory:

Dockerfile

Step 1: Use an official Python runtime as a parent image



FROM python:3.9-slim

Enter fullscreen mode Exit fullscreen mode




Step 2: Set the working directory in the container

WORKDIR /app

Step 3: Copy the current directory contents into the container at /app

COPY . /app

Step 4: Install any necessary dependencies

RUN pip install --no-cache-dir -r requirements.txt

Step 5: Make port 5000 available to the world outside this container

EXPOSE 5000

Step 6: Run the application

CMD ["python", "app/app.py"]

  1. Build and Run the Docker Container Step 3.1: Build the Docker image In the terminal, navigate to the project directory (dockerized-article/), then run the following command to build your Docker image:

docker build -t dns-ip-routing-article .
Step 3.2: Run the Docker container
Once the image is built, you can run the container using:

docker run -d -p 5000:5000 dns-ip-routing-article
This command will:

Run the container in the background (-d).
Map port 5000 on your local machine to port 5000 in the container (-p 5000:5000).

Step 3.3: Access the web page
Once the container is up and running, open your browser and go to http://localhost:5000. You should see the article displayed on the webpage.

Without DNS, we’d have to memorize numbers instead of domain names. Imagine having to remember IP addresses for every website you visit! No thanks!

Here’s a real-world example:

You type www.example.com into your browser.
Your browser asks the DNS server, “Hey, what’s the IP address for this domain?”
DNS responds with something like, “Sure, it’s 93.184.216.34.”
Now, your browser knows where to go to load the website!
Why should you care? Every time you search for something or access a webpage, DNS is working behind the scenes, making your internet experience faster and easier. Understanding DNS also helps troubleshoot when websites seem unreachable. It could be a DNS issue!

IP Routing: The Internet’s Roadmap
Once DNS translates the domain into an IP address, the next step is getting your data to its destination. This is where IP routing comes into play. Imagine driving from your home to a new restaurant. You might use a GPS app to find the best route, right? IP routing works in a similar way—it figures out the best path for your data to travel across the internet.

But the internet’s roads aren’t made of concrete—they’re made of networks. Routers act like traffic controllers, deciding where to send packets of data. Your data doesn’t travel in one giant piece; instead, it’s broken down into smaller packets, each of which takes the most efficient route possible to reach its destination.

Here’s how IP routing works in simple steps:

Image description

Your computer sends a packet of data to the destination IP address (which DNS helped you find).
The data passes through a series of routers, each one directing it closer to the destination.
Finally, the packets arrive, and the website loads or your email is delivered.
It sounds simple, but behind the scenes, routers are making split-second decisions based on traffic, distance, and other factors to ensure that your data gets where it needs to go. IP routing is what ensures that you can send a message from New York to Tokyo in the blink of an eye, with the data hopping between networks along the way.

Bringing DNS and IP Routing Together
Here’s how it all ties together: Every time you open a website, send an email, or stream a video, DNS and IP routing are working in tandem to make it happen.

DNS first translates the user-friendly domain name into an IP address.
IP routing then ensures that data travels across the most efficient networks to its destination.
Think of DNS as the translator and IP routing as the delivery service. Without one, you wouldn’t be able to find what you’re looking for, and without the other, your data wouldn’t know where to go.

Troubleshooting: When Things Go Wrong
Understanding the basics of DNS and IP routing can be a huge help when the internet isn’t cooperating. Here are two common scenarios:

Problem: You can’t access a website, but everything else works.

Potential cause: DNS issue. If DNS can’t translate the domain name into an IP address, your browser won’t know where to go.
Quick fix: Try clearing your DNS cache or switching to a public DNS service like Google’s 8.8.8.8.
Problem: Everything is super slow or not loading properly.

Potential cause: Routing issue. If there’s heavy traffic on the networks your data is traveling through, it can slow things down.
Quick fix: Restarting your router might help, or you can try using a VPN to route your traffic through less congested networks.
Why Understanding This Matters
It’s easy to take the internet for granted. We expect websites to load instantly, emails to send in seconds, and videos to stream smoothly. But when something goes wrong, having a basic understanding of DNS and IP routing gives you the power to diagnose issues, fix problems, or simply appreciate the complexity of what’s happening behind the scenes.

These two systems—DNS and IP routing—are like the air traffic controllers of the internet. They make sure your data gets where it needs to go quickly, efficiently, and safely. So, the next time you type a web address or send an email, give a nod to these unsung heroes that make your digital life seamless.

You wanna support me ? Just make a account and navigate!

. . . . . .
Terabox Video Player