Internet flow work

Example Scenario:1

Objective: You want to visit www.example.com.

  1. Entering the URL:

    • You type www.example.com into your browser’s address bar and hit Enter.
  2. DNS Resolution:

    • Step 1: Your browser checks if it has the IP address for www.example.com cached from a previous visit. If not, it sends a DNS request to your router.
    • Step 2: Your router, which may have its own DNS cache, checks if it has the IP address. If not, it forwards the DNS request to your ISP’s DNS server or a public DNS service like Google’s (8.8.8.8).
    • Step 3: The DNS server looks up www.example.com and returns the IP address, let’s say 93.184.216.34, back to your router.
    • Step 4: Your router forwards the IP address to your browser.
  3. Making the HTTP Request:

    • Step 1: Your browser now knows the IP address of www.example.com, so it creates an HTTP request to 93.184.216.34 asking for the webpage.
    • Step 2: The HTTP request is sent from your device with private IP 192.168.1.2 with source port 10001 to your router.
  4. Routing the Request:

    • Step 1: Your router receives the HTTP request and performs the NAT like Translates the private IP to public IP with unique port (192.168.1.2:10001 to 203.0.113.5:20001) and then forwards the request to your ISP’s network.
    • Step 2: The ISP’s network routes the request (with the router’s public IP address and the unique ports assigned by NAT) over the internet to the server at 93.184.216.34 where www.example.com is hosted.
  5. Server Response:

    • Step 1: The server at 93.184.216.34 processes the request and sends back the requested data (HTML, CSS, JavaScript) needed to display the webpage.
    • Step 2: This data travels back through the internet to your ISP’s network.
  6. Receiving the Response:

    • Step 1: The ISP routes the data back to your router.
    • Step 2: The router receives the response on public IP 203.0.113.5:20001 and translates it back to private IP 192.168.1.2:10001 and send the response to the respective device:192.168.1.2:10001.
  7. Rendering the Webpage:

    • Step 1: Your browser receives the data and processes it.
    • Step 2: The browser renders the webpage, displaying www.example.com for you to view.

Visual Flow Diagram

  1. Browser: Requests www.example.com
  2. DNS Lookup: Resolves to 93.184.216.34
  3. Router: Forwards request to ISP
  4. ISP: Routes request to server
  5. Server: Sends response
  6. ISP: Routes response back
  7. Router: Delivers response to browser
  8. Browser: Renders webpage


Example Scenario:2

You have 4 devices on a local network:

  • Device A: 192.168.1.2
  • Device B: 192.168.1.3
  • Device C: 192.168.1.4
  • Device D: 192.168.1.5

All devices are connected to a router with a single public IP address: 203.0.113.5.

Detailed Flow with NAT (PAT) and Ports

1. Devices Making Requests

  • Device A: Sends an HTTP request to www.example.com. The request originates from 192.168.1.2 with source port 10001.
  • Device B: Sends an HTTP request to www.example.org. The request originates from 192.168.1.3 with source port 10002.
  • Device C: Sends an HTTP request to www.example.net. The request originates from 192.168.1.4 with source port 10003.
  • Device D: Sends an HTTP request to www.example.edu. The request originates from 192.168.1.5 with source port 10004.

2. NAT (PAT) Process

  • Device A's Request:
    • Private IP and Port: 192.168.1.2:10001
    • Router Translation: Translates 192.168.1.2:10001 to 203.0.113.5:20001
  • Device B's Request:
    • Private IP and Port: 192.168.1.3:10002
    • Router Translation: Translates 192.168.1.3:10002 to 203.0.113.5:20002
  • Device C's Request:
    • Private IP and Port: 192.168.1.4:10003
    • Router Translation: Translates 192.168.1.4:10003 to 203.0.113.5:20003
  • Device D's Request:
    • Private IP and Port: 192.168.1.5:10004
    • Router Translation: Translates 192.168.1.5:10004 to 203.0.113.5:20004

The router assigns a unique port number for each request to distinguish between different connections.

3. Requests Sent to the Internet

  • The requests from each device are now sent to the destination servers with the router’s public IP address and the unique ports assigned by NAT:
    • Device A: 203.0.113.5:20001
    • Device B: 203.0.113.5:20002
    • Device C: 203.0.113.5:20003
    • Device D: 203.0.113.5:20004

4. Servers’ Responses

  • Servers respond to the public IP address and port numbers:
    • Response for Device A: Sent to 203.0.113.5:20001
    • Response for Device B: Sent to 203.0.113.5:20002
    • Response for Device C: Sent to 203.0.113.5:20003
    • Response for Device D: Sent to 203.0.113.5:20004

5. Router Handles Incoming Responses

  • Device A: The router receives the response on 203.0.113.5:20001 and translates it back to 192.168.1.2:10001.
  • Device B: The router receives the response on 203.0.113.5:20002 and translates it back to 192.168.1.3:10002.
  • Device C: The router receives the response on 203.0.113.5:20003 and translates it back to 192.168.1.4:10003.
  • Device D: The router receives the response on 203.0.113.5:20004 and translates it back to 192.168.1.5:10004.

6. Responses Delivered to Devices

  • The router forwards the responses to the correct devices based on the NAT table:
    • Device A receives the response at 192.168.1.2:10001.
    • Device B receives the response at 192.168.1.3:10002.
    • Device C receives the response at 192.168.1.4:10003.
    • Device D receives the response at 192.168.1.5:10004.

7. Rendering the Webpages

  • Each device processes the response and renders the webpage for the user to view.

Summary of Revised Flow

  1. Devices: Send requests with private IP addresses and source ports.
  2. Router (NAT): Translates private IP addresses and ports to public IP address and unique ports.
  3. Internet: Receives requests from the router’s public IP with unique ports.
  4. Servers: Send responses to the router’s public IP with unique ports.
  5. Router (NAT): Translates responses back to the correct private IP addresses and ports.
  6. Devices: Receive and process the responses.

Comments

Popular posts from this blog

How to enable the syslog monitoring-Zabbix

Zabbix installation: Distribution setup

API & API in Zabbix